niklaswall / node-red-contrib-light-scheduler

Light Scheduler is a node-red node that provides a weekly schedule mainly focused on controlling light in home automation scenarios.
Apache License 2.0
41 stars 15 forks source link

Problem with when-state-changes? #16

Closed michaelblight closed 5 years ago

michaelblight commented 6 years ago

If I deploy a node that comes ON at 9:00 and goes OFF at 9:15 and I deploy it at 8:50 then it is logically in the OFF state. If I select "when state changes + startup", I would expect an OFF message immediately. However, if I select only "when state changes", I would expect an ON message at 9:00. However, about a minute after I deploy, I am getting an OFF message - presumably because the state is changing from 'null' to OFF. Or am I doing it wrong?

niklaswall commented 5 years ago

If I deploy a node that comes ON at 9:00 and goes OFF at 9:15 and I deploy it at 8:50 then it is logically in the OFF state. If I select "when state changes + startup", I would expect an OFF message immediately.

Yes, you are right that should be the case.

However, if I select only "when state changes", I would expect an ON message at 9:00. However, about a minute after I deploy, I am getting an OFF message - presumably because the state is changing from 'null' to OFF. Or am I doing it wrong?

The evaluation is done on a minutely basis, so when a minute has passed and there is no previous state (null as you mention) the output will change... however, this does not happen on deploy, it only happens when node-red starts up and when a new light scheduler node is dropped in a flow.

I have solved this and it will be available shortly.

/Niklas