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 13 forks source link

How to emit current sun event #26

Closed Onixarts closed 3 years ago

Onixarts commented 3 years ago

Hi, I'm not sure but I think the v2 has emited the current sun event after deploy. V3 does not doing that. Is there any possibility to achieve this behaviour again? I'm using this node for my weather dashboard and after deploy it does not receive the current (previous) sun event, so it can't set up dashboard visualisation correctly.

freakent commented 3 years ago

No, previous versions did not do that and I’m not planning to add it to a future version. To do so would be mixing events with states. It sounds like you are using sunevents to change the state of your dashboard. What is your logic for setting the current state? How does knowing the previous event help you determine current state? When I used this node to set my house lights I persisted my “lights on” state so that in the event of a restart it would initialise the state based on the previously persisted state. On the dusk sunevent I changed to the state to “lights on”. If I did a restart and brought the system back up at some point later then knowing that the last event was “sunset end” for example wouldn’t be very useful. I’d have to code logic for every state and if the states ever changed then my logic would break. There is probably a much better way to solve your problem. Outputting the last event is nothing more than a hack.

Onixarts commented 3 years ago

I'm using mqtt retain messages for holding the current state. The problem was the output message structure has change in v3 which broke my flow.

freakent commented 3 years ago

Good that you are using retained messages in MQTT. Sorry it broke your flow, but the documentation does make it clear you will need to update your flow.

Onixarts commented 3 years ago

Yes, but who reads the docs when there is only an update button in node-red :)