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":[]}]

Flow Info

Created 5 years, 11 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • function (x1)
  • inject (x1)
  • switch (x1)
Other

Tags

Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option