so basic intent here is someone come homes (home previously vacant) and IF sun is below_horizon, once front door is unlocked, find all ights and turn them on.
What has actually been happening is anytime the front door unlocks, the lights come on haha. What am I missing in this flow?
First, I would use the events:state and current state nodes, not the trigger:state nodes… also ditch the enable/disable nodes (you don’t need those with the current state node anyways).
Second, I’d start the automation with the door to unlocked state, then feed that to the day/night check, then from your night time output to a current state node that checks the if previous tracker state was vacant (hopefully using msg.data.old_state.state).
Although, wouldn’t this always be true if you are home anyways? Maybe you need something more like “if the time when state switched to home is <Xminutes to do anything with that”).
The rest seems to be working for you so leave that alone.
Trigger nodes are usually fine. It is kind of a matter of taste between event node and trigger…
So, for the first one, you can keep it (the home detection). However for the garage door, here you cannot use the trigger. Despite being in the middle of your flow, the trigger will be activated if the door is opened even if the home trigger did not take place. That’s is why, when you open the door, the light goes on. It is triggered…
Without changing to much your flow, you can replace the trigger for the garage door with a “wait until” node. With this one, you can wait until an event (here door opened) occurs. You include a timeout of X seconds. So that if you open the garage door 2 hours after being home, the light will not goes on.
I don’t understand either what is the purpose of the switch, enable and disable nodes… What do you want to do with that?
GV
so I added the Enable/Disable nodes because as far as I can tell, whenever the door is unlocked, no matter if day or night, the top portion of the flow has been running in the middle of the day when someone unlocks the front door.
so just to be clear, this should be kicked off when the home switches to occupied (by entering zone) AND IF its nighttime, once front door unlocked, find lights and turn them ON.
I may not be going about it the best way…but essentially, if you we come home AND it’s dark outside, i wanted to have the lights come on at the time the front door is unlocked.
I get it. However, in your screenshot both Enable and Disable are connected to the trigger for the garage.
So, assuming your switch node “Night or Day” is true when it is night (so usually the top connector of the node), then only that what should be connected to the rest.
You have plenty of palettes in NR that can give you this information. For a similar situation, I use node-red-contrib-sun-position. The “within time” node will give you true or false based on time condition (including sun position).
GV
Maybe instead of the trigger node for the door, you can simply use the wait node. Once the door opens, the flow will continue.