Skip to content

Instantly share code, notes, and snippets.

@Micha2536
Created November 12, 2018 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Micha2536/ca42fa0e9ae352c5497b34ca12cc0a5e to your computer and use it in GitHub Desktop.
Save Micha2536/ca42fa0e9ae352c5497b34ca12cc0a5e to your computer and use it in GitHub Desktop.
homee-Statusmeldung-Sonos-Wemorückkanal

Mit Diesem Flow kannst du den Zustand deiner Sonos Box zurückmelden an homee. Verwendet wurde ein Wemoemu zum schalten in homee. Wenn die Sonos Box nun per App geschaltet wird, bekommt das homee über den Flow zurückgemeldet.

[{"id":"daaee97f.34d168","type":"better-sonos-status","z":"eeb0b50.5800748","confignode":"","name":"Sonos","x":690,"y":280,"wires":[["df199e75.74ccf"]]},{"id":"df199e75.74ccf","type":"function","z":"eeb0b50.5800748","name":"Prüfen des Zustandes der Sonos Box","func":"var nodeid = 0; // node ID in homee vom Wemo\nvar attributid = 0; // attribut ID in homee vom Wemo\nconst attributes = global.get('homee.attributes');\nvar status = attributes.filter(attribute => attribute.id === attributid).map(a => a.current_value).reduce((a,c) => a+c);\n\nif (msg.state === \"stopped\" && status === 1)\n{return {payload: \"PUT:/nodes/\"+nodeid+\"/attributes/\"+attributid+\"?target_value=0\"}}\nif (msg.state === \"playing\" && status === 0)\n{return {payload: \"PUT:/nodes/\"+nodeid+\"/attributes/\"+attributid+\"?target_value=1\"}}\n","outputs":1,"noerr":0,"x":930,"y":280,"wires":[["cbc6ea51.199a68"]]},{"id":"8357cb52.17cfd8","type":"inject","z":"eeb0b50.5800748","name":"","topic":"","payload":"","payloadType":"date","repeat":"10","crontab":"","once":false,"onceDelay":0.1,"x":490,"y":280,"wires":[["daaee97f.34d168"]]},{"id":"cbc6ea51.199a68","type":"homee","z":"eeb0b50.5800748","name":"","host":"","x":1170,"y":280,"wires":[[]]},{"id":"140dfba0.be6504","type":"wemo-emulator","z":"eeb0b50.5800748","name":"Sonos ","friendlyName":"Sonos ","serial":"554423","port":"34523","onTopic":"on","onPayload":"on","offTopic":"off","offPayload":"off","x":490,"y":400,"wires":[["2ea5c614.77b56a"]]},{"id":"2ea5c614.77b56a","type":"switch","z":"eeb0b50.5800748","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"on","vt":"str"},{"t":"eq","v":"off","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":788,"y":399,"wires":[["2d8b322e.66e04e"],["65bc5bce.538cb4"]],"outputLabels":["on",""]},{"id":"2d8b322e.66e04e","type":"sonos-control","z":"eeb0b50.5800748","playnode":"","name":"","mode":"play","track":"","volume":"empty","volume_value":"","x":1090,"y":357,"wires":[]},{"id":"65bc5bce.538cb4","type":"sonos-control","z":"eeb0b50.5800748","playnode":"","name":"","mode":"pause","track":"","volume":"","volume_value":"","x":1091,"y":417,"wires":[]}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment