mrgadget / node-red-contrib-eztimer

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

Event times - request feature #30

Closed Fires04 closed 4 years ago

Fires04 commented 4 years ago

Hi, I search everywhere but I can't find an answer. It is possible to somehow emit also a time of events for example msg.times? That same time what is under node if it running ( ON until xxxxx ). It would be nice to have the opportunity to save this time for example for the countdown to the next sunrise etc..

Thanks for your nice work

mrgadget commented 4 years ago

Hey - thanks. Would info work for you?

If you send the node a message with msg.payload set to info (string), it will emit a message detailing it's current setup/state - eg;

{
  "name": "eztimer",
  "state": "off",
  "on": {
    "property": "msg.payload",
    "value": "on_test",
    "nextEvent": "Wed Apr 22 2020 06:45:23 GMT+1200 (New Zealand Standard Time)"
  },
  "off": {
    "property": "msg.payload",
    "value": "off_test",
    "nextEvent": "Wed Apr 22 2020 18:34:17 GMT+1200 (New Zealand Standard Time)"
  }
}

That give you what you need?

Fires04 commented 4 years ago

Almost yes.. But it will be good if you could parse this info with an event output value without request.

út 21. 4. 2020 v 13:19 odesílatel Ben Nuttall notifications@github.com napsal:

Hey - thanks. Would info work for you?

If you send the node a message with msg.payload set to info (string), it will emit a message detailing it's current setup/state - eg;

{ "name": "eztimer", "state": "off", "on": { "property": "msg.payload", "value": "on_test", "nextEvent": "Wed Apr 22 2020 06:45:23 GMT+1200 (New Zealand Standard Time)" }, "off": { "property": "msg.payload", "value": "off_test", "nextEvent": "Wed Apr 22 2020 18:34:17 GMT+1200 (New Zealand Standard Time)" } }

That give you what you need?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mrgadget/node-red-contrib-eztimer/issues/30#issuecomment-617116076, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAFKWTXQRPCWUKORCG6ZUJTRNV6LRANCNFSM4MNGUTDQ .

mrgadget commented 4 years ago

Right, so how about we just emit the contents of info with every output (outside the payload) eg;

msg = {
    "info": { },
    "tag": "eztimer",
    "payload": { }
}

Or maybe just do this as an option? I don't want to clutter the UI with too many options though...

Thoughts?

mrgadget commented 4 years ago

@Fires04 - can you replace the index.js with the one from my latest commit and tell me if it works for you? I think it will... Thanks!

Fires04 commented 4 years ago

Hi, nice work it works like charm. Just some little tweaks but it work flawlessly. Maybe you can send times in the current time zone (not as ISO8601 2020-04-27T03:10:19.846Z) as info under the node. But it is just a little conversion that needs to be done in flow. So thank you very much.

mrgadget commented 4 years ago

No problem - I don't actually send as UTC, I just send as-is.

It seems to be how Node-Red decides to display it (in debug) - might be related to issue #29?

For me, if I do a .getTime() on the on.nextEvent output, it returns the right number of seconds for the local date, and if I do a .toString(), it shows the string representation in local format too - is this how it behaves for you?

Fires04 commented 4 years ago

You right. I think the datetime object is right way. Good work man.

mrgadget commented 4 years ago

You've got a working version - I'm just going to close this and push a version to NPM at a later date (when I have some more critical fixes or features).