Created
April 28, 2017 09:12
-
-
Save janhuddel/862ae79638ad662021e1e8ea5912d13f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"id": "94300d26.02bc3", | |
"type": "tab", | |
"label": "hue2hm" | |
}, | |
{ | |
"id": "f2a5ef5d.edde6", | |
"type": "inject", | |
"z": "94300d26.02bc3", | |
"name": "alle 10 Sekunden", | |
"topic": "", | |
"payload": "", | |
"payloadType": "date", | |
"repeat": "10", | |
"crontab": "", | |
"once": true, | |
"x": 130, | |
"y": 80, | |
"wires": [ | |
[ | |
"37cc2292.89d01e" | |
] | |
] | |
}, | |
{ | |
"id": "37cc2292.89d01e", | |
"type": "http request", | |
"z": "94300d26.02bc3", | |
"name": "get light state", | |
"method": "GET", | |
"ret": "obj", | |
"url": "http://hue.ip/api/xgo5Y8iUMoKnqPe7o8VeDiwrzXNhADOD27pblZOC/lights", | |
"tls": "", | |
"x": 280, | |
"y": 140, | |
"wires": [ | |
[ | |
"c015ff1f.3ec08" | |
] | |
] | |
}, | |
{ | |
"id": "c015ff1f.3ec08", | |
"type": "function", | |
"z": "94300d26.02bc3", | |
"name": "process & split", | |
"func": "var lights = msg.payload;\n\nvar messages = [];\nfor (var key in lights) {\n if (lights.hasOwnProperty(key)) {\n \n var current = lights[key];\n var cache = flow.get('hue#'+key);\n var updateRequired = true;\n \n // hat sich der Zustand geändert?\n if (cache !== undefined && current.state.on === cache.state.on) {\n updateRequired = false;\n } \n \n if (updateRequired) {\n messages.push({\n 'topic': key,\n 'payload': current.state.on\n });\n \n // Update Cache\n flow.set('hue#'+key, current);\n }\n }\n}\nreturn [ messages ];", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 420, | |
"y": 80, | |
"wires": [ | |
[ | |
"65bcc584.d8ba7c" | |
] | |
] | |
}, | |
{ | |
"id": "65bcc584.d8ba7c", | |
"type": "map", | |
"z": "94300d26.02bc3", | |
"name": "map light", | |
"property": "topic", | |
"propertyType": "msg", | |
"mappingTable": "2462ebb.1f66a14", | |
"x": 540, | |
"y": 140, | |
"wires": [ | |
[ | |
"d868cc79.96d13" | |
] | |
] | |
}, | |
{ | |
"id": "a5307c0d.abd0f", | |
"type": "hmrega", | |
"z": "94300d26.02bc3", | |
"name": "", | |
"ccu2ip": "ccu2.ip", | |
"ccu2port": 80, | |
"x": 780, | |
"y": 140, | |
"wires": [ | |
[ | |
"f8d4ac1d.f7648" | |
] | |
] | |
}, | |
{ | |
"id": "d868cc79.96d13", | |
"type": "function", | |
"z": "94300d26.02bc3", | |
"name": "prepare rega", | |
"func": "var state = msg.payload ? 1 : 0;\n\nmsg.payload = \"dom.GetObject('CUxD.\" + msg.topic +\n \".SET_STATE').State(\" + state + \");\";\n\nreturn msg;", | |
"outputs": 1, | |
"noerr": 0, | |
"x": 650, | |
"y": 80, | |
"wires": [ | |
[ | |
"a5307c0d.abd0f" | |
] | |
] | |
}, | |
{ | |
"id": "f8d4ac1d.f7648", | |
"type": "debug", | |
"z": "94300d26.02bc3", | |
"name": "", | |
"active": false, | |
"console": "false", | |
"complete": "false", | |
"x": 910, | |
"y": 80, | |
"wires": [] | |
}, | |
{ | |
"id": "2462ebb.1f66a14", | |
"type": "mapping-table", | |
"z": "", | |
"name": "hue2hm", | |
"map": [ | |
{ | |
"search": "1", | |
"replace": "CUX4000002:1" | |
}, | |
{ | |
"search": "2", | |
"replace": "CUX4000002:2" | |
}, | |
{ | |
"search": "3", | |
"replace": "CUX4000002:3" | |
}, | |
{ | |
"search": "4", | |
"replace": "CUX4000003:1" | |
}, | |
{ | |
"search": "5", | |
"replace": "CUX4000003:2" | |
}, | |
{ | |
"search": "7", | |
"replace": "CUX4000001:1" | |
}, | |
{ | |
"search": "8", | |
"replace": "CUX4000005:1" | |
}, | |
{ | |
"search": "9", | |
"replace": "CUX4000004:1" | |
}, | |
{ | |
"search": "10", | |
"replace": "CUX4000002:6" | |
} | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment