-
Notifications
You must be signed in to change notification settings - Fork 38
homebridge2NodeRED
cflurin edited this page Oct 27, 2018
·
3 revisions
The example-flow demonstrates a bi-directional communication between node-red and homebridge-mqtt:
- add the accessory office_lamp
topic: homebridge/to/add
payload: {"name":"office_lamp","service":"Switch"}
- now you can set office_lamp to on (true) or off (false)
topic: homebridge/to/set
payload: {"name":"office_lamp","characteristic":"On","value":true}
or
payload: {"name":"office_lamp","characteristic":"On","value":false}
- diplay the messages from homebridge-mqtt in the debug tab:
topic: homebridge/from/#
- To test this example flow copy the code and import it into node-red.
[{"id":"cc36cd2c.a2431","type":"mqtt out","z":"8eb4cc4d.73ef5","name":"","topic":"homebridge/to/add","qos":"","retain":"","broker":"325f5be5.555734","x":470,"y":1900,"wires":[]},{"id":"36e3c0e.46dda4","type":"inject","z":"8eb4cc4d.73ef5","name":"add office_lamp","topic":"","payload":"{\"name\":\"office_lamp\",\"service\":\"Switch\"}","payloadType":"json","repeat":"","crontab":"","once":false,"x":160,"y":1900,"wires":[["cc36cd2c.a2431"]]},{"id":"5cbe73cb.1d80fc","type":"mqtt out","z":"8eb4cc4d.73ef5","name":"","topic":"homebridge/to/set","qos":"","retain":"","broker":"325f5be5.555734","x":470,"y":1960,"wires":[]},{"id":"edc5bba8.7546f8","type":"inject","z":"8eb4cc4d.73ef5","name":"office_lamp on","topic":"","payload":"{\"name\":\"office_lamp\",\"characteristic\":\"On\",\"value\": true}","payloadType":"json","repeat":"","crontab":"","once":false,"x":160,"y":1960,"wires":[["5cbe73cb.1d80fc"]]},{"id":"e9155373.ff06e","type":"inject","z":"8eb4cc4d.73ef5","name":"office_lamp off","topic":"","payload":"{\"name\":\"office_lamp\",\"characteristic\":\"On\",\"value\": false}","payloadType":"json","repeat":"","crontab":"","once":false,"x":160,"y":2000,"wires":[["5cbe73cb.1d80fc"]]},{"id":"8e81a4e3.072168","type":"mqtt in","z":"8eb4cc4d.73ef5","name":"","topic":"homebridge/from/#","qos":"2","broker":"325f5be5.555734","x":150,"y":1820,"wires":[["3d01e5b7.937e7a"]]},{"id":"618bc320.42cbec","type":"debug","z":"8eb4cc4d.73ef5","name":"","active":true,"console":"false","complete":"false","x":550,"y":1820,"wires":[]},{"id":"3d01e5b7.937e7a","type":"json","z":"8eb4cc4d.73ef5","name":"","property":"payload","action":"obj","pretty":false,"x":370,"y":1820,"wires":[["618bc320.42cbec"]]},{"id":"325f5be5.555734","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.35","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""}]
In the mqtt nodes config set your mqtt-broker.