Closed andesse closed 2 years ago
Update: What I found out so far. I figured out the reason why HUE is doing this. Instead of fire a lot of different messages the new firmware combines it to one message with up to 16! data objects. What I figured out so far, one for lights, one for dimming, one for group and a second group (what I have no idea what it is)
In the screenshot you can see my room, Küche, it has the RID shown above as a comment that is used in the change node. At the moment I don’t receive any updates, for this reason: in the new message from the eventstream the correct grouped_light is at data point 3, so all switches need to be changed.
I won’t make any changes in this repository until Saturday evening, cause I still need to figure out what actually changed. If I add a new setup, this one will get a V3 prefix
@FredBlo what do you need for informations, to integrate this into your V2 approach? This is your work, hahah
I made a very ugly workaround that works. As the updated API sends arrays up to 16 objects (in my case,see screenshot) for the reason, that the rid/ ID cycles through the objects, this subflow will fillter up to 20 objects in the array, you can add more if needed.
https://github.com/andesse/hue-clip-api.node-red-flows/blob/main/V3_light_receiver.json
Using this you will get a true / false response again. Everthing else seems to be fine. The problem occurs for lights and group responses. Latency did not change for me, still instant response
I found a better solution that I’ll test now. The data array will get splitted directly after the event flow node. This means that there will be some changes in the switch nodes, cause they won’t search for payload.data.0.id anymore. Instead it will be payload.id
That means I will create a package now for people who need to update their existing flow, and a new version of the main flow.
@FredBlo i will use your flow example to create the new flow for the upcoming update.
New Release
@andesse ,
Based on the bridge update you talked about, I spend a 'bit of time' to made a few checks & tests :
HUE Bridge documentation is quite clear about what occurs here, as stated in eventstream doc :
*"There is a 1 second rate limit on the amount of event containers the Bridge will send. If the same property has changed twice within that timeframe, you only get the last state. If multiple resources have changed within that timeframe, then you will get multiple events grouped in a single container."*
Working as designed / documented from the beginning ... but I presume the new bridge firmware is a bit more aggressive when it has to decide whether it aggregates '.data' or not...
The Philips HUE events (@yadomi/node-red-contrib-philipshue-events) will 'forward' any message received from the bridge as such. This means it will always be an array of '.data', which can hold 1 to n entries :
-> extract from file 'philipshue-events-config.ts' :
const events = JSON.parse(message.data);
this.emitter.emit("event", events);
The HUEMagic node splits the message it received from the bridge. By doing so, each '.data' of the array will initiate a new flow natively:
-> extract from file 'api.js' :
const messages = JSON.parse(event.data);
for (var i = messages.length - 1; i >= 0; i--)
{
const message = messages[i];
[...]
callback(message.data);
[...]
}
The 'philipshue-events-config.ts' could easily be updated to manage data split natively (while keeping every data part received under a single array (data):
const events = JSON.parse(message.data);
for (var i = events.length - 1; i >= 0; i--)
{
this.emitter.emit("event", [events[i]]);
}
Note : HUEMagic is processing incoming data from last to first, I don't know whether there is a reason for this, but I kept this same logic, not sure it is the way to go...
The flow can also be adapted to manage itself splitting '.data' in separated flows. The way you made it in your update is good at doing so. The sole drawback I see is the fact it is not backward compatible (i.e. you have to change your already created (sub)flows since '.data' is moved as such to '.payload'). I would either re-move back payload to payload.data after the split, or use a simple function call which will split as required :
[{"id":"e07e18793ef596bf","type":"comment","z":"68ad1cd9aa26e13b","name":"Converter seperates the array","info":"","x":660,"y":600,"wires":[]},{"id":"b76bc75ac8191065","type":"function","z":"68ad1cd9aa26e13b","name":"1 data per flow","func":"for (var i = 0; i < msg.payload.data.length; i++) {\n // Create a deep copy of msg object\n let splitmsg = JSON.parse(JSON.stringify(msg));\n\n // Reset data of new message to its single data part\n splitmsg.payload.data = [msg.payload.data[i]];\n \n // send using node\n node.send(splitmsg);\n}\n\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":640,"y":560,"wires":[["2a141678adf47667","cc2ef99d4ab569ae"]]},{"id":"5dedd8e42abed89d","type":"philipshue-events","z":"68ad1cd9aa26e13b","bridge":"","x":400,"y":560,"wires":[["b76bc75ac8191065"]]},{"id":"2a141678adf47667","type":"debug","z":"68ad1cd9aa26e13b","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":890,"y":560,"wires":[]},{"id":"cc2ef99d4ab569ae","type":"link out","z":"68ad1cd9aa26e13b","name":"link out 4","mode":"link","links":["0c8f88588b2a2b4f"],"x":835,"y":520,"wires":[]}]
PS : I rather not use a subflow for it because it is normally a single use-case, but maybe you use it for multiple receivers in your system (?)
More globally, I think it would be better / easier to only keep a single valid file with all content in it. In its current state, new users will have more difficult to find their way (do I have to use V2, V3,...), and existing users do not directly see what's new... I would have a v2 'valid' and a v3 beta (which is v2 with your updated approach for now).
@FredBlo I understand the concept in general, BUT on my old FW bridge I get a lot of status messages when I turn off (there came like 5-6 more then on this screenshot)
and the new firmware gives me one
message object with an array
I use a subflows with where I change the payload.data to payload and use a split node afterwards. it’s already available for download and works like a charm for me.
And yes, I have two bridges, one for the Livingroom (non beta) and for the rest of the apartment (beta)
i will hit Yadomi up for this reason, I will try to edit the file manually and if it works I’ll ask him to update.
Good point, I will a makeover in the next days and merge everything in one flow. Think there will be need to write the readme more clearly as well.
This was more like an emergency update that everyone can prepare.
Your previous explanations were clear about going for multiple messages to a single grouped one.
The function I posted / suggest is actually a splitter which will send 1 separate msg (flow) per .data element in the received array. The result is the same as what you achieved in your subfow, only you keep the initial structure with payload containing '.data' which is an array of 1 single data object (=as before FW upgrade, using msg.payload.data[0]), while the splitter you used modifies the msg structure with msg.payload containing what was before set in msg.payload.data[0]
@FredBlo ok, i went back and used the function node from you now. so nobody need to update the receivers. It is already online for now.
@FredBlo I will merge our two flows tomorrow and update the readme and remove the V2 prefix flow so that there is just one. I like the splitter function node, that should be the best approach for the array. I’ll also add a 3 node flow to create the user token, I just tried it and it works fine and add some more change node examples for actions. Then it should be fine for a while.
I got recently some feedback from different communities, what should be changed in the readme for a better understanding. That’s a thing I want to do as well.
Any suggestions or ideas what need to added as well?
I was a bit too fast at analyzing '@yadomi/node-red-contrib-philipshue-events' node-set yesterday :-) (I also looked at code on GitHub, not on deployed node-red, which is indeed a .js with some imports being different, but no change to code itself)
Since I do not have the issue (of .data array) myself, a bit complex to reproduce... But I understood a bit better what -I think- is occurring.
The HUE bridge is already aggregating data 'as documented'... and the current node is also performing a split on incoming events. But the way data are being aggregated by the bridge changed... In previous bridge versions, you received a single eventstream from the bridge being an array of events
[
{
"creationtime": "2022-09-06T06:55:43Z",
"data": [=single array with {content}-],
"id": "b0ce6895-c31a-41a2-9fc7-392e19947006",
"type": "update"
},
{
"creationtime": "2022-09-06T06:55:43Z",
"data": [=single array with {content}-],
"id": "3ad5ac3f-09e0-4dea-a53f-8f5b7cfa770a",
"type": "update"
},
{
"creationtime": "2022-09-06T06:55:43Z",
"data": [=single array with {content}-],
"id": "0bc30764-ca81-453f-ad13-2cb83c877bb7",
"type": "update"
}
]
The yadomi's node correctly split in separated flows (only it is made in 'philipshue-events.js', not in 'philipshue-events-config.js', which I didn't see)
Based, on your info, the new bridge FW also sends a single eventstream container only its globalized at .data level, meaning something like
[
{
"creationtime": "2022-09-06T06:55:43Z",
"data": [
{data info1},
{data info2},
{data info3}
],
"id": "b0ce6895-c31a-41a2-9fc7-392e19947006",
"type": "update"
},
]
Conclusions
"use strict";
const nodeInit = (RED) => {
const node = function (config) {
const status = {
incoming: () => {
this.status({ fill: "blue", text: "Incoming..." });
setTimeout(status.listening, 1000);
},
connected: () => {
this.status({ fill: "green", text: "Connected" });
setTimeout(status.listening, 2000);
},
disconected: () => {
this.status({ fill: "red", text: "Not connected" });
},
listening: () => {
this.status({ fill: "green", text: "Listening" });
},
error: () => {
this.status({ fill: "red", text: "Error" });
},
};
RED.nodes.createNode(this, config);
status.disconected();
this.bridge = RED.nodes.getNode(config.bridge);
if (!this.bridge)
return;
status.listening();
this.bridge.emitter.on("event", (events) => {
status.incoming();
for (const event of events) {
for (var i = 0; i < event.data.length; i++) {
// Create a deep copy of msg object
let splitevent = JSON.parse(JSON.stringify(event));
// Reset data of new message to its single data part
splitevent.data = [event.data[i]];
// send using node
this.send({ payload: splitevent });
}
}
});
this.bridge.emitter.on("error", (error) => {
status.error();
this.send({ payload: error });
});
this.bridge.emitter.on("onopen", status.connected);
};
RED.nodes.registerType("philipshue-events", node);
};
module.exports = nodeInit;
- not sure this is a wanted behaviour from HUE actually, since change is quite important for all already developed connectors... Maybe post about this in their dev / support if you have any contact ?
@FredBlo hi, i reached out to the developers, waiting for reply. I really think that your function spllitter does a great job. In my opinion we should use that one. I started to merge the flows. Here is what i did so far, i want it as easy as possible to understand.
As I had never issues with the http request nodes, i added your approach as an alternative, cause I think that without the limiter the easy http request flow might have a little bit better performance. What do you think?
[{"id":"7a14643a.75260c","type":"subflow","name":"Splitter","info":"","category":"","in":[{"x":540,"y":300,"wires":[{"id":"273108cc.4b9928"}]}],"out":[{"x":960,"y":300,"wires":[{"id":"a7524f72.576f3","port":0},{"id":"f3125664899350c0","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"273108cc.4b9928","type":"switch","z":"7a14643a.75260c","name":"","property":"topic","propertyType":"msg","rules":[{"t":"eq","v":"split","vt":"str"},{"t":"eq","v":"array","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":630,"y":300,"wires":[["fb18185d.5df9e8"],["f3125664899350c0"]]},{"id":"a7524f72.576f3","type":"split","z":"7a14643a.75260c","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":810,"y":240,"wires":[[]]},{"id":"fb18185d.5df9e8","type":"change","z":"7a14643a.75260c","name":"del topic","rules":[{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":280,"wires":[["a7524f72.576f3"]]},{"id":"f3125664899350c0","type":"change","z":"7a14643a.75260c","name":"del topic","rules":[{"t":"delete","p":"topic","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":320,"wires":[[]]},{"id":"d1abcd4.10bc03","type":"subflow","name":"Request Timer","info":"","category":"","in":[{"x":320,"y":180,"wires":[{"id":"ae3b4275178b1b9a"}]}],"out":[{"x":860,"y":300,"wires":[{"id":"244e6655.741d9a","port":0},{"id":"6bd8af1f.89fdd","port":0},{"id":"2a5d491d.97c806","port":0},{"id":"9e7f2747.5c4628","port":0},{"id":"c2dcb099.f3e78","port":0},{"id":"9fd56572.0c0b38","port":0},{"id":"f15b3597.8713b8","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"f0a2d4f4.19a288","type":"delay","z":"d1abcd4.10bc03","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":480,"y":220,"wires":[["6bd8af1f.89fdd","a0bdc284.5e792"]]},{"id":"a0bdc284.5e792","type":"delay","z":"d1abcd4.10bc03","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":480,"y":260,"wires":[["2a5d491d.97c806","ffdeebc6.4d7b88"]]},{"id":"244e6655.741d9a","type":"change","z":"d1abcd4.10bc03","name":"room","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"set","p":"endpoint","pt":"msg","to":"room","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":180,"wires":[[]]},{"id":"6bd8af1f.89fdd","type":"change","z":"d1abcd4.10bc03","name":"zone","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"set","p":"endpoint","pt":"msg","to":"zone","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":220,"wires":[[]]},{"id":"2a5d491d.97c806","type":"change","z":"d1abcd4.10bc03","name":"scene","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"set","p":"endpoint","pt":"msg","to":"scene","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":260,"wires":[[]]},{"id":"ffdeebc6.4d7b88","type":"delay","z":"d1abcd4.10bc03","name":"","pauseType":"delay","timeout":"4","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":480,"y":300,"wires":[["c2dcb099.f3e78","b2ade02a.ff9c1"]]},{"id":"c2dcb099.f3e78","type":"change","z":"d1abcd4.10bc03","name":"device","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"set","p":"endpoint","pt":"msg","to":"device","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":300,"wires":[[]]},{"id":"9e7f2747.5c4628","type":"change","z":"d1abcd4.10bc03","name":"motion","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"set","p":"endpoint","pt":"msg","to":"motion","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":340,"wires":[[]]},{"id":"b2ade02a.ff9c1","type":"delay","z":"d1abcd4.10bc03","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":480,"y":340,"wires":[["9e7f2747.5c4628","db7b216c.0f12c"]]},{"id":"9fd56572.0c0b38","type":"change","z":"d1abcd4.10bc03","name":"button","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"set","p":"endpoint","pt":"msg","to":"button","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":380,"wires":[[]]},{"id":"f15b3597.8713b8","type":"change","z":"d1abcd4.10bc03","name":"light","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"delete","p":"topic","pt":"msg"},{"t":"set","p":"endpoint","pt":"msg","to":"light","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":650,"y":420,"wires":[[]]},{"id":"db7b216c.0f12c","type":"delay","z":"d1abcd4.10bc03","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":480,"y":380,"wires":[["9fd56572.0c0b38","5ff7e2ec.4fce7c"]]},{"id":"5ff7e2ec.4fce7c","type":"delay","z":"d1abcd4.10bc03","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":480,"y":420,"wires":[["f15b3597.8713b8"]]},{"id":"ae3b4275178b1b9a","type":"delay","z":"d1abcd4.10bc03","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":480,"y":180,"wires":[["f0a2d4f4.19a288","244e6655.741d9a"]]},{"id":"aff9cdb5.1ba04","type":"subflow","name":"Scenes Room / Zones","info":"","category":"","in":[{"x":660,"y":340,"wires":[{"id":"d783c4a0.a134f8"},{"id":"b2fff99f.0b7af8"}]}],"out":[{"x":1260,"y":300,"wires":[{"id":"fb43fcd6.f6b8c","port":0}]},{"x":1260,"y":380,"wires":[{"id":"c17682ee.48568","port":0}]}],"env":[],"color":"#DDAA99"},{"id":"b2fff99f.0b7af8","type":"split","z":"aff9cdb5.1ba04","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":840,"y":380,"wires":[["48dc6c9.51e3694"]]},{"id":"48dc6c9.51e3694","type":"switch","z":"aff9cdb5.1ba04","name":"","property":"payload.zone-name","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":990,"y":380,"wires":[["c17682ee.48568"]]},{"id":"c17682ee.48568","type":"join","z":"aff9cdb5.1ba04","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1130,"y":380,"wires":[[]]},{"id":"a1aefb6a.38dee8","type":"switch","z":"aff9cdb5.1ba04","name":"","property":"payload.room-name","propertyType":"msg","rules":[{"t":"nempty"}],"checkall":"true","repair":false,"outputs":1,"x":990,"y":300,"wires":[["fb43fcd6.f6b8c"]]},{"id":"fb43fcd6.f6b8c","type":"join","z":"aff9cdb5.1ba04","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"3","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1130,"y":300,"wires":[[]]},{"id":"d783c4a0.a134f8","type":"split","z":"aff9cdb5.1ba04","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":840,"y":300,"wires":[["a1aefb6a.38dee8"]]},{"id":"4e22b0a547b71127","type":"subflow","name":"HUE Motion Receiver","info":"","category":"HUE v2","in":[{"x":40,"y":440,"wires":[{"id":"b48930eb8130de8c"}]}],"out":[{"x":870,"y":360,"wires":[{"id":"b1fa90333cd3d7c2","port":0}]},{"x":890,"y":440,"wires":[{"id":"b1fa90333cd3d7c2","port":0},{"id":"c3a995dec60ea23a","port":0}]},{"x":870,"y":520,"wires":[{"id":"c3a995dec60ea23a","port":0}]}],"env":[{"name":"motion_ID","type":"str","value":"replace with discovered Motion Sensor ID"}],"meta":{},"color":"#9876D3","outputLabels":["motion true","motion true / false","motion false"],"icon":"node-red/bridge-dash.svg"},{"id":"a53e4a4353ead5c5","type":"switch","z":"4e22b0a547b71127","name":"payload.data.0.motion.motion","property":"payload.data.0.motion.motion","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":450,"y":440,"wires":[["b1fa90333cd3d7c2"],["c3a995dec60ea23a"]]},{"id":"b1fa90333cd3d7c2","type":"change","z":"4e22b0a547b71127","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":400,"wires":[[]]},{"id":"c3a995dec60ea23a","type":"change","z":"4e22b0a547b71127","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":690,"y":480,"wires":[[]]},{"id":"b48930eb8130de8c","type":"switch","z":"4e22b0a547b71127","name":"Motion Sensor ID","property":"payload.data.0.id","propertyType":"msg","rules":[{"t":"cont","v":"motion_ID","vt":"env"}],"checkall":"true","repair":false,"outputs":1,"x":190,"y":440,"wires":[["a53e4a4353ead5c5"]]},{"id":"b16d682909fa8060","type":"comment","z":"4e22b0a547b71127","name":"HUE - Motion Sensor Event Filter \\n \\n Output 1: Will send just an **true** when Motion is detected \\n \\n Output 2: Will send an **true** when Motion is detected and a **false** if no motion is detected any longer. \\n \\n Output 3: Will send just an **false** when no Motion is detected any longer. \\n \\n ----------------------- \\n All outputs are boolean \\n ----------------------- \\n \\n Most easy Subflow, but convinient when lots of sensors need to be set up.","info":"Output 1:\nWill send just an **true** when Motion is detected\n\nOutput 2:\nWill send an **true** when Motion is detected and a **false** if no motion is detected any longer.\n\nOutput 3:\nWill send just an **false** when no Motion is detected any longer.\n\n-----------------------\nAll outputs are boolean\n-----------------------\n\nMost easy Subflow, but convinient when lots of sensors need to be set up.","x":380,"y":180,"wires":[]},{"id":"a481bf787a7fdeab","type":"subflow","name":"HUE Light Receiver","info":"","category":"HUE v2","in":[{"x":40,"y":580,"wires":[{"id":"f3271feba7c9915a"}]}],"out":[{"x":1020,"y":500,"wires":[{"id":"7589246b1e06008f","port":0}]},{"x":1040,"y":580,"wires":[{"id":"7589246b1e06008f","port":0},{"id":"4af07ff82cd530da","port":0}]},{"x":1020,"y":660,"wires":[{"id":"4af07ff82cd530da","port":0}]}],"env":[{"name":"light_ID","type":"str","value":"replace with discovered Lamp / Group ID"}],"meta":{},"color":"#86E3FF","outputLabels":["On","On / Off","Off"],"icon":"node-red/light.svg"},{"id":"8b5bf9aa6165443b","type":"rbe","z":"a481bf787a7fdeab","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":730,"y":500,"wires":[["7589246b1e06008f"]]},{"id":"7589246b1e06008f","type":"switch","z":"a481bf787a7fdeab","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":850,"y":500,"wires":[[]]},{"id":"a7ba6a6bbe78ae39","type":"change","z":"a481bf787a7fdeab","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":460,"wires":[["099f85bc73efff73"]]},{"id":"099f85bc73efff73","type":"delay","z":"a481bf787a7fdeab","name":"2s","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":850,"y":460,"wires":[["8b5bf9aa6165443b"]]},{"id":"a003a94d2ebb1a69","type":"change","z":"a481bf787a7fdeab","name":"True","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":540,"wires":[["8b5bf9aa6165443b"]]},{"id":"b785268eac1e03d1","type":"delay","z":"a481bf787a7fdeab","name":"2s","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":850,"y":700,"wires":[["b836e2a7909c55e9"]]},{"id":"b836e2a7909c55e9","type":"rbe","z":"a481bf787a7fdeab","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":730,"y":660,"wires":[["4af07ff82cd530da"]]},{"id":"598dbd38880b8bb8","type":"change","z":"a481bf787a7fdeab","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":620,"wires":[["b836e2a7909c55e9"]]},{"id":"c3b7a3bc0f18b044","type":"change","z":"a481bf787a7fdeab","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":700,"wires":[["b785268eac1e03d1"]]},{"id":"4af07ff82cd530da","type":"switch","z":"a481bf787a7fdeab","name":"","property":"payload","propertyType":"msg","rules":[{"t":"false"}],"checkall":"true","repair":false,"outputs":1,"x":850,"y":660,"wires":[[]]},{"id":"db4b92b38d2635c5","type":"switch","z":"a481bf787a7fdeab","name":"payload.data.0.on.on","property":"payload.data.0.on.on","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":480,"y":580,"wires":[["a003a94d2ebb1a69","a7ba6a6bbe78ae39"],["598dbd38880b8bb8","c3b7a3bc0f18b044"]]},{"id":"b94463b527fd5453","type":"comment","z":"a481bf787a7fdeab","name":"HUE light / grouped_light Event Filter \\n \\n Output 1: This output will send a **true** when Lights or Groups are turned on. \\n \\n Output 2: This output will send a **true** when Lights or Groups are turned on AND a **false** when Lights or Groups are turned off. \\n \\n Output 3: This output will send a **false** when Lights or Groups are turned off \\n \\n Depending on your Situation it can be useful just to have a **true** OR **false** OR **both** states in your Flow. Thats the reason i built this Subflow. \\n Just use the Output that makes you happy :) \\n \\n ----------------------- \\n All outputs are boolean \\n ----------------------- \\n \\n The delays will reset the RBE nodes. \\n You can adjust the times for your needs, but this worked for me prefectly.","info":"Output 1:\nThis output will send a **true** when Lights or Groups are turned on.\n\nOutput 2:\nThis output will send a **true** when Lights or Groups are turned on AND a **false** when Lights or Groups are turned off.\n\nOutput 3:\nThis output will send a **false** when Lights or Groups are turned off\n\nDepending on your Situation it can be useful just to have a **true** OR **false** OR **both** states in your Flow. Thats the reason i built this Subflow.\nJust use the Output that makes you happy :)\n\n-----------------------\nAll outputs are boolean \n-----------------------\n\nThe delays will reset the RBE nodes.\nYou can adjust the times for your needs, but this worked for me prefectly.","x":510,"y":220,"wires":[]},{"id":"f3271feba7c9915a","type":"switch","z":"a481bf787a7fdeab","name":"light / grouped_light ID","property":"payload.data.0.id","propertyType":"msg","rules":[{"t":"cont","v":"light_ID","vt":"env"}],"checkall":"true","repair":false,"outputs":1,"x":200,"y":580,"wires":[["db4b92b38d2635c5"]]},{"id":"f97d7e51bb5967a2","type":"subflow","name":"HUE Button Receiver","info":"","category":"HUE v2","in":[{"x":40,"y":500,"wires":[{"id":"50e9a6cafc2f5612"}]}],"out":[{"x":1230,"y":240,"wires":[{"id":"7f25389d80fa3cde","port":0}]},{"x":1240,"y":440,"wires":[{"id":"f02e878296414031","port":0}]},{"x":1210,"y":600,"wires":[{"id":"36f17c4928f045ac","port":0}]},{"x":1230,"y":760,"wires":[{"id":"45b938adbb6fe26f","port":0}]}],"env":[{"name":"button_ID","type":"str","value":"replace with discovered button ID","ui":{"type":"input","opts":{"types":["str"]}}}],"meta":{},"color":"#E6E0F8","outputLabels":["initial_press","short_release","repeat","long_release"],"icon":"font-awesome/fa-toggle-on"},{"id":"3c318b2306429e4d","type":"rbe","z":"f97d7e51bb5967a2","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":950,"y":240,"wires":[["7f25389d80fa3cde"]]},{"id":"7f25389d80fa3cde","type":"switch","z":"f97d7e51bb5967a2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":1070,"y":240,"wires":[[]]},{"id":"b6ab7fec2b8dc05e","type":"change","z":"f97d7e51bb5967a2","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":200,"wires":[["a508a630c6fee070"]]},{"id":"a508a630c6fee070","type":"delay","z":"f97d7e51bb5967a2","name":"2s","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":1070,"y":200,"wires":[["3c318b2306429e4d"]]},{"id":"9a81e6607acd41c9","type":"change","z":"f97d7e51bb5967a2","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":280,"wires":[["3c318b2306429e4d"]]},{"id":"22bf2356fe704447","type":"delay","z":"f97d7e51bb5967a2","name":"2s","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":1070,"y":720,"wires":[["3ffa34d7fd3607ee"]]},{"id":"3ffa34d7fd3607ee","type":"rbe","z":"f97d7e51bb5967a2","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":950,"y":760,"wires":[["45b938adbb6fe26f"]]},{"id":"307c3cf1d28c06e2","type":"change","z":"f97d7e51bb5967a2","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":720,"wires":[["22bf2356fe704447"]]},{"id":"2ca41635e1099306","type":"change","z":"f97d7e51bb5967a2","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":800,"wires":[["3ffa34d7fd3607ee"]]},{"id":"45b938adbb6fe26f","type":"switch","z":"f97d7e51bb5967a2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":1070,"y":760,"wires":[[]]},{"id":"e0d3f900fbfb7ee8","type":"switch","z":"f97d7e51bb5967a2","name":"payload.data.0.button.last_event","property":"payload.data.0.button.last_event","propertyType":"msg","rules":[{"t":"cont","v":"initial_press","vt":"str"},{"t":"cont","v":"short_release","vt":"str"},{"t":"cont","v":"repeat","vt":"str"},{"t":"cont","v":"long_release","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":660,"y":500,"wires":[["b6ab7fec2b8dc05e","9a81e6607acd41c9"],["49066fcfb2a909b3","5aa80bc6dd152296"],["36f17c4928f045ac"],["2ca41635e1099306","307c3cf1d28c06e2"]]},{"id":"6337bd151ed3c9d7","type":"rbe","z":"f97d7e51bb5967a2","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","x":950,"y":440,"wires":[["f02e878296414031"]]},{"id":"f02e878296414031","type":"switch","z":"f97d7e51bb5967a2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":1070,"y":440,"wires":[[]]},{"id":"5aa80bc6dd152296","type":"change","z":"f97d7e51bb5967a2","name":"false","rules":[{"t":"set","p":"payload","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":400,"wires":[["aafcb4efbf90626a"]]},{"id":"aafcb4efbf90626a","type":"delay","z":"f97d7e51bb5967a2","name":"2s","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"outputs":1,"x":1070,"y":400,"wires":[["6337bd151ed3c9d7"]]},{"id":"49066fcfb2a909b3","type":"change","z":"f97d7e51bb5967a2","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":480,"wires":[["6337bd151ed3c9d7"]]},{"id":"36f17c4928f045ac","type":"change","z":"f97d7e51bb5967a2","name":"true","rules":[{"t":"set","p":"payload","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":600,"wires":[[]]},{"id":"a67312d8cbdb82c5","type":"comment","z":"f97d7e51bb5967a2","name":"HUE Button Event Filter \\n \\n Output 1: The **initial_press** comes ALWAYS directly after you push the Button. Quickest response possible! \\n \\n Output 2: The **short_release** will just appear after the **initial_press**, when you pushed the Button quick. \\n \\n Output 3: The **repeat** will appear if you hold the button, and will send a message every second until you release it. \\n \\n Output 4: The **long_release** will appear after the **repeat** ENDED! \\n \\n -------------------------------- \\n All outputs are boolean **true** \\n -------------------------------- \\n \\n The delays will reset the RBE node with a false. \\n You can adjust the times for your needs, but this worked for me prefectly.","info":"Output 1:\nThe **initial_press** comes ALWAYS directly after you push the Button. Quickest response possible!\n\nOutput 2:\nThe **short_release** will just appear after the **initial_press**, when you pushed the Button quick.\n\nOutput 3:\nThe **repeat** will appear if you hold the button, and will send a message every second until you release it.\n\nOutput 4:\nThe **long_release** will appear after the **repeat** ENDED!\n\n\n--------------------------------\nAll outputs are boolean **true**\n--------------------------------\n\n\nThe delays will reset the RBE node with a false.\nYou can adjust the times for your needs, but this worked for me prefectly.","x":420,"y":200,"wires":[]},{"id":"50e9a6cafc2f5612","type":"switch","z":"f97d7e51bb5967a2","name":"Button ID","property":"payload.data.0.id","propertyType":"msg","rules":[{"t":"cont","v":"button_ID","vt":"env"}],"checkall":"true","repair":false,"outputs":1,"x":260,"y":500,"wires":[["e0d3f900fbfb7ee8"]]},{"id":"cdb52ede208a8b09","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"d1ee0d98140d128f","type":"group","z":"cdb52ede208a8b09","style":{"stroke":"#999999","stroke-opacity":"1","fill":"none","fill-opacity":"1","label":true,"label-position":"nw","color":"#a4a4a4"},"nodes":["d069a2208617fbcc","61469ee805126ef0","2d25c381c159d18e","7699add772e086a4","0975896def6ca5a0","68229e0adc7203a0","2ed29c5083a6de0b","699c8cdccac11818","2cb049928d07db4a","27d231963f620b19","e99d41d473ac76ea","06a0049fe9ae27f3","4134d5531e112a64","6105f2cba6941617","759a8b36478447b8"],"x":74,"y":667,"w":1352,"h":262},{"id":"590db39b07f5dbc5","type":"link out","z":"cdb52ede208a8b09","name":"EventStream","mode":"link","links":["5ede3dd6bb3c23e0","ad8c0b265ba625b0","cc5833d54f3f3441"],"x":1050,"y":360,"wires":[],"l":true},{"id":"da6fc10e719a6490","type":"debug","z":"cdb52ede208a8b09","name":"HUE monitor","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":830,"y":360,"wires":[]},{"id":"d069a2208617fbcc","type":"link in","z":"cdb52ede208a8b09","d":true,"g":"d1ee0d98140d128f","name":"HUE API INPUT","links":["e47d2651b5f4c0e8","72b7947f5a45067a"],"x":220,"y":820,"wires":[["06a0049fe9ae27f3"]],"l":true},{"id":"61469ee805126ef0","type":"http request","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"HUE API V2","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"4bc31af9bd03bbdc","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":830,"y":820,"wires":[["2cb049928d07db4a"]]},{"id":"2d25c381c159d18e","type":"link out","z":"cdb52ede208a8b09","d":true,"g":"d1ee0d98140d128f","name":"API Response OUT","mode":"link","links":["96ce524ab9b8b274"],"x":1290,"y":840,"wires":[],"l":true},{"id":"7699add772e086a4","type":"function","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"Take snapshot \\n - or - \\n Restore snapshot \\n (retry processing) \\n +set rate max 1/250ms","func":"// Take a copy of payload & headers as they are now to be able to re-use it on retry\nif (msg.retryInfo === undefined) {\n // msg was never processed befor, take a copy (snapshot) of key values to be re-applied in case of retry\n msg.retryInfo = {}\n msg.retryInfo.payload = msg.payload;\n msg.retryInfo.headers = msg.headers;\n msg.retryInfo.retryCount = 0;\n} else {\n // msg was processed at least once before, apply snapshot'd values back\n msg.payload = msg.retryInfo.payload;\n msg.headers = msg.retryInfo.headers;\n msg.statusCode = undefined;\n msg.retryInfo.retryCount++\n}\n\n// Set maximum rate to 1/200ms\nmsg.rate = 200;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":620,"y":840,"wires":[["27d231963f620b19"]],"outputLabels":["Blocked msg to send to repeater"],"icon":"font-awesome/fa-copy"},{"id":"0975896def6ca5a0","type":"delay","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"(0.25s - 0.5s)","pauseType":"random","timeout":"1100","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"250","randomLast":"500","randomUnits":"milliseconds","drop":false,"allowrate":false,"outputs":1,"x":410,"y":860,"wires":[["7699add772e086a4"]]},{"id":"68229e0adc7203a0","type":"debug","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"HUE API error","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1300,"y":880,"wires":[]},{"id":"2ed29c5083a6de0b","type":"link in","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"Retry...","links":["699c8cdccac11818"],"x":285,"y":860,"wires":[["0975896def6ca5a0"]]},{"id":"699c8cdccac11818","type":"link out","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"Try to retry...","mode":"link","links":["2ed29c5083a6de0b"],"x":1195,"y":800,"wires":[]},{"id":"2cb049928d07db4a","type":"switch","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"Catch Error \\n 429+503","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"429","vt":"str"},{"t":"eq","v":"503","vt":"num"},{"t":"regex","v":"2\\d\\d","vt":"str","case":false},{"t":"else"}],"checkall":"true","repair":false,"outputs":4,"x":1030,"y":860,"wires":[["e99d41d473ac76ea"],["e99d41d473ac76ea"],["2d25c381c159d18e"],["2d25c381c159d18e","68229e0adc7203a0"]],"outputLabels":[null,"503 : too many calls sent","2xx : all OK","others (Error)"]},{"id":"6d24f8bee3a4d1b9","type":"comment","z":"cdb52ede208a8b09","name":"Step 1b ","info":"","x":150,"y":360,"wires":[]},{"id":"27d231963f620b19","type":"delay","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"Limit 1msg/s","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":true,"outputs":1,"x":830,"y":860,"wires":[["61469ee805126ef0"]]},{"id":"e99d41d473ac76ea","type":"switch","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"Max 10 retries","property":"retryInfo.retryCount","propertyType":"msg","rules":[{"t":"lt","v":"10","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":1040,"y":800,"wires":[["699c8cdccac11818"],["2d25c381c159d18e","68229e0adc7203a0"]],"outputLabels":["Less than 10 errors, keep retrying...","More than 10 errors, abord retries"]},{"id":"7211efc7853624a7","type":"philipshue-events","z":"cdb52ede208a8b09","bridge":"9201a46f772e1bc2","x":360,"y":360,"wires":[["f8fd9b9a6761a80a"]]},{"id":"5484440aaa139994","type":"subflow:f97d7e51bb5967a2","z":"cdb52ede208a8b09","name":"","env":[{"name":"button_ID","value":"replace with discovered button <<ID>>","type":"str"}],"x":520,"y":2000,"wires":[["3f3c31fa3882e2d9"],["3d7de882beae077d"],["5113e156b0543b3d"],["60388ee13ec84a1b"]]},{"id":"ead630866e18da2a","type":"subflow:a481bf787a7fdeab","z":"cdb52ede208a8b09","name":"","env":[{"name":"light_ID","value":"replace with discovered Lamp ID / Group RID","type":"str"}],"x":510,"y":1520,"wires":[["5db02c2109181a78"],["bc588d2334cbf9a8"],["5fba5f4386a25c77"]]},{"id":"fd7e3712112abde2","type":"subflow:4e22b0a547b71127","z":"cdb52ede208a8b09","name":"","env":[{"name":"motion_ID","value":"replace with discovered Motion Sensor <<ID>>","type":"str"}],"x":510,"y":1760,"wires":[["31a092d91ad63f49"],["a49ea0a69ed35dc2"],["0f76b96aaacce01c"]]},{"id":"3f3c31fa3882e2d9","type":"debug","z":"cdb52ede208a8b09","name":"initial","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":740,"y":1940,"wires":[]},{"id":"3d7de882beae077d","type":"debug","z":"cdb52ede208a8b09","name":"short","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":740,"y":1980,"wires":[]},{"id":"5113e156b0543b3d","type":"debug","z":"cdb52ede208a8b09","name":"holded","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":740,"y":2020,"wires":[]},{"id":"60388ee13ec84a1b","type":"debug","z":"cdb52ede208a8b09","name":"long","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":740,"y":2060,"wires":[]},{"id":"31a092d91ad63f49","type":"debug","z":"cdb52ede208a8b09","name":"motion true","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":760,"y":1720,"wires":[]},{"id":"a49ea0a69ed35dc2","type":"debug","z":"cdb52ede208a8b09","name":"motion true + false","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":780,"y":1760,"wires":[]},{"id":"0f76b96aaacce01c","type":"debug","z":"cdb52ede208a8b09","name":"motion false","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":760,"y":1800,"wires":[]},{"id":"5db02c2109181a78","type":"debug","z":"cdb52ede208a8b09","name":"On (true)","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":1480,"wires":[]},{"id":"bc588d2334cbf9a8","type":"debug","z":"cdb52ede208a8b09","name":"On / Off (true/false)","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":780,"y":1520,"wires":[]},{"id":"5fba5f4386a25c77","type":"debug","z":"cdb52ede208a8b09","name":"Off (false)","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":1560,"wires":[]},{"id":"cc5833d54f3f3441","type":"link in","z":"cdb52ede208a8b09","name":"HUE IN","links":["590db39b07f5dbc5"],"x":340,"y":1760,"wires":[["fd7e3712112abde2"]],"l":true},{"id":"ad8c0b265ba625b0","type":"link in","z":"cdb52ede208a8b09","name":"HUE IN","links":["590db39b07f5dbc5"],"x":340,"y":2000,"wires":[["5484440aaa139994"]],"l":true},{"id":"5ede3dd6bb3c23e0","type":"link in","z":"cdb52ede208a8b09","name":"HUE IN","links":["590db39b07f5dbc5"],"x":340,"y":1520,"wires":[["ead630866e18da2a"]],"l":true},{"id":"f8fd9b9a6761a80a","type":"function","z":"cdb52ede208a8b09","name":"Array Splitter","func":"for (var i = 0; i < msg.payload.data.length; i++) {\n // Create a deep copy of msg object\n let splitmsg = JSON.parse(JSON.stringify(msg));\n\n // Reset data of new message to its single data part\n splitmsg.payload.data = [msg.payload.data[i]];\n \n // send using node\n node.send(splitmsg);\n}\n\nreturn;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":360,"wires":[["590db39b07f5dbc5","da6fc10e719a6490"]]},{"id":"cae7d18de5a1b398","type":"link out","z":"cdb52ede208a8b09","name":"API Response OUT","mode":"link","links":["96ce524ab9b8b274"],"x":1070,"y":540,"wires":[],"l":true},{"id":"96ce524ab9b8b274","type":"link in","z":"cdb52ede208a8b09","name":"BRIDGE DATA RESPONSE IN","links":["cae7d18de5a1b398","3f6d2329.8027ec","29cb5ec00b633749","2d25c381c159d18e"],"x":2245,"y":740,"wires":[["a9212b2af44d2132","b0e5d8e6a428298f","88b8101f056f291d","8f355a66955b7f75","76515ac8b0a39115","fc578914ef989dbb","aff4539644bcbe27"]]},{"id":"a9212b2af44d2132","type":"switch","z":"cdb52ede208a8b09","name":"Room","property":"endpoint","propertyType":"msg","rules":[{"t":"eq","v":"room","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2550,"y":560,"wires":[["1de5803171f53db2","997aa9bbc0752123"]]},{"id":"13bd0cf76dccb987","type":"inject","z":"cdb52ede208a8b09","name":"Scenes Zone (seperately)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"split","payload":"zone_scenes","payloadType":"flow","x":1810,"y":900,"wires":[["ca0c141c11be0501"]]},{"id":"e39b879e0c4f2ad1","type":"change","z":"cdb52ede208a8b09","name":"rooms","rules":[{"t":"set","p":"rooms","pt":"flow","to":"keys","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2890,"y":500,"wires":[[]]},{"id":"b0e5d8e6a428298f","type":"switch","z":"cdb52ede208a8b09","name":"Scene","property":"endpoint","propertyType":"msg","rules":[{"t":"eq","v":"scene","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2550,"y":740,"wires":[["8d788ee3a1e97f55","a64f9743ef9027fd"]]},{"id":"88b8101f056f291d","type":"switch","z":"cdb52ede208a8b09","name":"Light","property":"endpoint","propertyType":"msg","rules":[{"t":"eq","v":"light","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2550,"y":1140,"wires":[["714d986c5213b037"]]},{"id":"8f355a66955b7f75","type":"switch","z":"cdb52ede208a8b09","name":"Zone","property":"endpoint","propertyType":"msg","rules":[{"t":"eq","v":"zone","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2550,"y":400,"wires":[["4e4f9ae30955b068","64c907388118fe79"]]},{"id":"8d788ee3a1e97f55","type":"function","z":"cdb52ede208a8b09","name":"Scene Name, ID, Zone Name","func":"var response = [];\nvar zones = flow.get(\"zones\") || {};\nvar size = Object.keys(zones).length;\nif(size <= 0) {\n node.error(\"Please Update Zones First\");\n}\nmsg.payload.data.forEach(function(item){\n var pair = {\n \"name\": item.metadata.name,\n \"id\": item.id,\n // \"rid\": item.group.rid,\n // \"rtype\": item.group.rtype,\n \"zone-name\": zones[item.group.rid]\n };\n response.push(pair);\n});\nreturn {\n \"payload\": response,\n \"topic\": \"Scene name/rids\"\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2810,"y":700,"wires":[["d3de0263e6fcf49a"]]},{"id":"1976dd2ed1429661","type":"change","z":"cdb52ede208a8b09","name":"zones","rules":[{"t":"set","p":"zones","pt":"flow","to":"keys","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2890,"y":340,"wires":[[]]},{"id":"d3de0263e6fcf49a","type":"subflow:aff9cdb5.1ba04","z":"cdb52ede208a8b09","name":"","env":[],"x":2840,"y":740,"wires":[["e24480e054fd52c5","20832290c36e3a3f"],["d639dece0e44102c","6921a110f947e4c4"]]},{"id":"e24480e054fd52c5","type":"debug","z":"cdb52ede208a8b09","name":"Room Scenes","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3120,"y":700,"wires":[]},{"id":"d639dece0e44102c","type":"debug","z":"cdb52ede208a8b09","name":"Zone Scenes","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3110,"y":780,"wires":[]},{"id":"5c34407bbc96a25a","type":"debug","z":"cdb52ede208a8b09","name":"Rooms","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3100,"y":540,"wires":[]},{"id":"e5ab88e6d6670204","type":"debug","z":"cdb52ede208a8b09","name":"Zones","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3090,"y":380,"wires":[]},{"id":"406f4f822135a8d8","type":"inject","z":"cdb52ede208a8b09","name":"Request all Data","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":1840,"y":200,"wires":[["e0d06ff65f93ed12","5f0446e29ae11d70"]]},{"id":"20832290c36e3a3f","type":"change","z":"cdb52ede208a8b09","name":"room_scenes","rules":[{"t":"set","p":"room_scenes","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2860,"y":660,"wires":[[]]},{"id":"5f0446e29ae11d70","type":"subflow:d1abcd4.10bc03","z":"cdb52ede208a8b09","name":"Request","env":[],"x":2040,"y":200,"wires":[["e47d2651b5f4c0e8"]]},{"id":"6921a110f947e4c4","type":"change","z":"cdb52ede208a8b09","name":"zone scene","rules":[{"t":"set","p":"zone_scenes","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2870,"y":820,"wires":[[]]},{"id":"72098e411c638d51","type":"inject","z":"cdb52ede208a8b09","name":"Scenes Zone (an array)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"array","payload":"zone_scenes","payloadType":"flow","x":1820,"y":860,"wires":[["ca0c141c11be0501"]]},{"id":"581ef2171be857c6","type":"inject","z":"cdb52ede208a8b09","name":"Scenes Room (an array)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"array","payload":"room_scenes","payloadType":"flow","x":1810,"y":620,"wires":[["ca0c141c11be0501"]]},{"id":"a56dc9f9938dc2db","type":"inject","z":"cdb52ede208a8b09","name":"Scenes Room (seperately)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"split","payload":"room_scenes","payloadType":"flow","x":1810,"y":660,"wires":[["ca0c141c11be0501"]]},{"id":"ca0c141c11be0501","type":"subflow:7a14643a.75260c","z":"cdb52ede208a8b09","name":"","env":[],"x":2220,"y":740,"wires":[["d4d6109ad8b6d5e1"]]},{"id":"e0d06ff65f93ed12","type":"change","z":"cdb52ede208a8b09","name":"DELETE","rules":[{"t":"delete","p":"zones","pt":"flow"},{"t":"delete","p":"rooms","pt":"flow"},{"t":"delete","p":"lights","pt":"flow"},{"t":"delete","p":"zone_scenes","pt":"flow"},{"t":"delete","p":"room_scenes","pt":"flow"},{"t":"delete","p":"rooms_array","pt":"flow"},{"t":"delete","p":"zones_array","pt":"flow"},{"t":"delete","p":"devices","pt":"flow"},{"t":"delete","p":"motion","pt":"flow"},{"t":"delete","p":"lights","pt":"flow"},{"t":"delete","p":"button","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":2040,"y":240,"wires":[[]]},{"id":"f7feb3a58ef5670a","type":"inject","z":"cdb52ede208a8b09","d":true,"name":"Delete Data","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":1850,"y":240,"wires":[["e0d06ff65f93ed12"]]},{"id":"a7f8076aa98d020d","type":"change","z":"cdb52ede208a8b09","name":"lights","rules":[{"t":"set","p":"lights","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2890,"y":1100,"wires":[[]]},{"id":"243b549af0f23c07","type":"debug","z":"cdb52ede208a8b09","name":"Lights","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3090,"y":1140,"wires":[]},{"id":"714d986c5213b037","type":"function","z":"cdb52ede208a8b09","name":"Light Name, ID, Abilities","func":"var response = [];\nvar rooms = flow.get(\"rooms\") || {};\nvar size = Object.keys(rooms).length;\nif(size <= 0) {\n node.error(\"Please Update Rooms First\");\n}\nmsg.payload.data.forEach(function(item){\n var pair = {\n \"name\": item.metadata.name,\n \"type\": item.metadata.archetype,\n \"id\": item.id,\n \"color\": item.hasOwnProperty(\"color\") ? true : false,\n \"temp\": item.hasOwnProperty(\"color_temperature\") ? true : false\n };\n response.push(pair);\n});\nreturn {\n \"payload\": response,\n \"topic\": \"Lights\"\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2830,"y":1140,"wires":[["a7f8076aa98d020d","243b549af0f23c07"]]},{"id":"9637a91e664bdb56","type":"inject","z":"cdb52ede208a8b09","name":"Buttons (an Array)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"array","payload":"button","payloadType":"flow","x":1830,"y":1100,"wires":[["ca0c141c11be0501"]]},{"id":"b629ca378138645c","type":"inject","z":"cdb52ede208a8b09","name":"Buttons (seperately)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"split","payload":"button","payloadType":"flow","x":1830,"y":1140,"wires":[["ca0c141c11be0501"]]},{"id":"d949f0d309a4ca0d","type":"inject","z":"cdb52ede208a8b09","name":"Rooms (seperately)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"split","payload":"rooms_array","payloadType":"flow","x":1830,"y":540,"wires":[["ca0c141c11be0501"]]},{"id":"1de5803171f53db2","type":"function","z":"cdb52ede208a8b09","name":"Room Name and ID","func":"var response = [];\nvar roomkeys = {};\nmsg.payload.data.forEach(function(item){\n if(item.services.length > 0) {\n var pair = {\n \"name\": item.metadata.name,\n \"id\": item.id,\n \"rid\": item.services[0].rid,\n \"rtype\": item.services[0].rtype\n };\n roomkeys[item.id] = item.metadata.name;\n response.push(pair);\n }\n});\n\nreturn {\n \"payload\": response,\n \"topic\": \"rooms name/rid\",\n \"keys\": roomkeys\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2840,"y":540,"wires":[["e39b879e0c4f2ad1","5c34407bbc96a25a"]]},{"id":"76515ac8b0a39115","type":"switch","z":"cdb52ede208a8b09","name":"Device","property":"endpoint","propertyType":"msg","rules":[{"t":"eq","v":"device","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2550,"y":900,"wires":[["6dd2419c1eb93676"]]},{"id":"6dd2419c1eb93676","type":"function","z":"cdb52ede208a8b09","name":"Devices Button and Motion","func":"// NOTE: Devices have multipe rtypes in the services\n// This script grabs the first one, so a motion sensor may show\n// up as \"temperature\" as it also does temp. don't worry\n// this script is more to get the name of the devices to help\n// with the button/motion scripts.\nvar response = [];\nvar devices = {};\nmsg.payload.data.forEach(function(item){\n try {\n if(item.metadata.archetype == \"unknown_archetype\") {\n var pair = {\n \"name\": item.metadata.name,\n \"id\": item.id,\n \"rid\": item.services[0].rid,\n \"rtype\": item.services[0].rtype\n };\n devices[item.id] = item.metadata.name;\n response.push(pair);\n }\n } catch(err) {\n node.warn(err);\n }\n});\n\nreturn {\n \"payload\": response,\n \"topic\": \"devices name/rid\",\n \"keys\": devices\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2820,"y":900,"wires":[["be3c7aca7b702cca","880602988be96de2"]]},{"id":"be3c7aca7b702cca","type":"change","z":"cdb52ede208a8b09","name":"devices","rules":[{"t":"set","p":"devices","pt":"flow","to":"keys","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2880,"y":860,"wires":[[]]},{"id":"64c907388118fe79","type":"function","z":"cdb52ede208a8b09","name":"Zone Name and ID","func":"var response = [];\nvar roomkeys = {};\nmsg.payload.data.forEach(function(item){\n if(item.hasOwnProperty(\"services\")) {\n var pair = {\n \"name\": item.metadata.name,\n \"id\": item.id,\n \"rid\": item.services[0].rid,\n \"rtype\": item.services[0].rtype\n };\n roomkeys[item.id] = item.metadata.name;\n response.push(pair);\n }\n});\n\nreturn {\n \"payload\": response,\n \"topic\": \"zones name/rid\",\n \"keys\": roomkeys\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2850,"y":380,"wires":[["1976dd2ed1429661","e5ab88e6d6670204"]]},{"id":"4e4f9ae30955b068","type":"function","z":"cdb52ede208a8b09","name":"Zone Name and ID (array)","func":"var response = [];\nmsg.payload.data.forEach(function(item){\n if(item.services.length > 0) {\n var pair = {\n \"name\": item.metadata.name,\n \"id\": item.id,\n \"rid\": item.services[0].rid,\n \"rtype\": item.services[0].rtype\n };\n response.push(pair);\n }\n});\n\nreturn {\n \"payload\": response,\n \"topic\": \"zones name/rid\",\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2830,"y":420,"wires":[["56920af96c4fc625"]]},{"id":"a64f9743ef9027fd","type":"function","z":"cdb52ede208a8b09","name":"Scene Name, ID, Room Name","func":"var response = [];\nvar rooms = flow.get(\"rooms\") || {};\nvar size = Object.keys(rooms).length;\nif(size <= 0) {\n node.error(\"Please Update Rooms First\");\n}\nmsg.payload.data.forEach(function(item){\n var pair = {\n \"name\": item.metadata.name,\n \"id\": item.id,\n // \"rid\": item.group.rid,\n // \"rtype\": item.group.rtype,\n \"room-name\": rooms[item.group.rid]\n };\n response.push(pair);\n});\nreturn {\n \"payload\": response,\n \"topic\": \"Scene name/rids\"\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2810,"y":780,"wires":[["d3de0263e6fcf49a"]]},{"id":"997aa9bbc0752123","type":"function","z":"cdb52ede208a8b09","name":"Room Name and ID (array)","func":"var response = [];\nmsg.payload.data.forEach(function(item){\n if(item.services.length > 0) {\n var pair = {\n \"name\": item.metadata.name,\n \"id\": item.id,\n \"rid\": item.services[0].rid,\n \"rtype\": item.services[0].rtype\n };\n response.push(pair);\n }\n});\n\nreturn {\n \"payload\": response,\n \"topic\": \"rooms name/rid\",\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2820,"y":580,"wires":[["06d6d05502465087"]]},{"id":"06d6d05502465087","type":"change","z":"cdb52ede208a8b09","name":"rooms_array","rules":[{"t":"set","p":"rooms_array","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2870,"y":620,"wires":[[]]},{"id":"56920af96c4fc625","type":"change","z":"cdb52ede208a8b09","name":"zones_array","rules":[{"t":"set","p":"zones_array","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2870,"y":460,"wires":[[]]},{"id":"6df99a78164a6e87","type":"inject","z":"cdb52ede208a8b09","name":"Rooms (an array)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"array","payload":"rooms_array","payloadType":"flow","x":1840,"y":500,"wires":[["ca0c141c11be0501"]]},{"id":"d4d6109ad8b6d5e1","type":"debug","z":"cdb52ede208a8b09","name":"API V2 DATA","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2230,"y":700,"wires":[]},{"id":"c0041f9422969256","type":"inject","z":"cdb52ede208a8b09","name":"Zones (seperately)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"split","payload":"zones_array","payloadType":"flow","x":1830,"y":780,"wires":[["ca0c141c11be0501"]]},{"id":"cd2acf075685dcd9","type":"inject","z":"cdb52ede208a8b09","name":"Zones (an array)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"array","payload":"zones_array","payloadType":"flow","x":1840,"y":740,"wires":[["ca0c141c11be0501"]]},{"id":"880602988be96de2","type":"debug","z":"cdb52ede208a8b09","name":"Devices","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3100,"y":900,"wires":[]},{"id":"fc578914ef989dbb","type":"switch","z":"cdb52ede208a8b09","name":"Motion","property":"endpoint","propertyType":"msg","rules":[{"t":"eq","v":"motion","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2550,"y":980,"wires":[["9877503c33bc78d1"]]},{"id":"9877503c33bc78d1","type":"function","z":"cdb52ede208a8b09","name":"Motion Name, ID, Device Name","func":"var response = [];\nvar devices = flow.get(\"devices\") || {};\nvar size = Object.keys(devices).length;\nif(size <= 0) {\n node.error(\"Please Update Devices First\");\n}\nmsg.payload.data.forEach(function(item){\n var pair = {\n \"Device\": devices[item.owner.rid],\n \"id\": item.id,\n \"type\": item.type,\n };\n response.push(pair);\n});\nreturn {\n \"payload\": response,\n \"topic\": \"Motion name/rids\"\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2810,"y":980,"wires":[["9f8980c2205fd2f2","fdeb627dd51f3271"]]},{"id":"9f8980c2205fd2f2","type":"debug","z":"cdb52ede208a8b09","name":"Motion","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3090,"y":980,"wires":[]},{"id":"fdeb627dd51f3271","type":"change","z":"cdb52ede208a8b09","name":"motion","rules":[{"t":"set","p":"motion","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2890,"y":940,"wires":[[]]},{"id":"8a0e02a7dbe4f810","type":"inject","z":"cdb52ede208a8b09","name":"Motion Senors (seperately)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"split","payload":"motion","payloadType":"flow","x":1810,"y":1020,"wires":[["ca0c141c11be0501"]]},{"id":"fe761679450afa82","type":"inject","z":"cdb52ede208a8b09","name":"Motion Sensors (an array)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"array","payload":"motion","payloadType":"flow","x":1810,"y":980,"wires":[["ca0c141c11be0501"]]},{"id":"aff4539644bcbe27","type":"switch","z":"cdb52ede208a8b09","name":"Button","property":"endpoint","propertyType":"msg","rules":[{"t":"eq","v":"button","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":2550,"y":1060,"wires":[["cd125ef8092e9381"]]},{"id":"292cb964c12fa5d3","type":"inject","z":"cdb52ede208a8b09","name":"Lights (seperately)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"split","payload":"lights","payloadType":"flow","x":1830,"y":420,"wires":[["ca0c141c11be0501"]]},{"id":"ec5cabedbef2d83b","type":"inject","z":"cdb52ede208a8b09","name":"Lights (an array)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"array","payload":"lights","payloadType":"flow","x":1840,"y":380,"wires":[["ca0c141c11be0501"]]},{"id":"cd125ef8092e9381","type":"function","z":"cdb52ede208a8b09","name":"Button Name, ID, Device Name","func":"var response = [];\nvar devices = flow.get(\"devices\") || {};\nvar size = Object.keys(devices).length;\nif(size <= 0) {\n node.error(\"Please Update Devices First\");\n}\nmsg.payload.data.forEach(function(item){\n var pair = {\n \"Device\": devices[item.owner.rid],\n \"id\": item.id,\n \"type\": item.type,\n };\n response.push(pair);\n});\nreturn {\n \"payload\": response,\n \"topic\": \"Motion name/rids\"\n};","outputs":1,"noerr":0,"initialize":"","finalize":"","x":2810,"y":1060,"wires":[["3b6048fd090f6932","8967de7277a9f7a3"]]},{"id":"3b6048fd090f6932","type":"change","z":"cdb52ede208a8b09","name":"button","rules":[{"t":"set","p":"button","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2890,"y":1020,"wires":[[]]},{"id":"8967de7277a9f7a3","type":"debug","z":"cdb52ede208a8b09","name":"Button","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":3090,"y":1060,"wires":[]},{"id":"022ac90db6208473","type":"comment","z":"cdb52ede208a8b09","name":"Bridge Data","info":"","x":2230,"y":740,"wires":[]},{"id":"0c4b650a40d83af8","type":"comment","z":"cdb52ede208a8b09","name":"DO NOT CHANGE ANYTHING HERE","info":"","x":2210,"y":560,"wires":[]},{"id":"dc76c5e3155bf947","type":"debug","z":"cdb52ede208a8b09","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1050,"y":500,"wires":[]},{"id":"92627b866d04fe48","type":"http request","z":"cdb52ede208a8b09","name":"HUE API V2","method":"use","ret":"obj","paytoqs":"ignore","url":"","tls":"4bc31af9bd03bbdc","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":830,"y":540,"wires":[["dc76c5e3155bf947","cae7d18de5a1b398"]]},{"id":"195fcd6f68760e36","type":"comment","z":"cdb52ede208a8b09","name":"Add your Data here \\n IP and Username","info":"","x":590,"y":480,"wires":[]},{"id":"16b3e93a502c8113","type":"function","z":"cdb52ede208a8b09","name":"HEADER V2","func":"// you can copy the user key from the hue config node out of Huemagic\nvar user = \"kq-V-Pqs6HzSlvW7daMZXxjbU321oN9YJqnD2yfk\";\nvar ip = \"192.168.0.31\"\n\nif(msg.endpoint === undefined)\n msg.url = \"https://\" + ip + \"/clip/v2/resource\";\nelse if(msg.topic === undefined)\n msg.url = \"https://\" + ip + \"/clip/v2/resource/\" + msg.endpoint;\nelse\n msg.url = \"https://\" + ip + \"/clip/v2/resource/\" + msg.endpoint + \"/\" + msg.topic;\n\nmsg.headers = {};\n\nmsg.headers['hue-application-key'] = user;\nmsg.headers['Content-Type'] = 'application/json';\nmsg.headers['Accept'] = 'application/json';\n\nif(msg.payload != undefined)\n msg.headers['ContentLength'] = JSON.stringify(msg.payload).length;\n\nif(msg.verb === undefined)\n msg.method = \"get\";\nelse\n msg.method = msg.verb;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":590,"y":540,"wires":[["92627b866d04fe48"]]},{"id":"e47d2651b5f4c0e8","type":"link out","z":"cdb52ede208a8b09","name":"Discover Out","mode":"link","links":["b28042c8728237db","d069a2208617fbcc"],"x":2145,"y":200,"wires":[]},{"id":"b28042c8728237db","type":"link in","z":"cdb52ede208a8b09","name":"HUE API INPUT","links":["e47d2651b5f4c0e8","72b7947f5a45067a"],"x":340,"y":540,"wires":[["16b3e93a502c8113"]],"l":true},{"id":"06a0049fe9ae27f3","type":"function","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"HEADER V2","func":"// you can copy the user key from the hue config node out of Huemagic\nvar user = \"API USERNAME\";\nvar ip = \"YOUR IP\"\n\nif(msg.endpoint === undefined)\n msg.url = \"https://\" + ip + \"/clip/v2/resource\";\nelse if(msg.topic === undefined)\n msg.url = \"https://\" + ip + \"/clip/v2/resource/\" + msg.endpoint;\nelse\n msg.url = \"https://\" + ip + \"/clip/v2/resource/\" + msg.endpoint + \"/\" + msg.topic;\n\nmsg.headers = {};\n\nmsg.headers['hue-application-key'] = user;\nmsg.headers['Content-Type'] = 'application/json';\nmsg.headers['Accept'] = 'application/json';\n\nif(msg.payload != undefined)\n msg.headers['ContentLength'] = JSON.stringify(msg.payload).length;\n\nif(msg.verb === undefined)\n msg.method = \"get\";\nelse\n msg.method = msg.verb;\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":410,"y":820,"wires":[["7699add772e086a4"]]},{"id":"4134d5531e112a64","type":"comment","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"Add your Data here","info":"","x":410,"y":780,"wires":[]},{"id":"0ce51e8a3aa2f8c1","type":"change","z":"cdb52ede208a8b09","name":"API KEY","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\"devicetype\":\"nodered\",\"generateclientkey\":true}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":580,"y":200,"wires":[["192a50119c584a33"]]},{"id":"ee83ec32fa9d8c6d","type":"inject","z":"cdb52ede208a8b09","name":"Request","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":360,"y":200,"wires":[["0ce51e8a3aa2f8c1"]]},{"id":"d9d193f7b984fac1","type":"debug","z":"cdb52ede208a8b09","name":"API KEY","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1040,"y":200,"wires":[]},{"id":"192a50119c584a33","type":"http request","z":"cdb52ede208a8b09","name":"HUE Bridge IP","method":"POST","ret":"obj","paytoqs":"ignore","url":"https://192.168.0.31/api","tls":"4bc31af9bd03bbdc","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":840,"y":200,"wires":[["d9d193f7b984fac1"]]},{"id":"a292c3dc45d03f57","type":"comment","z":"cdb52ede208a8b09","name":"Add your IP here","info":"","x":840,"y":160,"wires":[]},{"id":"f3241cc0f86d57c2","type":"comment","z":"cdb52ede208a8b09","name":"Request new API KEY (username) \\n !! ADD IP FIRST !! ----------------->>>","info":"","x":360,"y":140,"wires":[]},{"id":"6105f2cba6941617","type":"comment","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"This is a different approach that can be used \\n when the normal one causes connection issues","info":"","x":680,"y":720,"wires":[]},{"id":"42aa6b361cd27c0a","type":"comment","z":"cdb52ede208a8b09","name":"username","info":"","x":1040,"y":160,"wires":[]},{"id":"3fe57c3181e11bc5","type":"comment","z":"cdb52ede208a8b09","name":"Step 1a","info":"","x":150,"y":200,"wires":[]},{"id":"d67369a8f8f20ce8","type":"comment","z":"cdb52ede208a8b09","name":"Step 2","info":"","x":150,"y":540,"wires":[]},{"id":"9b1785070ec26ab1","type":"comment","z":"cdb52ede208a8b09","name":"Step 3","info":"","x":1610,"y":220,"wires":[]},{"id":"4ae3b57b692d0ee3","type":"comment","z":"cdb52ede208a8b09","name":"Step 4","info":"","x":1610,"y":720,"wires":[]},{"id":"759a8b36478447b8","type":"comment","z":"cdb52ede208a8b09","g":"d1ee0d98140d128f","name":"Step 2 \\n alternative","info":"","x":160,"y":760,"wires":[]},{"id":"ab7fa84683b318a2","type":"comment","z":"cdb52ede208a8b09","name":"Configure this Node \\n IP and Username","info":"","x":350,"y":300,"wires":[]},{"id":"483d7a10b080173e","type":"comment","z":"cdb52ede208a8b09","name":"This will request all Data fron the Bridge, \\n just click the Inject node and wait 15 seconds","info":"","x":1930,"y":140,"wires":[]},{"id":"d8a76d40be8fe1a3","type":"comment","z":"cdb52ede208a8b09","name":"After you requested the Data \\n use the Inject Nodes to get ID / RID \\n the Data will apear in the Debug Window","info":"","x":2220,"y":480,"wires":[]},{"id":"68c6afb7b94243cf","type":"comment","z":"cdb52ede208a8b09","name":"To get responses from lamps and rooms \\n add your discovered ID / RID here \\n - for a lamp you need to add the ID \\n - for a room you need to add the RID \\n you need one subflow per lamp or room","info":"","x":490,"y":1420,"wires":[]},{"id":"7ce37e87c6153c56","type":"comment","z":"cdb52ede208a8b09","name":"Step 5","info":"","x":350,"y":1300,"wires":[]},{"id":"1475c31d7d6754b4","type":"comment","z":"cdb52ede208a8b09","name":"To get responses from motion sensors\\n add your discovered ID here \\n for every sensor you need one subflow","info":"","x":490,"y":1680,"wires":[]},{"id":"4de777c0dd480a32","type":"comment","z":"cdb52ede208a8b09","name":"To get responses from buttons \\n add your discovered ID here \\n for every button you need one subflow","info":"","x":490,"y":1920,"wires":[]},{"id":"05789db3bc39a0e8","type":"change","z":"cdb52ede208a8b09","name":"Dimming 10% down / 1s transition","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Replace with your discovered ID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"dynamics\":{\"duration\":1000},\"dimming_delta\":{\"action\":\"down\",\"brightness_delta\":10}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1640,"y":1460,"wires":[["72b7947f5a45067a"]]},{"id":"18b54b76b39246d0","type":"change","z":"cdb52ede208a8b09","name":"Light off / 1s transition","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Replace with your discovered ID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"on\":{\"on\":false},\"dynamics\":{\"duration\":1000}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1680,"y":1540,"wires":[["72b7947f5a45067a"]]},{"id":"89c2ae08f2a02ca4","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1460,"wires":[["05789db3bc39a0e8"]]},{"id":"321e00902a7b9fb6","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1420,"wires":[["5f66fc9b1ac954dc"]]},{"id":"699ce4429d5160e4","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1540,"wires":[["18b54b76b39246d0"]]},{"id":"5f66fc9b1ac954dc","type":"change","z":"cdb52ede208a8b09","name":"Light on / 100% / orange / 1s transition","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Replace with your discovered ID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"on\":{\"on\":true},\"dimming\":{\"brightness\":100},\"dynamics\":{\"duration\":1000},\"color\":{\"xy\":{\"x\":0.6101,\"y\":0.3662}}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1630,"y":1420,"wires":[["72b7947f5a45067a"]]},{"id":"83bdd4b17e548a18","type":"change","z":"cdb52ede208a8b09","name":"Dimming 10% up / 1s transition","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Replace with your discovered ID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"dynamics\":{\"duration\":1000},\"dimming_delta\":{\"action\":\"up\",\"brightness_delta\":10}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1650,"y":1500,"wires":[["72b7947f5a45067a"]]},{"id":"0ad879b9251a7547","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1500,"wires":[["83bdd4b17e548a18"]]},{"id":"1063c583e244da32","type":"change","z":"cdb52ede208a8b09","name":"Light on / 100% / red / alert flashing","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Replace with your discovered ID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"on\":{\"on\":true},\"dimming\":{\"brightness\":100},\"color\":{\"xy\":{\"x\":0.7,\"y\":0.25}},\"alert\":{\"action\":\"breathe\"}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1640,"y":1580,"wires":[["72b7947f5a45067a"]]},{"id":"4d0d3e03020a38e8","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1580,"wires":[["1063c583e244da32"]]},{"id":"421b728f2c9f68d4","type":"change","z":"cdb52ede208a8b09","name":"Light on / 80% / 2s transition / color temp cold 153","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Replace with your discovered ID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"on\":{\"on\":true},\"dimming\":{\"brightness\":80},\"dynamics\":{\"duration\":2000},\"color_temperature\":{\"mirek\":153}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1590,"y":1620,"wires":[["72b7947f5a45067a"]]},{"id":"0a3603deea37addb","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1620,"wires":[["421b728f2c9f68d4"]]},{"id":"b2de473af64fc8c6","type":"change","z":"cdb52ede208a8b09","name":"Light on / 50% / 1s transition / color temp warm 500","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Replace with your discovered ID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"on\":{\"on\":true},\"dimming\":{\"brightness\":50},\"dynamics\":{\"duration\":1000},\"color_temperature\":{\"mirek\":500}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1590,"y":1660,"wires":[["72b7947f5a45067a"]]},{"id":"202db7d3d41b8de3","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1660,"wires":[["b2de473af64fc8c6"]]},{"id":"dea8d76a40ce35ce","type":"comment","z":"cdb52ede208a8b09","name":"lights - DOUBLE CLICK FOR INFO","info":"","x":1360,"y":1380,"wires":[]},{"id":"d3d93b8a348e403d","type":"change","z":"cdb52ede208a8b09","name":"Room or Zone on / 100% / orange / 1s transition","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"grouped_light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"replace with discovered !!!>> RID <<!!!","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"on\":{\"on\":true},\"dimming\":{\"brightness\":100},\"dynamics\":{\"duration\":1000},\"color\":{\"xy\":{\"x\":0.6101,\"y\":0.3662}}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1600,"y":1780,"wires":[["72b7947f5a45067a"]]},{"id":"807905fec79980f6","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1780,"wires":[["d3d93b8a348e403d"]]},{"id":"8ce231e840ba4c7e","type":"comment","z":"cdb52ede208a8b09","name":"grouped_light - DOUBLE CLICK FOR INFO","info":"(Rooms & Zones) can be controlled in almost the samme way as lights. \n\nJust the endpoint in the change node is different and instead of using the ID of a Room / Zone you need to use the discoverd **rid **\n\ngrouped_light is a service (rid) that is connected to the group/zone ID","x":1390,"y":1740,"wires":[]},{"id":"05862cadf8befd2a","type":"change","z":"cdb52ede208a8b09","name":"Motion Sensor DISABLED","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"motion","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Replace with your discovered ID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"enabled\":false}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1670,"y":2120,"wires":[["72b7947f5a45067a"]]},{"id":"b6ee44f744753666","type":"change","z":"cdb52ede208a8b09","name":"Motion Sensor ENABLED","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"motion","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Replace with your discovered ID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"enabled\":true}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1670,"y":2080,"wires":[["72b7947f5a45067a"]]},{"id":"fcc5d8f664f32f1c","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":2120,"wires":[["05862cadf8befd2a"]]},{"id":"f9d8d1b2e66977cc","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":2080,"wires":[["b6ee44f744753666"]]},{"id":"ce27b9bb45326993","type":"link in","z":"cdb52ede208a8b09","name":"Motion Sensor ***Name*** On","links":[],"x":1435,"y":2080,"wires":[["b6ee44f744753666"]]},{"id":"b26bc86c6ed0dc9a","type":"link in","z":"cdb52ede208a8b09","name":"Motion Sensor ***Name*** Off","links":[],"x":1435,"y":2120,"wires":[["05862cadf8befd2a"]]},{"id":"bca7ad9b12239f14","type":"comment","z":"cdb52ede208a8b09","name":"Motion Sensor ENABLED / DISABLED","info":"","x":1370,"y":2040,"wires":[]},{"id":"dddf5b43cb1d1245","type":"change","z":"cdb52ede208a8b09","name":"Recall a Scene","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"scene","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"Replace with your discovered ID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"recall\":{\"action\":\"active\"}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1700,"y":1860,"wires":[["72b7947f5a45067a"]],"icon":"font-awesome/fa-star"},{"id":"a96bb40a291ac610","type":"change","z":"cdb52ede208a8b09","name":"Room or Zone off","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"grouped_light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"replace with discovered !!!>> RID <<!!!","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{\"on\":{\"on\":false}}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"put","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1690,"y":1820,"wires":[["72b7947f5a45067a"]]},{"id":"b079aba23166b6db","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1820,"wires":[["a96bb40a291ac610"]]},{"id":"254c38a21ef28a39","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":1860,"wires":[["dddf5b43cb1d1245"]]},{"id":"c1e7408093fa5306","type":"comment","z":"cdb52ede208a8b09","name":"Recall a Scene - DOUBLE CLICK FOR INFO","info":"I highly recommend to use Scenes to turn on Rooms/Zones. This is just one request to the Bridge and the rest is processed in the bridge. When 4 lights are turned on simultanious, the bridge possible wont be able to handle these requests at once.\n\nIf you have a sestup where it is needed to turn on seperate lights, then add delay nodes i front of the chhange node. \n\nExample: 4 Lights need to be tunes on, \nlight 1 = no delay\nlight 2 = 200ms delay\nlight 3 = 400ms delay\nlight 4 = 600ms delay\n\nwhen turning light off simultanious, this should be done in this way. Better is to turn off Rooms or Zones with one request.","x":1390,"y":1900,"wires":[]},{"id":"139de3c6a5f32efe","type":"change","z":"cdb52ede208a8b09","name":"Get State","rules":[{"t":"set","p":"endpoint","pt":"msg","to":"grouped_light","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"ADD GROUP RID","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"set","p":"verb","pt":"msg","to":"get","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1720,"y":2240,"wires":[["72b7947f5a45067a"]]},{"id":"8942a50fd3ab1bb2","type":"inject","z":"cdb52ede208a8b09","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1280,"y":2240,"wires":[["139de3c6a5f32efe"]]},{"id":"be6d646191483874","type":"comment","z":"cdb52ede208a8b09","name":"Get state of a Group","info":"","x":1310,"y":2200,"wires":[]},{"id":"72b7947f5a45067a","type":"link out","z":"cdb52ede208a8b09","name":"actions out","mode":"link","links":["b28042c8728237db","d069a2208617fbcc"],"x":2065,"y":1840,"wires":[]},{"id":"847281e05e33dbd2","type":"comment","z":"cdb52ede208a8b09","name":"Step 6","info":"","x":1270,"y":1300,"wires":[]},{"id":"048dac528fd23e17","type":"comment","z":"cdb52ede208a8b09","name":"These are pre-configured actions \\n add the ID / RID and try it out \\n with this samples it should be easy \\n to create all the actions you need","info":"","x":1680,"y":1980,"wires":[]},{"id":"2f428c842f16ad8a","type":"comment","z":"cdb52ede208a8b09","name":"----- CONTROLLING -----","info":"","x":1450,"y":1300,"wires":[]},{"id":"531408a557356f4d","type":"comment","z":"cdb52ede208a8b09","name":"----- STATUS UPDATES -----","info":"","x":540,"y":1300,"wires":[]},{"id":"4bc31af9bd03bbdc","type":"tls-config","name":"","cert":"","key":"","ca":"","certname":"","keyname":"","caname":"","servername":"","verifyservercert":false},{"id":"9201a46f772e1bc2","type":"philipshue-events-config","address":"192.168.0.31","applicationkey":"FxL-Wdqi8bjU5H71MMwKvFxigaJhZMdhsTpAMuDb"}]
@FredBlo Forgot to mention: as some users have multiple bridges, i think its more easy to add the data manually to the nodes, instead of setting the data with a Inject/change node. I also removed everthing with a link call, cause some users are not using the most recent NodeRed Version. That would cause a problem when importing.
Hi @andesse
Happy to see you merged it as a new version :-)
I personally prefer having subflows only when they have added value (i.e. used multiple times and managed centrally), and I also like exploiting functionalities of latest versions when they work great, but I understand your point about supporting larger scope than node-red v3+.
Anyway, I just gave you some ideas / things I updated to make it work better for me, you decide how you further want this flow to keep evolving :-)
@FredBlo i am very happy to have someone that helps with some code knowledge. I just really have basic knowledge when it comes to functions, that’s the reason I use often several nodes and subflow them. :)
I hope that the repository is good for some time now.
There is some contrib very popular in Germany, it’s called RedMatic (I was using it as well). I am pretty sure >1000 people use it. It’s a NodeRed Addon that is stuck at v2.x or something, cause the dev disappeared. I switched to a Tinkerboard a while ago just for NodeRed, that’s the reason I removed the link calls.
Greetings Andreas
@FredBlo i just realized that the grouping frame is also a NodeRed 3.x thing? I think I should remove it
@andesse ,
So Tinkerboard does not allow you running node-red v3 ? I am using the docker version of node-red, which enables to keep latest version runnign very easily (and also having multiple versions / dockers running in parallel for test & debug :-P )
About groups, as far as I remember, I always used such. It certainly existed already in 2.0.x (I checked in my flow backups from then) and maybe also in latest 1.x, but less sure about this).
Anyway, the way node-red manages groups is also backward compatible : when importing JSON flow, group nodes will be ignored but all its content will be imported (since there is no JSON imbrication used for these; a group as an ID and is set on a tab (z index), any node is in a tab (z index) and optionally in a group (g index)).
@FredBlo Hi, the Tinkerboard can run all Versions. I think it’s the most decent SBC available, it comes with an emcc. My thoughts were again users running old Versions. The flow should be simple as possible.
When you’re using it that long I trust what you say. I’m using node Red since version 2.?
Very impressed by your knowledge, haha
Andreas
Hue changed the data object on Firmware 1.53.1953188010
This is beta firmware in the moment I’m writing this, but you could also get a problem with the next FW! Turn Auto Update off!
With this flow I am actually not able anymore to get status from light / grouped_light etc.
I try to figure out what happens, even the Id looks strange.
Old, functional firmware
not functional data object, new firmware, big data array
So please don’t Update!