freakent / node-red-contrib-sunevents

A node for node-red that generates events based on the position of the Sun at the appropriate time of day.
Apache License 2.0
15 stars 14 forks source link

No output, only the warning. #33

Closed mweissen closed 2 years ago

mweissen commented 2 years ago

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?

freakent commented 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?

YorVeX commented 2 years ago

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.

freakent commented 2 years ago

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.