How to trigger node injecting specific date

Hi all, I have NodeRed connected with Home Assistant.

I would like to trigger an action (set_cover_position to specific value) 30 minutes before the sun rises.

I was thinking in getting this value from "sun.sun" entity:
data.event.new_state.attributes.next_rising

And triggering the set_cover_position service if current dates matches that with an offset of 30 minutes, but I really don’t know how to put the pieces together to implement this flow.

Anyone can guide me in the correct direction? Thanks a lot!

one way is to have one trigger that is for the date
and the other which is the sunrise use a join node. when the join gets both messages a message gets passed

or use something like the node-red-node-timeswitch node that will inject a 0 or 1 depending if between the hours you set (including sunrise with an offset). Then an RBE node to ensure you only get one transition (from 0 to 1 and 1 to 0)...

Or use the schedex node:

schedex-sunrise

[{"id":"d9e2660b.bfbab8","type":"schedex","z":"7c6a9ec3.f1512","name":"","suspended":false,"lat":"51","lon":"-1.5","ontime":"sunrise","ontopic":"","onpayload":"on","onoffset":"-30","onrandomoffset":0,"offtime":"","offtopic":"","offpayload":"","offoffset":0,"offrandomoffset":0,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":210,"y":700,"wires":[["50390619.ee4298"]]},{"id":"50390619.ee4298","type":"debug","z":"7c6a9ec3.f1512","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":390,"y":700,"wires":[]}]
1 Like

That is exactly the solution I was looking for, except for I wanted to base my automation on "sun.sun" entity from Home Assistant (not sure where is schedex getting the sun rising/setting data by latitude/longitude from).

But will use your solution as it's very easy to implement, thanks a lot.

From Suncalc (almost all NR nodes use Suncalc)

1 Like