mrgadget / node-red-contrib-eztimer

A simple-yet-flexible timer/scheduler for node-red
MIT License
13 stars 6 forks source link

on/off timer: wrong payload.state when triggered by info #19

Closed Export33 closed 4 years ago

Export33 commented 4 years ago

hey,

i´ve got another issue when the on/off node is triggered by info. In my example both states are off while night should be on.

Can you have a look at it? cheers again. Export

image

[{"id":"1c5b2df7.a43262","type":"eztimer","z":"f035508.fdbebb","name":"isMorning (6:45)","autoname":"06:45:00 - night","tag":"eztimer","suspended":false,"sendEventsOnSuspend":false,"lat":"51.4995","lon":"7.4717","timerType":"1","startupMessage":false,"ontype":"2","ontimesun":"sunrise","ontimetod":"06:45:00","onproperty":"payload","onvaluetype":"str","onvalue":"Morning","onoffset":"","onrandomoffset":0,"onsuppressrepeats":false,"offtype":"1","offtimesun":"night","offtimetod":"dusk","offduration":"00:01:00","offproperty":"payload","offvaluetype":"num","offvalue":0,"offoffset":"0","offrandomoffset":0,"offsuppressrepeats":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":2600,"y":1400,"wires":[["ebb8220d.b1024"]]},{"id":"6adcc7a6.b3cdd8","type":"eztimer","z":"f035508.fdbebb","name":"isNight","autoname":"night - 06:45:00","tag":"eztimer","suspended":false,"sendEventsOnSuspend":false,"lat":"51.4995","lon":"7.4717","timerType":"1","startupMessage":false,"ontype":"1","ontimesun":"night","ontimetod":"17:00","onproperty":"payload","onvaluetype":"str","onvalue":"Night","onoffset":0,"onrandomoffset":0,"onsuppressrepeats":false,"offtype":"2","offtimesun":"dusk","offtimetod":"06:45:00","offduration":"00:01:00","offproperty":"payload","offvaluetype":"num","offvalue":0,"offoffset":0,"offrandomoffset":0,"offsuppressrepeats":false,"mon":true,"tue":true,"wed":true,"thu":true,"fri":true,"sat":true,"sun":true,"x":2580,"y":1460,"wires":[["d4811025.2103"]]},{"id":"ebb8220d.b1024","type":"debug","z":"f035508.fdbebb","name":"morning","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2920,"y":1400,"wires":[]},{"id":"d4811025.2103","type":"debug","z":"f035508.fdbebb","name":"night","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2910,"y":1460,"wires":[]},{"id":"2988949f.ea970c","type":"inject","z":"f035508.fdbebb","name":"info","topic":"payload","payload":"info","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":2390,"y":1440,"wires":[["1c5b2df7.a43262","6adcc7a6.b3cdd8"]]}]
mrgadget commented 4 years ago

Hey, not sure why I missed this one - sorry about that. This is a lack of clarity (or possibly content) in my instructions!

I can tell by the labels that your nodes were recently deployed. The data in the info object/output is stored when each event is sent. As such, it reflects the state of the timer as far as node instance is concerned. Unfortunately this node doesn't store state across deployments/restarts, so when the node is initialised, it always starts in the off state - which is the behavior that you're seeing.

There is an option in the node that will resolve this - Send previous event on startup (bottom of general info) will do as it suggests, and at the same time it will update the info object, giving you the correct output after a deploy/restart.

Let me know how that works for you.

Export33 commented 4 years ago

Thank´s for clarification. Yes you are right, they were recently deployed. I was wondering about the wrong state because the labels below the node are correct.

I switched to the on/off mode with send previous event on startup recently and it´s working fine.