Closed mweissen closed 2 years ago
You probably just need to wait. The events will be emitted at the time of the sun event. So if you invoke the event at 10am in the morning, dusk will be emitted some hours later. If you enable test mode, hours are turned into minutes so instead of waiting 8 hours you would wait 8 mins. Makes sense?
But is there any way to have it emit the last event again immediately? I store the status in a variable but sometimes it is lost. I'd like to build a regular check whether the status is undefined and then have this node emit the last sun event again to recover it.
This is not the right way to solve this problem. You have an event based system already, you should not need to be polling on timers. Events and state are not the same things. Initialise your state on start up by customising the simple function node example I have provided, then just wait for the event(s) you are interested in to change state. You can store state in Nodered Context or as a retained messages on MQTT.
I have tried the first example without any change, but I get only the warning ""calculating sunevents for lat ..." without any output in the debug node. What could be wrong?