Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add status label #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ A node that stores a message and emits it when it is triggered.

1. Send a message to the node
2. Send a message which has the .trigger property set to true. The message sent at step 1 will be emited at the output of the node.

![statuses](img/hold-statuses.png)
4 changes: 4 additions & 0 deletions hold/hold.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ module.exports = function(RED) {
var node = this;
var msg = {};
node.context().storedmessage = node.context().storedmessage || null;
node.status({"shape":"dot","fill":"grey","text":"No message in buffer"})
this.on('input', function (msg) {
if ((msg.trigger==null)||(msg.trigger!=true)) {
node.context().storedmessage = msg;
node.status({"shape":"dot","fill":"blue","text":"Message hold"})
} else {
if(node.context().storedmessage!=null) {
node.send(node.context().storedmessage);
node.status({"shape":"dot","fill":"green","text":"Message triggered"})
} else {
node.warn("Hold '"+n.name+"' triggered without message in buffer.");
node.status({"shape":"dot","fill":"yellow","text":"Triggered without message in buffer"})
}
}
});
Expand Down
Binary file added img/hold-statuses.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "node-red-contrib-hold",
"version": "1.0.0",
"version": "1.1.0",
"description": "A node-red node which stores a message and emits it once it gets triggered",
"dependencies": {},
"keywords": [
Expand Down