Sunset trigger

Hello all,

I’m using node-red to switch on (and off) my gardenlights (who isn’t :)). It works fine.
I’ve hooked up telegram to it and i’m being notified etc. all good.

Thing is; it keeps telling me the lights are on (or off), every five minutes or so. I’ve checked the debuglog, seems that the sun trigger is being triggerd all the time. I guess this has something todo with the elevation of the sun changing?

This is my triggernode;

Is there a way to find (or read) it’s previous state? So I can make a kind of IF statement in Node-Red, making sure it only gets fired on state change; below_horizon -> above_horizon and vice versa?

Thanks for pointing me in the right direction.

I prefer to use SchedEx for my automated lighting.

But it appears what you really need to do is use a trigger node, and scope down the output based on conditions, like based on an attribute, rather than the state. You can try checking the box on your event state node that says Output only on state change. It sounds like right now it is passing the data every time any attribute changes, which occurs about every 5 minutes

1 Like

I’m using a Triggernode in my current setup (1st node in screenshot);

This doesn’t have a checkbox where I can toggle the “Output only on state change” property.
I justed checked and a event node (state_changed) does have this option (2nd node in screenshot)

I’ve justed hooked this up with my telegram to inform me on state changed events for the sun.sun entity to see if this will work. I’ll let you know.
Thanks for the info!

Works perfect! Switching to a state_changed event node and using it’s “Output only on state change” property works exactly the way I need it.


1 Like