Hi guys,
I´m trying to create a function node with a sequenced "IF" clause. The use case is as follows:
- My hue sensor tracks motion
- Msg.payload "true" (boolean) is sent to the function node
- Depending on the part of the day AND the brightness in the room, different scenes should be activated
This is the flow
Thats the content of the debug node "Status Conditions"
And thats the content of my function node "Check Conditions":
msg.debug = {
occupancy: msg.payload,
occupancyType: typeof msg.payload,
Lights_Off: flow.get("Lights_Off"),
Lights_OffType: typeof flow.get("Lights_Off"),
TagModus: global.get("TagModus"),
TagModusType: typeof global.get("TagModus"),
AbendModus: global.get("AbendModus"),
AbendModusType: typeof global.get("AbendModus"),
NachtModus: global.get("NachtModus"),
NachtModusType: typeof global.get("NachtModus"),
Brightness: flow.get("Brightness"),
BrightnessType: typeof flow.get("Brightness")
}
if (((flow.get("Lights_Off")===true))&&
((flow.get("Brightness")<25)))
{
if (global.get("TagModus") === true)
{
if ((flow.get("Brightness")>12))
msg.payload = {"scene":"EStwiUv7q69qKtm"};
return msg;
}
else
{
msg.payload = {"scene":"57KOzEvv0bVYuq9"};
return msg;
}
if (global.get("AbendModus") === true)
{
msg.payload = {"scene":"zTM-LR-NfXhpzWs"};
return msg;
}
else
{
msg.payload = null;
return msg;
}
}
Now what actually SHOULD happen under the circumstances given, is this:
msg.payload = {"scene":"zTM-LR-NfXhpzWs"};
However, what actually DOES happen is this:
msg.payload = {"scene":"57KOzEvv0bVYuq9"};
And now I need your brain power guys to point me where am I going down the wrong path