Stopping Sequence an hour before sunset

I am new to Node-Red, like hours new.

I was able to setup a sequence to turn on my lights if the weather is bad, someone is home, and it was after 14:00 and before sunset.

My lights turn on at sunset with 1 light coming on 45 mins earlier.

I created a second flow that turns off the lights if the bad weather ends. I would like to put a check in place that if it's 1 hour before sunset the lights should just stay on. I haven't been able to figure this one out.

I've tried BigTimer and Sun Position but they both require a start and end times. I just need is it more than 1 hour before sunset? Yes - Turn off the lights. No - Leave them on.

Would I just use a start time of 14:00 and an end time of Sunset (with -60 min offset)?

You can try the Openweathermap node, this will give the sunset and sunrise time as timestamp.
Then it's easy to substract the 1 hour and do your thing.

Try the time-range switch node. It works with offsets if you want.

What is the problem with the start and end times?

Just add a within-time-switch node of the node-red-contrib-sun-position node collection with a start at 14:00 and a end 1 hour before sunset (set offset to -60 minutes or -1 hour - offset can be negative or positive). Then do switch the light of on the first output of the node and let the second output open.

This is what I ended up using. Luckily for me it snowed the day atfer I posted my question and it worked!

1 Like