That looks nice. I created a clean flow, wich you can use as an example.I only have it working for a short while, but it looks like it's working flawles.
1. As you see, the upper stream is from Casambi to Domoticz, while the lower is from Domoticz to Casambi.
2. In the upper stream the top is used for a dimmable lamp and the lower part is used for a dimmable lamp with adjustable color temperature.
3. If you have more lamps of a particular type, you can copy the two nodes (marked "Choose accessory/service" and "Set topic") and feed them to the function node.
4. You have to set your Domotixz IDX in the "Set topic" node.
5. In the lower stream, you have to set the Domoticz IDX in the node, called "Filter Idx", which you can expand to the number of lamps you have.
6. Dependent on the type of lamp (only dimmable or with color temperature) you copy the function node and the Homebridge output node and connect the function node to the corresponding output of the "Switch" node.
The corresponding flow, you will find below.
Code: Select all
[{"id":"f969203d.64c2d","type":"hb-event","z":"8331ad68.1e8ba","name":"","Homebridge":"","Manufacturer":"","Service":"","device":"","conf":"ad94f0af.d9b61","x":230,"y":60,"wires":[["322df4f5.4e1f6c"]]},{"id":"72b367de.e52358","type":"function","z":"8331ad68.1e8ba","name":"","func":"if (msg.payload.On === true)\n\n{\n msg.payload = {\n \"command\": \"switchlight\",\n \"idx\": msg.topic,\n \"switchcmd\": \"Set Level\",\n \"level\": msg.payload.Brightness\n }\n}\n\nelse if (msg.payload.On === false)\n\n{\n msg.payload = {\n \"command\": \"switchlight\",\n \"idx\": msg.topic,\n \"switchcmd\": \"Off\",\n };\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":60,"wires":[["67a7be59.c329b"]]},{"id":"387ae58a.a6af2a","type":"function","z":"8331ad68.1e8ba","name":"","func":"if (msg.payload.On === true)\n{\n msg.payload = {\n \"command\": \"setcolbrightnessvalue\",\n \"idx\": msg.topic,\n \"brightness\": msg.payload.Brightness,\n \"color\": {\n \"m\": 2,\n \"t\": parseInt((msg.payload.ColorTemperature -222) * (255/232))\n }\n }\n} \nelse if (msg.payload.On === false)\n{\n msg.payload = {\n \"command\": \"switchlight\",\n \"idx\": msg.topic,\n \"switchcmd\": \"Off\"\n };\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":640,"y":140,"wires":[["67a7be59.c329b"]]},{"id":"67a7be59.c329b","type":"mqtt out","z":"8331ad68.1e8ba","name":"Domoticz In","topic":"domoticz/in","qos":"","retain":"","broker":"c2d9657a.d81bf8","x":830,"y":100,"wires":[]},{"id":"3a2d0867.54c118","type":"mqtt in","z":"8331ad68.1e8ba","name":"Domoticz Out","topic":"domoticz/out","qos":"2","datatype":"json","broker":"c2d9657a.d81bf8","x":190,"y":259,"wires":[["ac0c58eb.b08dd8"]]},{"id":"ac0c58eb.b08dd8","type":"switch","z":"8331ad68.1e8ba","name":"Filter Idx","property":"payload.idx","propertyType":"msg","rules":[{"t":"eq","v":"22","vt":"str"},{"t":"eq","v":"23","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":259,"wires":[["80d1d798.ab93c8"],["8def210e.ad7408"]]},{"id":"80d1d798.ab93c8","type":"function","z":"8331ad68.1e8ba","name":"","func":"switch (msg.payload.nvalue) {\n \n case 0: //Uit\n msg.payload = {\"On\":false,\"Brightness\":0};\n break;\n\n case 1: //Aan\n case 2: //Dimmer stand\n msg.payload = {\"On\":true,\"Brightness\":parseInt(msg.payload.svalue1)};\n break;\n\n \n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":219,"wires":[["5f47300e.8d402"]]},{"id":"5f47300e.8d402","type":"hb-control","z":"8331ad68.1e8ba","name":"","Homebridge":"","Manufacturer":"","Service":"","device":"","conf":"361f342f.410a7c","x":790,"y":219,"wires":[]},{"id":"8def210e.ad7408","type":"function","z":"8331ad68.1e8ba","name":"","func":"switch (msg.payload.nvalue) {\n \n case 0: //Uit\n msg.payload = {\"On\":false,\"Brightness\":0};\n break;\n \n case 1: //Aan\n case 10: //Color Temperature\n case 15: //Dimmer stand\n msg.payload = {\"On\":true,\"Brightness\":parseInt(msg.payload.svalue1),\"ColorTemperature\":parseInt((msg.payload.Color.t) * (232/255) + 222)};\n break;\n\n}\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":300,"wires":[["4f13924d.282e94"]]},{"id":"4f13924d.282e94","type":"hb-control","z":"8331ad68.1e8ba","name":"","Homebridge":"","Manufacturer":"","Service":"","device":"","conf":"361f342f.410a7c","x":790,"y":300,"wires":[]},{"id":"57a1bdf2.efbb6c","type":"hb-event","z":"8331ad68.1e8ba","name":"","Homebridge":"","Manufacturer":"","Service":"","device":"","conf":"ad94f0af.d9b61","x":230,"y":140,"wires":[["dcc781e6.6c7d5"]]},{"id":"322df4f5.4e1f6c","type":"change","z":"8331ad68.1e8ba","name":"Set topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"22","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":60,"wires":[["72b367de.e52358"]]},{"id":"dcc781e6.6c7d5","type":"change","z":"8331ad68.1e8ba","name":"Set topic","rules":[{"t":"set","p":"topic","pt":"msg","to":"23","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":460,"y":140,"wires":[["387ae58a.a6af2a"]]},{"id":"ad94f0af.d9b61","type":"hb-conf","z":"","username":"12345"},{"id":"c2d9657a.d81bf8","type":"mqtt-broker","z":"","name":"","broker":"127.0.0.1","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"361f342f.410a7c","type":"hb-conf","z":"","username":"12345"}]