node-red-contrib-suncron
Advanced tools
Comparing version 1.3.3 to 1.4.0
{ | ||
"name": "node-red-contrib-suncron", | ||
"version": "1.3.3", | ||
"version": "1.4.0", | ||
"description": "A Node-RED node that triggers configurable outgoing messages based on the position of the sun", | ||
@@ -33,10 +33,10 @@ "main": "index.js", | ||
"dependencies": { | ||
"cron": "^1.7.2", | ||
"dayjs": "^1.8.17", | ||
"cron": "^1.8.2", | ||
"dayjs": "^1.8.27", | ||
"suncalc": "^1.8.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^6.6.0", | ||
"mocha": "^6.2.2", | ||
"node-red": "^1.0.2", | ||
"eslint": "^7.0.0", | ||
"mocha": "^7.1.2", | ||
"node-red": "^1.0.6", | ||
"node-red-node-test-helper": "^0.2.3" | ||
@@ -43,0 +43,0 @@ }, |
@@ -53,4 +53,6 @@ # SunCron | ||
The node will eject messages at the specified times (respecting offsets), which will have a `msg.payload` and `msg.topic` as configured in the editor. Outgoing messages also have a `schedule` attribute containing an object with details about the schedule of the current date. The schedule contains only events which have been configured with a payload. | ||
### Sun events | ||
The node will emit messages at the specified sun events (respecting offsets), which will have a `msg.payload` and `msg.topic` as configured in the editor. Those messages also have a `schedule` attribute containing an object with details about the schedule of the current date. The schedule contains only events which have been configured with a payload. | ||
Each event has the following attributes: | ||
@@ -63,3 +65,3 @@ | ||
### Example `msg.schedule` object | ||
#### Example `msg.schedule` object | ||
@@ -90,4 +92,8 @@ ```javascript | ||
### Schedule events | ||
If the checkbox "Emit schedule when updated" is ticked, the node will emit additional messages whenever the schedule gets updated. This happens on startup, when offsets are overridden at runtime, and shortly after midnight. Those messages will contain the schedule object as `msg.payload` (same structure as above) and the string "suncron:schedule" as `msg.topic`. | ||
## Contributions and Suggestions | ||
... are always welcome! Just file a GitHub [issue](https://github.com/csuermann/node-red-contrib-suncron/issues) or [pull request](https://github.com/csuermann/node-red-contrib-suncron/pulls)! |
@@ -47,2 +47,5 @@ const CronJob = require('cron').CronJob | ||
installMsgCronjobs(schedule) | ||
setTimeout(() => { | ||
ejectSchedule(schedule) | ||
}, 500) | ||
debug(schedule) | ||
@@ -171,2 +174,3 @@ | ||
installMsgCronjobs(schedule) | ||
ejectSchedule(schedule) | ||
setNodeStatusToNextEvent(schedule) | ||
@@ -266,2 +270,12 @@ }, | ||
const ejectSchedule = function (schedule) { | ||
if (!config.ejectScheduleOnUpdate) { | ||
return | ||
} | ||
node.send({ | ||
topic: 'suncron:schedule', | ||
payload: formatSchedule(schedule), | ||
}) | ||
} | ||
node.on('input', function (msg, send, done) { | ||
@@ -268,0 +282,0 @@ send = |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
215242
409
97
Updatedcron@^1.8.2
Updateddayjs@^1.8.27