Wild card incoming MQTT devices, so I have a dedicated MQTT conncector publishing to indigo/bulbs for now, and have set up the zigbee2mqtt friendly names (that is the topic for the control message, to be the same as the indigo deviceid.
All I need to do now for a new Hue bulb, is create the dummy device in Indigo and rename the device in zigbee2mqtt and I should have it controlled from indigo.
Time for bed but this is looking good. So much so I have just ordered 4 more zigbee bulbs to get a stronger mesh working.
- Code: Select all
[{"id":"912583bd.193ff","type":"tab","label":"Zigbee bulbs","disabled":false,"info":""},{"id":"197df9cb.54b346","type":"mqtt in","z":"912583bd.193ff","name":"","topic":"indigo/bulbs/#","qos":"0","datatype":"auto","broker":"628714c4.ba20ac","x":150,"y":220,"wires":[["64f796c3.fb2568"]]},{"id":"64f796c3.fb2568","type":"yaml","z":"912583bd.193ff","property":"payload","name":"","x":330,"y":220,"wires":[["b3a7269b.9b6888"]]},{"id":"4ade006f.5dc57","type":"switch","z":"912583bd.193ff","name":"","property":"payload.states.blueLevel","propertyType":"msg","rules":[{"t":"nnull"},{"t":"null"}],"checkall":"true","repair":false,"outputs":2,"x":990,"y":220,"wires":[["afd675e3.e48768"],["14c27476.c3293c"]]},{"id":"14c27476.c3293c","type":"template","z":"912583bd.193ff","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"state\":\"{{payload.states.onOffState}}\",\n\"brightness\":\"{{payload.states.brightnessLevel}}\",\n\"color_temp\":\"{{payload.states.color_temp}}\"}","output":"str","x":1200,"y":300,"wires":[["ac6914e7.86bcc8"]]},{"id":"afd675e3.e48768","type":"template","z":"912583bd.193ff","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{\"state\":\"{{payload.states.onOffState}}\",\n\"brightness\":\"{{payload.states.brightnessLevel}}\",\n\"color\":\n{\"r\":\"{{payload.states.redLevel}}\",\n\"g\":\"{{payload.states.greenLevel}}\",\n\"b\":\"{{payload.states.blueLevel}}\"}}","output":"str","x":1200,"y":160,"wires":[["5269ca8a.5f63b4"]]},{"id":"9b280440.dd88d8","type":"change","z":"912583bd.193ff","name":"","rules":[{"t":"delete","p":"payload.name","pt":"msg"},{"t":"change","p":"payload.states.onOffState","pt":"msg","from":"True","fromt":"str","to":"ON","tot":"str"},{"t":"change","p":"payload.states.onOffState","pt":"msg","from":"False","fromt":"str","to":"OFF","tot":"str"},{"t":"set","p":"payload.states.brightnessLevel","pt":"msg","to":"$number(payload.states.brightnessLevel)","tot":"jsonata"},{"t":"set","p":"payload.states.color_temp","pt":"msg","to":"payload.states[\"whiteTemperature.ui\"]","tot":"msg"},{"t":"set","p":"payload.states.color_temp","pt":"msg","to":"1000000/$number(payload.states.color_temp)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":660,"y":220,"wires":[["8d992373.40f7f"]]},{"id":"8d992373.40f7f","type":"template","z":"912583bd.193ff","name":"","field":"topic","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"zigbee2mqtt/{{payload.deviceId}}/set/","output":"str","x":840,"y":220,"wires":[["4ade006f.5dc57"]]},{"id":"5269ca8a.5f63b4","type":"mqtt out","z":"912583bd.193ff","name":"","topic":"","qos":"0","retain":"false","broker":"628714c4.ba20ac","x":1370,"y":160,"wires":[]},{"id":"ac6914e7.86bcc8","type":"mqtt out","z":"912583bd.193ff","name":"","topic":"","qos":"0","retain":"false","broker":"628714c4.ba20ac","x":1370,"y":300,"wires":[]},{"id":"b3a7269b.9b6888","type":"range","z":"912583bd.193ff","minin":"0","maxin":"100","minout":"0","maxout":"255","action":"clamp","round":true,"property":"payload.states.brightnessLevel","name":"","x":480,"y":220,"wires":[["9b280440.dd88d8"]]},{"id":"628714c4.ba20ac","type":"mqtt-broker","z":"","name":"qnap mqqt","broker":"192.168.0.104","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
So it
converts message string to object,
scales the brightness,
changes True/False to ON/OFF,
changes brightness level from string to number (need to check if actually required),
creates template for the MQTT topic,
splits if RGB or colour_temp,
creates template for the payload, then sends the MQTT message.