From 99e10e752f06c841971f2116928489d8ec726965 Mon Sep 17 00:00:00 2001 From: Cornelius Suermann Date: Tue, 22 Jun 2021 21:25:59 +0200 Subject: [PATCH] fix(msg.next): Change to object --- suncron.html | 4 ++-- suncron.js | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/suncron.html b/suncron.html index d3e70a6..8a18e5b 100644 --- a/suncron.html +++ b/suncron.html @@ -1216,7 +1216,7 @@

Sun event outputs

obj
msg.next - string + obj

Details

@@ -1261,7 +1261,7 @@
Example msg.schedule object

Next

- The msg.next attribute contains a string hinting at the next upcoming event, e.g. "sunsetStart @ 21:29" + The msg.next attribute contains the event object of the schedule which is coming up next.

Schedule event outputs

diff --git a/suncron.js b/suncron.js index 2e0fec3..9f47209 100644 --- a/suncron.js +++ b/suncron.js @@ -266,19 +266,22 @@ module.exports = function (RED) { } } - let nextEvent + let next try { nextEvent = findNextEvent(schedule) + console.log('schedule', schedule) + console.log('nextEvent', nextEvent) + next = schedule[nextEvent.eventName] } catch (e) { - nextEvent = e.message + next = null } node.send({ topic, payload: castPayload(payload, payloadType), schedule: formatSchedule(schedule), - next: `${nextEvent.eventName} @ ${nextEvent.eventTime.format('HH:mm')}`, + next, }) }