Installations
npm install node-red-contrib-toggle
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
12.18.0
NPM Version
6.14.4
Score
67.7
Supply Chain
98.6
Quality
75.5
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
HTML (69.34%)
JavaScript (30.66%)
Developer
eschava
Download Statistics
Total Downloads
41,895
Last Day
46
Last Week
338
Last Month
1,133
Last Year
15,711
GitHub Statistics
2 Stars
12 Commits
2 Forks
2 Watching
1 Branches
2 Contributors
Package Meta Information
Latest Version
0.1.1
Package Id
node-red-contrib-toggle@0.1.1
Unpacked Size
101.50 kB
Size
85.25 kB
File Count
13
NPM Version
6.14.4
Node Version
12.18.0
Total Downloads
Cumulative downloads
Total Downloads
41,895
Last day
-22%
46
Compared to previous day
Last week
61%
338
Compared to previous week
Last month
-31.7%
1,133
Compared to previous month
Last year
78.1%
15,711
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
node-red-contrib-toggle
Toggle switch node for Node-red.
This node is a companion for any switch (physical or virtual), storing its state and providing toggle operation without need of using function nodes or flow/global variables.
Fig. 1: Node appearance
Installation
In Node-RED (preferred)
- Via Manage Palette -> Search for "node-red-contrib-toggle"
In a shell
- go to the Node-RED installation folder, e.g.:
~/.node-red
- run
npm install node-red-contrib-toggle
Usage
Node Configuration
The node configuration sets the active on/off/toggle keywords as well as optional topic names.
Fig. 2: Node properties
ON value / OFF value / Toggle value
These attributes can be of type
- string
- number
- boolean
They are set to the values you want to be the keywords within msg.payload
when the actions switch to ON, switch to OFF and toggle shall take place (execution command).
Remark: If you do not set a value to one of the attributes the according method (e.g. switch ON) can not be executed by the node (it needs a value to compare...).
On/Off topic resp. Toggle topic (optional)
If you set the topic attributes to a value, the input msg
needs to contain the same topic name to execute On/Off resp. toggle in addition to the msg.payload
value containing the execution command.
Pass through ON/OFF messages
The node has three pass through modes:
- No - means that node sends an output
msg
only when state is toggled. ON/OFF input messages just update internal state of the node. - If changed - sends an output
msg
for ON/OFF input message only once it differs from the previous state. And obviously message is always sent for "toggle" message. - Always - the output
msg
is always sent as a reaction on an inputmsg
.
Input
The input msg.payload
contains the execution command to the node.
The value needs to be identical to the values you configured in the configuration dialog.
If a (string) value is set to the configuration attributes On/Off topic or Toggle topic, the msg.topic
property must contain the same string value to execute the command given in msg.payload
.
An example msg
contents is shown for On/Off topic = "onofftopic":
Fig. 3: Example msg
when using topics
Output
The input msg
is forwarded to the output, if a valid switch command was detected.
The configuration attribute pass through ON/OFF messages is taken into account.
Node status
The node status signals:
- If the switch status is on it shows a green dot with the text ON.
- If the switch status is off it shows a red dot with the text OFF.
Initially it shows no state.
Examples
Remark: Example flows are present in the examples subdirectory. In Node-RED they can be imported via the import function and then selecting Examples in the vertical tab menue.
Example 1: Basic ON/OFF usage
This example shows the basic usage of the on and off commands.
The configuration is set to boolean true
resp. false
to switch on resp. switch off and no toggle option.
BasicUsage.json
Fig. 4: Basic usage example
Example 2: Basic toggle usage
This example shows the basic usage of the toggle command.
The configuration is set to boolean true
resp. false
and to toggle with all other msg.payload
/msg.topic
combinations.
ToggleUsage.json
Fig. 5: Toggle usage example
Example 3: Usage with topics
This example shows the usage of topics.
The configuration is set to strings (switchON
, switchOFF
) to switch on resp. off and a string (toggleSTATE
) to toggle the switch.
Additionally, the topics are set to onofftopic
(for the commands switchON
and switchOFF
) and to toggletopic
for the toggle operation (command toggleSTATE
).
TopicUsage.json
Fig. 6: Topic usage example
Version history
v0.1.1 Toggle example added to docu
v0.1.0 Docu rework
v0.0.2 Docs updated
v0.0.1 Initial release
Credits
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 2/5 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 9 are checked with a SAST tool
Score
3.1
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More