drmibell / node-red-contrib-simple-gate Goto Github PK
View Code? Open in Web Editor NEWA Node-RED node for controlling message flow.
License: Apache License 2.0
A Node-RED node for controlling message flow.
License: Apache License 2.0
In the dashboard 'Info panel', the node is only referred to as 'gate', so unless users can remember which node was installed/used, it could potentially be node-red-contrib-message-gate, queue-gate, simple-gate, etc.
Also if sharing a flow, and the new user doesn't have your node already installed, node-RED will halt awaiting the node 'gate' to be registered, but which one?
If this line was changed to more accurately reflect the node's name (simple-gate), it would make it much easier to identify.
This is a very minor issue, which you may wish to consider when you next update the node.
While trying this node for the first time, I was very confused reading the node's help.
Messages with the topic Control Topic are control messages, which set the state of the gate. Control messages can have values representing open, close, toggle, default, and status.
To me, this seemed like I needed to set msg.topic to "Control Topic" (which I now know is incorrect). I played with a 'help' that I think will be better understand:
And here is the code that would replace the current help:
<script type="text/x-red" data-help-name="gate">Transmits input messages when in the open
state and blocks them when
closed
.
Configuration options:
Control Topic:
defines the msg.topic used in messages to control the state of the gate. Messages with this topic can alter or retrieve the status of the gate by setting msg.payload to one of the Command
options (see below)
Default State:
Sets the default state of the gate when first deployed or after a default command. This can be captured by the Status
node.
Restore from state saved in:
When checked and with a chosen persistent form of context storage selected, the node will enter the state it was in prior to a re-deploy or Node-RED restart.
Commands:
The default options are open
, close
, toggle
, default
, or status
.
You can change the default commands to a name you want. If you change any of them, you will use that value in msg.payload when sending a control message to the node.
Examples can be found in the Import options
(hamburger menu -> Import -> Examples -> flows -> node-red-contrib->simple-gate)
It would be useful to be able to set the queue size to 1 but have it so that it is the latest message that is saved rather than the oldest. The result would be that the gate could be used to stop a stream of messages, possibly containing values of a slider for example, then when the gate is opened the latest value is released.
Since nodes in Node-Red are connected by virtual 'wires', not 'pipes', then the terminology should be electrical, not plumbing.
OPEN should mean that the switch is open and current doesn't flow.
CLOSED should mean that the switch is closed and current flow is allowed.
at the moment we can only use msg.topic.
since this is widely used for other things i can not integrate this gate node because it screws up the topic of the current flows
if we could choose our own category this node could be integrated anywere.
eg msg.control, msg.gate
for now i solved the thing with rules in a function.(but this does not show a realtime state)
The node doesn't appear to persist reboot's.
It would be a great improvement if the current state was saved to flow context, so that the same state was retrieved after a reboot.
I was wondering today when using the gate node that I don't get a message when requesting the current status.
Apparently the problem is that the switch case for the status is missing the necessary code.
See:
node-red-contrib-simple-gate/gate.js
Line 82 in b547e21
The case is empty. Is that on purpose?
I am hoping this is the right node. I am going on the icon used more than anything. (See below)
That you can select between TEXT
and NUMBER
values.
I have written a basic bit of code upstream from this node.
It is a toggle and so uses 0
and 1
values.
To keep things simple the 0
and 1
are sent out as the messages.
But I can't use them to control your node.
To get it working I need a lot more code to convert from number to text. :(
(Oh, P.S.)
The name used isn't helping.
In NR it is called GATE
yet here it is SIMPLE-GATE
. So which is it?
The message like below I get in logs every minute (I think when a message from sensor is received)
29 Dec 10:05:54 - [error] [gate:c1a75881.315b98] TypeError: Cannot read property 'toLowerCase' of undefined
The "on" and "off" fields.
They allow only ONE entry. Fair enough, but.... (wink)
There are times when I am using a complicated gate layout and there are many paths.
Therefore there are many signals.
Could the OFF field be allowed to accept multiple types?
eg: off || close || shut
Those words a poor examples but to help get the idea through.
That way you could have something like this.
(Again slight over simplified.)
SORRY
I stuffed up - again.
Hi,
I very often have the used case where I use your Simple-gate node along with the MyTimeout node to lock the gate for a certain period of time (e.g. Send Weather update only every 2h, but overwrite when rain is starting)
It would be great to have your gate with an integrated timout-timer to close or open the gate for a certain period of time. As usual controlled via Control topic
Thanks for considering!
below is a code example of my workaround:
[{"id":"f5bb6512.75a3a8","type":"inject","z":"4dad7ace.9006c4","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1580,"y":320,"wires":[["ecf8862a.d220d"]]},{"id":"ecf8862a.d220d","type":"gate","z":"4dad7ace.9006c4","name":"","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":1790,"y":350,"wires":[["6509d78f.7db23","95a023d3.392128"]]},{"id":"6509d78f.7db23","type":"mytimeout","z":"4dad7ace.9006c4","name":"1h","outtopic":"control","outsafe":"close","outwarning":"","outunsafe":"open","warning":"5","timer":"3600","debug":false,"ndebug":false,"ignoreCase":false,"repeat":false,"again":false,"x":1780,"y":430,"wires":[["8a26057f.cb568"],[]]},{"id":"8a26057f.cb568","type":"change","z":"4dad7ace.9006c4","name":"ctrl","rules":[{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1900,"y":430,"wires":[["ecf8862a.d220d"]]}]
In the Information panel to the node I read the following:
Messages with the topic Control Topic are control messages, which set the state of the gate.
The two words Control Topic are in red. I thought that I need to set
msg.topic = "Control Topic";
but it seems that
msg.topic = "Control";
is the correct setting. In my personal view the text is slightly misleading.
Without the red word 'Topic' I probably would have made it in the first try (and probably would made other errors).
Maybe you look at it and decide yourself.
Kind regards,
Urs.
Hi! Really like this node, very useful for home automation stuff where you want to block repeating messages from sensors and switches.
Was wondering if it is possible to implement a new feature into this node. I'd like to have an option (check box) to set the node state to closed after receiving a first message.
In my example, I'm using a Hue Wall Switch Module that has two inputs. It gives an event on button press, quick button release, hold button (repeating every 800ms) and hold button release. I want to use the hold button event to trigger a repeating message for dimming a Hue light and use the hold button release to stop/reset the trigger. Therefore, I only need the first hold button event for my example and ideally have the gate closed automatically after receiving the first message.
Let me know what you think!
Hi,
It would be nice if we could control the gate node without connecting 'wires' to the input. In my case, I want to use multiple gates on a flow, all of them will be controlled by the same trigger. I think instead messing up with multiple wires, the gate node could be controlled by flow/global variable.
Then I can simply switch variable in one function node (or maybe dedicated control node) to open each gate that "listen" the same variable.
What do You think?
Please provide release info available on page https://github.com/drmibell/node-red-contrib-simple-gate/releases
It's very convenient to see changlelog and it's possible to subscribe on these releases to be in the loop.
Hi
Great gate function, though it seems its not blocking all payloads. I have an Ikea motion sensor using a zigbee2mqtt-devices node, which unfortunately can pass through you closed gate node.
I cant give you its exact payload output, for some strange reason I cant get the debug node to pickup anything from it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.