biddster / node-red-contrib-schedex

Scheduler for node-red which allows you to enter on/off times as 24hr clock (e.g. 01:10) or suncalc events (e.g. goldenHour). It also allows you to offset times and randomise the time within the offset.
22 stars 17 forks source link

Output state at startup, flow and full deploy #23

Closed openSoftMan closed 5 years ago

openSoftMan commented 6 years ago

Greetings and thanks for the node.

Would it be possible to add a node option that outputs the current timer state for: 1) Node red startup. 2) Flow/Full deploy.

OR

Maybe an input message like: msg.payload.state and/or a string like "state"

There's no way to know whether the schedule is on/off; I'd like to update an icon to reflect the current state and not wait for the next change.

Thanks!

younesmaia commented 6 years ago

Hello,

This is REALLY important. It is essential that we know if we should be "ON" or "OFF" when a node is deployed, instead of waiting for the next scheduled event. I believe that passing anything to msg.payload.state is the way to go. The output should then reflect "onState" or "offState" according to what was set programmatically or at the node configuration tab.

A "current timer state on startup" would be great as well, but a explicit message requiring it is even more flexible.

Another option is to implement a "once a minute" output (like BigTimer's). What do you think about that?

I'm looking forward to use Schedex on a project of mine, but that would require one of the features above to be implemented.

Thanks for the great node!

biddster commented 6 years ago

I'm just finishing up #26. That will give you the option to send a payload of info on startup and you'll get the state on the output. I think this is what you want in the first part of the above message?

I'm not against having a brute force mode which keeps sending every minute (or whatever the time period is).

younesmaia commented 6 years ago

Hi,

Yes, but I believe implementing a way to query the current state on demand is also very important. The best way to do this would be passing some argument over msg.payload, in order for the output to present the "info" message, which would contain the current state (on or off), as well as other information (next on/off date, suspended state, etc).

A second output, presenting the current state every minute (or any other configurable period) is probably useful as well.

biddster commented 6 years ago

You can query the current state on demand since 1.1.0.

Just send a msg.payload of info to the input and the output will contain the information you asked for above.

You could use an inject node sending info every minute to the input of schedex.

biddster commented 6 years ago

Here is an example of what is emitted when you send info to schedex's input:

{  
   "topic":"info",
   "payload":{  
      "on":"Mon, 11 Dec 2017 07:21:00 GMT",
      "off":"Sun, 10 Dec 2017 15:56:45 GMT",
      "state":"on"
   },
   "_msgid":"c89ede98.37612"
}

...and when suspended:

{  
   "topic":"info",
   "payload":{  
      "on":"suspended",
      "off":"suspended",
      "state":"suspended"
   },
   "_msgid":"196ddfb.fe6922"
}
biddster commented 5 years ago

Closing as no response for a year.