hello help me with this, please
node1 and node2 are inputs to node3, node4 is the output
if node3 received 2 msgs from node1 and didn't receive any msg from node2 then node3 send msg
I'll preheat your help
So are the nodes in sequence? i.e. does node1's out go to node2's input and node2's out go to node3 input etc?
What nodes are you using? What have you tried? what does your flow look like?
node1 is the schedule node that turns on the led in a specific time, node2 is a button that turns off led....the led must be turned off every time ...if not then node3 will send a warning(email) @zenofmud
do you mean at
a specific time?
so you haven't shown me how the nodes are connected. Please export your flow and attach it to a reply (make wure to use the </>
option when inserting your flow.
sorry for my English, LED suppose to work as a reminder, this is something similar for what I mean ...and node3 is what I'm asking about it will do nothing unless the button is not pushed after the LED is turned on by the cron-plus node
[{"id":"f2ffc9c7.914b38","type":"inject","z":"2acee63b.cfe00a","name":"GPIOinput button","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":620,"y":60,"wires":[["93c462d8.c2baa","7fb6a45f.8ab30c"]]},{"id":"46b7aaa5.4b4af4","type":"cronplus","z":"2acee63b.cfe00a","name":"","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"schedule1","topic":"schedule1","payloadType":"default","payload":"","expressionType":"cron","expression":"0 0 */12 * * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":620,"y":180,"wires":[["93c462d8.c2baa","7fb6a45f.8ab30c"]]},{"id":"93c462d8.c2baa","type":"debug","z":"2acee63b.cfe00a","name":"GPIOoutput LED","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":870,"y":180,"wires":[]},{"id":"7fb6a45f.8ab30c","type":"function","z":"2acee63b.cfe00a","name":"node3 !!!!!!!!!","func":"\nreturn msg;","outputs":1,"noerr":0,"x":850,"y":60,"wires":[[]]}]
So if I understand
1 - cron causes a msg to be sent and turns on the LED
2 - you can press the button and turn off the LED
3 - after a set amount of time, if the button has not been pushed, send an email
Is that right?
that's right
What I think you want is to use the trigger
node. Check out this little sample I came up with:
[{"id":"39dfd9f8.b63146","type":"inject","z":"dfab065e.cd792","name":"GPIOinput button (ON)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"ON","payloadType":"str","x":300,"y":160,"wires":[["789a3f8c.6221f","706448d1.63aea8"]]},{"id":"789a3f8c.6221f","type":"debug","z":"dfab065e.cd792","name":"GPIOoutput LED","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":610,"y":280,"wires":[]},{"id":"98482bd7.ff5b38","type":"inject","z":"dfab065e.cd792","name":"Manual OFF button","props":[{"p":"payload"},{"p":"reset","v":"reset","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":290,"y":280,"wires":[["789a3f8c.6221f","706448d1.63aea8"]]},{"id":"706448d1.63aea8","type":"trigger","z":"dfab065e.cd792","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"5","extend":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":580,"y":160,"wires":[["866efa9b.bd2ea8"]]},{"id":"e1861431.ef646","type":"debug","z":"dfab065e.cd792","name":"send email","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":160,"wires":[]},{"id":"866efa9b.bd2ea8","type":"change","z":"dfab065e.cd792","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"send email","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":780,"y":160,"wires":[["e1861431.ef646"]]}]
here it's not "after a set amount of time" it's before another msg from cron comes
So if I understand you, this is what you want?
initialization msg_count = 0
1 - cron sends out a msg - add 1 to msg_count
2 - if msg_count > 1 send email
3 - button pushed - set msg_count = 0
that's right
So make three flows
Flow 1: an inject node that sets flow.msg_count to 0 and set the inject node to run on initialization.
Flow 2: cron to a change node to the led node. In the change node add 1 to flow.msg_count. I would use JSONata to do it. You could also do this in a function node. Send the output of the change node to test if flow.msg_count is greater than 1. If so send the email
Flow 3: a button node connected to a change node that sets flow.msg_count to 0
Hrer is a sample of how you could do it - note flow 2 and 3 are flipped to make the wiring neat:
[{"id":"ce5936c0.23cb4","type":"inject","z":"dfab065e.cd792","name":"GPIOinput button (ON)","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"str","x":180,"y":600,"wires":[["300441b.d4a8ebe","2db1acd9.d8e834"]]},{"id":"2db1acd9.d8e834","type":"debug","z":"dfab065e.cd792","name":"GPIOoutput LED","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":690,"y":520,"wires":[]},{"id":"ffb6464a.3c4c08","type":"inject","z":"dfab065e.cd792","name":"Manual OFF button","props":[{"p":"payload"},{"p":"reset","v":"reset","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"OFF","payloadType":"str","x":170,"y":520,"wires":[["2db1acd9.d8e834","9c79b450.2a5dd"]]},{"id":"d4262bb4.2163b","type":"debug","z":"dfab065e.cd792","name":"send email","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":680,"wires":[]},{"id":"e3a6562e.9f31","type":"change","z":"dfab065e.cd792","name":"setup email text","rules":[{"t":"set","p":"payload","pt":"msg","to":"send email","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":440,"y":680,"wires":[["d4262bb4.2163b"]]},{"id":"ebd03041.87b53","type":"inject","z":"dfab065e.cd792","name":"Flow 1: initilization","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":170,"y":440,"wires":[["9c79b450.2a5dd"]]},{"id":"9c79b450.2a5dd","type":"change","z":"dfab065e.cd792","name":"set flow.msg_count to 0","rules":[{"t":"set","p":"msg_count","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":440,"wires":[[]]},{"id":"300441b.d4a8ebe","type":"change","z":"dfab065e.cd792","name":"flow.msg_count + 1","rules":[{"t":"set","p":"payload","pt":"msg","to":"$flowContext(\"msg_count\")+1","tot":"jsonata"},{"t":"set","p":"msg_count","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":450,"y":600,"wires":[["12fe943e.2d1e04","5246ab7d.8daba4"]]},{"id":"12fe943e.2d1e04","type":"debug","z":"dfab065e.cd792","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":600,"wires":[]},{"id":"5246ab7d.8daba4","type":"switch","z":"dfab065e.cd792","name":"msg_count > 1 ?","property":"msg_count","propertyType":"flow","rules":[{"t":"gt","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":450,"y":640,"wires":[["e3a6562e.9f31"]],"outputLabels":["True"]},{"id":"366ff401.f96a84","type":"comment","z":"dfab065e.cd792","name":"Flow 1","info":"","x":120,"y":400,"wires":[]},{"id":"1fea589b.48d64f","type":"comment","z":"dfab065e.cd792","name":"Flow 2","info":"","x":130,"y":560,"wires":[]},{"id":"880bedcd.e2b95","type":"comment","z":"dfab065e.cd792","name":"Flow 3","info":"","x":130,"y":480,"wires":[]}]
@zenofmud thank you so much
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.