Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
node-red-contrib-eztimer
Advanced tools
Timer/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.
Forked from (retaining much of the code, including this document) schedex which was in turn inspired by Pete Scargill's BigTimer, so hat-tip to both those coders.
Emphasis has been put on creating a simple interface and utilising built-in Node-RED formatting helpers (such as creating a JSON payload).
Use the built-in Node-Red Palette Manager to find and install.
In the CLI on your Node-Red box;
cd ~/.node-red
npm install node-red-contrib-eztimer
This isn't for most people - but I've thrown this in so I don't need to keep explaining it in GitHub issues. This assumes you have a default install of Node-RED.
cd ~
wget https://raw.githubusercontent.com/mrgadget/node-red-contrib-eztimer/develop/index.js
wget https://raw.githubusercontent.com/mrgadget/node-red-contrib-eztimer/develop/index.html
cd ~/.node-red/node_modules/node-red-contrib-eztimer
mv index.js index.js.bak
mv index.html index.html.bak
cp ~/index.js .
cp ~/index.html .
You will need to restart Node-RED for the change to take effect. You can put back your old version at any time simply by copying the backup back over top.
The scheduling days allow you to choose which days of the week to schedule events. Unticking all days will suspend scheduling.
The Suspend Scheduling checkbox allows you to disable time scheduling. If scheduling is suspended, eztimer will only
generate output events upon receipt of input on
and off
events (see below).
This setting is provided for the situation where you temporarily don't want time based activation and don't want to rewire your Node-RED flow.
Select the type of trigger from the dropdown and this will provide either;
off
event).The below table denotes the permitted formats for Times/durations:
input | interpretation |
---|---|
"12:14" | 12 hours and 14 minutes |
"12:14:24" | Time of day, or 12 hours, 14 minutes and 24 seconds |
"23h 5m" | 23 hours and 5 minutes |
"5m" | 5 minutes |
"90s" | 1 minute and 30 seconds (90 seconds) |
300 | 5 minutes (300 seconds) - integers are interpreted as seconds |
These are valid both at UI/config-time and at runtime using payload input.
The on and off time can have an offset. This is specified in minutes:
-60
, a message will be generated 60 minutes
before dusk.Both on
and off
times can be randomised by ticking "Use random time within offset period". For example, if you specify
dusk with an offset of -60 minutes, every day a message will be generated at a random time in a 60 minute window before
dusk.
In some circumstances it may be required to re-start the timer without re-sending the on
event - this setting achieves
this. It's available for both on
and off
events, but disabled in trigger
mode.
You can wire inject nodes to the input of this node and send the following string values in msg.payload
.
msg.payload | Description |
---|---|
trigger | Causes eztimer to emit the configured trigger event. |
on | Triggers manual on mode and causes eztimer to emit the configured on event. Manual mode is reset when the next on or off time is reached |
off | Triggers manual off mode and causes eztimer to emit the configured off event. Manual mode is reset when the next on or off time is reached |
info | Eztimer emits an object containing the on and off (or trigger ) times in UTC format. It also contains the state which is either on or off (for on/off type). |
cancel | Cancels the current run (if any) of the timer (without emitting an off event). |
sync | Re-sends the last emitted event |
This node supports programmatic time control as well as configuration via the NodeRED UI.
It is very important to note that properties set programmatically in this manner are transient. They will not persist over a Node-RED restart or redeploy!
Note that both the property-based and string-based specifications are overrides that violate the usual behavior. See here for further discussion https://github.com/node-red/node-red/issues/399.
You can set the following:
Property | Type |
---|---|
msg.payload.action | Accepts the standard input payloads of trigger , on , off , etc. |
msg.payload.suspended | Boolean: true will suspend scheduling, false will resume scheduling |
msg.payload.manual | Alias of suspended |
msg.payload.tag | String value emitted as the tag for all events |
msg.payload.ontype | Integer value: Sun Event [1] & Time of Day [2] |
msg.payload.ontime | String value representing time of day (HH:mm[:ss]) |
msg.payload.triggertime | Alias of ontime |
msg.payload.ontopic | String value emitted as the topic for the on event |
msg.payload.onvalue | Output value for on event (must be same as configured type) |
msg.payload.triggervalue | Alias of onvalue |
msg.payload.onoffset | Number value as specified above for Offset configuration |
msg.payload.onrandomoffset | Boolean value as specified above in Randomisation of Times |
msg.payload.offtype | Integer value: Sun Event [1] , Time of Day [2] & Duration [3] |
msg.payload.offtime | String value representing time of day (HH:mm[:ss]) |
msg.payload.duration | String value representing a timespan (see Times) |
msg.payload.offtopic | String value emitted as the topic for the off event |
msg.payload.offvalue | Output value for off event (must be same as configured type) |
msg.payload.offoffset | Number value as specified above for Offset configuration |
msg.payload.offrandomoffset | Boolean value as specified above in Randomisation of Times |
msg.payload.mon | Boolean: true enables the schedule on a Monday, false disables it. |
msg.payload.tue | Boolean: true enables the schedule on a Tuesday, false disables it. |
msg.payload.wed | Boolean: true enables the schedule on a Wednesday, false disables it. |
msg.payload.thu | Boolean: true enables the schedule on a Thursday, false disables it. |
msg.payload.fri | Boolean: true enables the schedule on a Friday, false disables it. |
msg.payload.sat | Boolean: true enables the schedule on a Saturday, false disables it. |
msg.payload.sun | Boolean: true enables the schedule on a Sunday, false disables it. |
cancel
action so that it correctly cancels the current timer run, and re-schedules the next on
event. credit @wokkeltje13resend
feature. Enabling this causese the last scheduled event to be re-emitted at the pre-defined interval. credit @JasonSwindleaction
in programmatic control - this enablings the sending of on/off events from a JSON input. credit @petter-bofftype
and ontype
programmables. Used for dynamically changing the event type - these changes are not saved (ie, they won't survive a Node-RED restart), and input is not validated, so use with caution. Required integer values are in the Programmatic Control table. credit @matt6575manual
as an alias for suspended
as it makes more sense with how some users use the node. credit @matt6575info
to be sent with every output (under the msg.info
). credit @Fires04.nextEvent
property info
to be Date object (rather than a string) - enabling easier programmatic usage (for example .getDate()
for unix timestamp). This can be turned back in to a string if required using the .toString()
method. This property may still be a string however, for example, if it is suspended
or manual
.null
or undefined
msg.payload is sent to the node.number
output - added parseFloat()
to ensure output is a number (rather than a string representation of a number). credit @bemmbix.scheduling suspended
node status text.flow
and global
context values (node wouldn't pick them up as values previously)flow
and global
context values to store correct type. credit @LorenzKahl.Input Trigger
off-type to Manual
to align with the on-type of the same name.Manual
off time. credit @moryoav.cancel
to actually work - the node no longer emits the off
event after a cancel
call. credit @svwhisper.flow
and global
contexts as assignment properties. When selected, these do not emit flow message. credit @LorenzKahl.Fixes driven by issue #21 credit @jazzgil.
ontopic
or offtopic
) - not previously sent.tag
value programmatically.info
message (displaying on
and off
values) credit @Export33.info
output be more informative and logical. Fixed issue where info
wouldn't work for trigger
timer type. credit @marc-gist.timestamp
value type (previously emitted a blank value) so it outputs milliseconds since epoch - the same as the built-in input node. credit @marc-gist.A few changes in this one - have had it running in test for a month or two and believe it to be stable - as always, log any bugs at github issues and I'll tend to them as soon as possible.
on
event has been sent, repeatedly sending on
inputs won't resend the on
event (but it will restart the timer)cancel
as input command (to cancel any existing timer run without emitting off
event).tag
config parameter. This value is emitted with all events to allow easy identification of specific eztimer node the message was emitted from. Defaults to eztimer
.off
event would schedule on the next available day (causing an abnormally long runtime).nadir
to ordered sun event arraynight
was chosen, but doesn't exist, nauticalDusk
would be used. A warning is emitted each time an event is scheduled for a sun event different to that selected in the config. - credit @B0F1B0.on
event (with a duration-based off
event) wasn't scheduling it's off
event.payload.duration
to allow prgrammatic adjustment of the duration.duration
to 00:01:00 (1 minute) - was 0, which broke the node.off
event.info
output payload.info
output. If no name is set, eztimer
is returned.Thanks to @stu-carter for detailed reports enabling the above fixes (related issue).
manual
variable being used before declaration - credit @marc-gist.onvalue
and offvalue
are more correct, as it's not necessarily the payload you're updating.triggervalue
as an alias to onvalue
.trigger
, configured off by default. Caution required due to this being on by default for exisitng nodes.ontime
and offtime
inputs, added triggertime
as an alias of ontime
.FAQs
A simple-yet-flexible timer/scheduler for node-red
We found that node-red-contrib-eztimer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.