README.md
simple bridge FIBARO HC2 to NODE-RED
please do not forget setup
1) NODE-RED MQTT server
2) login / password / IP address HC2
flow.json
[{"id":"3564e897.facab8","type":"http request","z":"dae260f4.2feda","name":"from HC2","method":"GET","ret":"obj","url":"http://192.168.1.36/api/refreshStates?last={{{query}}}","tls":"","x":500,"y":80,"wires":[["ae2fa308.b6785"]]},{"id":"aa852586.bf5798","type":"inject","z":"dae260f4.2feda","name":"query parameter","topic":"","payload":"0","payloadType":"num","repeat":"10","crontab":"","once":false,"x":140,"y":80,"wires":[["a3401a51.9c95c8"]]},{"id":"a3401a51.9c95c8","type":"function","z":"dae260f4.2feda","name":"get last param","func":"var last = flow.get('last') || 0;\nmsg.query = last\nreturn msg;","outputs":1,"noerr":0,"x":320,"y":80,"wires":[["3564e897.facab8"]]},{"id":"ae2fa308.b6785","type":"function","z":"dae260f4.2feda","name":"parse events","func":"flow.set(\"last\", msg.payload.last); \nmsg.payload = msg.payload[\"changes\"];\nif ( typeof msg.payload !== 'undefined' ) {\n msg.payload.forEach(function(table) {\n if ( typeof table.log == 'undefined' ) {\n if (typeof table.value !== 'undefined' && table.value !== null){\n var event={};\n event.topic = \"home/status/\" + table.id;\n event.payload = table.value; \n /*\n if (typeof table.lastBreached !== 'undefined' && table.lastBreached !== null){\n event.payload = table; \n } else {\n event.payload = table.value; \n }\n */\n // node.status({text:\"Toggle switch_s6\"}); \n node.send([event]);\n }\n }\n });\n}\nreturn null;\n","outputs":1,"noerr":0,"x":690,"y":80,"wires":[["ef657a52.5e5b28","3cdfb244.dbcf5e"]]},{"id":"3cdfb244.dbcf5e","type":"mqtt out","z":"dae260f4.2feda","name":"HC2","topic":"","qos":"","retain":"","broker":"50ba17cb.2fbd18","x":850,"y":80,"wires":[]},{"id":"ef657a52.5e5b28","type":"debug","z":"dae260f4.2feda","name":"","active":false,"tosidebar":true,"console":false,"complete":"false","x":870,"y":20,"wires":[]},{"id":"50ba17cb.2fbd18","type":"mqtt-broker","z":"dae260f4.2feda","broker":"192.168.1.29","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":"","willTopic":"","willQos":"0","willRetain":null,"willPayload":""}]