Socket
Socket
Sign inDemoInstall

node-red-contrib-schedex

Package Overview
Dependencies
3
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

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.


Version published
Maintainers
1
Weekly downloads
288
increased by26.32%

Weekly downloads

Readme

Source

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.

Inspired by Pete Scargill's BigTimer

NOTE: When upgrading from versions prior to 1.0.0, you will see a message for each Schedex node in the Node-RED debug window. This message is to advise that the Schedex configuration changed slightly in version 1.0.0 in order to accomodate days of the week when scheduling. To remedy, simply edit each Schedex node, tick the days of the week you want Schedex enabled and re-deploy.

Installation

This node requires node 10.x+. It's tested against 10.22.0.

$ cd ~/.node-red
$ npm install node-red-contrib-schedex

Configuration

Schedule

The scheduling days allow you to choose which days of the week to schedule events. Unticking all days will suspend scheduling.

Suspending scheduling

The 'Suspend scheduling' checkbox allows you to disable time scheduling. If scheduling is suspended, Schedex 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.

Note that scheduling is suspended if you do not enter an on or off time in the node configuration.

Times

Note that on and off times are independent. You only need to configure one or the other or both. You can leave the on or off time field blank in the node configuration and no output will be emitted.

The times can be a 24 hour time or a suncalc event:

TimeDescription
00:00 ... 23:5924hr time
sunrisesunrise (top edge of the sun appears on the horizon)
sunriseEndsunrise ends (bottom edge of the sun touches the horizon)
goldenHourEndmorning golden hour (soft light, best time for photography) ends
solarNoonsolar noon (sun is in the highest position)
goldenHourevening golden hour starts
sunsetStartsunset starts (bottom edge of the sun touches the horizon)
sunsetsunset (sun disappears below the horizon, evening civil twilight starts)
duskdusk (evening nautical twilight starts)
nauticalDusknautical dusk (evening astronomical twilight starts)
nightnight starts (dark enough for astronomical observations)
nadirnadir (darkest moment of the night, sun is in the lowest position)
nightEndnight ends (morning astronomical twilight starts)
nauticalDawnnautical dawn (morning nautical twilight starts)
dawndawn (morning nautical twilight ends, morning civil twilight starts)

Offsets

The on and off time can have an offset. This is specified in minutes:

  • -ve number brings the time forward. E.g. if the time is dusk and offset is -60, a message will be generated 60 minutes before dusk.
  • +ve number delays the time by the specified number of minutes

Randomisation of times

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.

Message passthrough

When Passthrough unhandled messages is enabled, any message that isn't explicitly handled by Schedex will be immediately emitted. To clarify, if the input payload does not match any one of the programmatic options above, along with the on|off|toggle|info|info_local commands, the message will be sent to output.

With Passthough unhandled messagesdisabled (the default), any message that isn't handled by Schedex will be dropped and an error reported.

Inputs

You can wire inject nodes to the input of this node and send the following in msg.payload.

msg.payloadDescription
onTriggers manual on mode and causes Schedex to emit the configured on event. Manual mode is reset when the next on or off time is reached
offTriggers manual off mode and causes Schedex to emit the configured off event. Manual mode is reset when the next on or off time is reached
toggleTriggers either the manual on or manual off mode. If the last event was the on event, toggle will cause schedex to emit the off event and vice versa. State is not maintained over restarts and deploys. Schedex assumes off upon start so the first toggle will emit the on event.
infoSchedex emits an object containing the on and off times in UTC format. It also contains the state which is either on or off along with the rest of this node's configuration. Note that the output message contains the actuated state. This will be null (if an event hasn't happened yet) or 'on' or 'off'.
info_localEmits the information exactly the same as the info command but with the on and off times in local ISO format.
send_stateCauses Schedex to emit the current state as a message with either the on or off topic/payload set. If Schedex is suspended, this command emits nothing.

Programmatic Control

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 NodeRED 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:

PropertyType
msg.payload.suspendedBoolean: true will suspend scheduling, false will resume scheduling
msg.payload.ontimeString value as specified in the table above for time configuration
msg.payload.ontopicString value emitted as the topic for the on event
msg.payload.onpayloadString value emitted as the payload for the on event
msg.payload.onoffsetNumber value as specified above for Offset configuration
msg.payload.onrandomoffsetBoolean value as specified above in Randomisation of Times
msg.payload.offtimeString value as specified in the table above for time configuration
msg.payload.offtopicString value emitted as the topic for the off event
msg.payload.offpayloadString value emitted as the payload for the off event
msg.payload.offoffsetNumber value as specified above for Offset configuration
msg.payload.offrandomoffsetBoolean value as specified above in Randomisation of Times
msg.payload.monBoolean: true enables the schedule on a Monday, false disables it.
msg.payload.tueBoolean: true enables the schedule on a Tuesday, false disables it.
msg.payload.wedBoolean: true enables the schedule on a Wednesday, false disables it.
msg.payload.thuBoolean: true enables the schedule on a Thursday, false disables it.
msg.payload.friBoolean: true enables the schedule on a Friday, false disables it.
msg.payload.satBoolean: true enables the schedule on a Saturday, false disables it.
msg.payload.sunBoolean: true enables the schedule on a Sunday, false disables it.
msg.payload.passthroughunhandledBoolean: true enables unhandled input messages to automatically be sent to output.

Alternatively, you can send msg.payload as a string with the following values:

Example msg.payloadDescription
suspended truetrue will suspend scheduling, false will resume scheduling
ontime 12:00Time as specified in the table above for time configuration
ontopic my_topicSets the topic for the on event (no spaces)
onpayload my_payloadSets the payload for the on event (no spaces)
onoffset 30Sets the offset for the on event
onrandomoffset trueSets the random offset for the on event
offtime duskTime as specified in the table above for time configuration
offtopic my_topicSets the topic for the off event (no spaces)
offpayload my_payloadSets the payload for the off event (no spaces)
offoffset -30Sets the offset for the off event
offrandomoffset falseSets the random offset for the off event
mon falseDisables the schedule on a Monday
tue trueEnables the schedule on a Tuesday
ontime 16:30 onoffset 60 onrandomoffset trueSets the time, offset and random offset for the on event
passthroughunhandled falseDisabled unhandled input messages automatically being sent to output

Enabling extra debugging

Install node-red-contrib-config and drag a config node into your workspace. Configure the node to set a global variable called schedex with a JSON value of {"debug": true}. Also make sure that the config tickbox for active is unchecked. Redeploy. Now click the button on the config node. This will trigger all instances of schedex to write extra logging to the os syslog next time they're invoked.

Keywords

FAQs

Last updated on 19 Mar 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc