Hi,my name is kimi
How do I create a timer that started counting after the value in the flow exceeded certain value?
Im using an external switches that allows more voltage to pass through after I clicked to the respective switches.Currently I have 4 switches.So I have 4 sensor nodes.
How to create a flow from sensor node with a timer after I clicked the switches and when I off the switches it stopped counting and stores the amount of time.
Thank you!
What do you want to do with the timer? When does it (need to) stop ? Where do you want to store the time ?
I'm a bit confused here... the bit about more voltage to pass through after your click the respective switches.
Does that mean each of the four switches are connected to four different voltages???
Or, you have four switches and depending on the binary pattern (various switches down or up) you want the timer to run for a unqiue amount of time?
An example to get you started:
[{"id":"ef86b984.c308d","type":"inject","z":"b02181d3.325168","name":"on: 5.5v","topic":"","payload":"5.5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":248,"y":330,"wires":[["1deecae.2564eb5"]]},{"id":"c48d825d.37c788","type":"inject","z":"b02181d3.325168","name":"on: 8v","topic":"","payload":"8","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":248,"y":374,"wires":[["1deecae.2564eb5"]]},{"id":"1f88b052.4f0da","type":"inject","z":"b02181d3.325168","name":"off: 0v","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":248,"y":418,"wires":[["1deecae.2564eb5"]]},{"id":"13d458a2.fe019f","type":"debug","z":"b02181d3.325168","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":642,"y":374,"wires":[]},{"id":"1deecae.2564eb5","type":"function","z":"b02181d3.325168","name":"","func":"c = flow.get(\"timer\")\ni = msg.payload\n\nif(i > 5.5){\n // start timer\n node.send({payload:\"Timer started\"})\n d = new Date()\n flow.set(\"timer\",d)\n}\n\nif(i === 0 && c){\n d = new Date()\n o = d-c\n flow.set(\"timer\",0) // reset\n node.send({payload:\"Timer end\"})\n return {payload:{time:o}} // time in ms\n}","outputs":1,"noerr":0,"x":446,"y":374,"wires":[["13d458a2.fe019f"]]}]
You could adapt this and handle this per "topic".
timer starts when I turn on the switch and stop when I turn off(open circuit) the switch
Im also confused with the voltage values.
open circuit does not mean 0 voltage but a lower voltage compared to when closed circuit.
It still works eventhough I do not know the exact voltage,Im just altering the range to complete my GUI.
Im using analog modbus with mini pc and 4 switches.mini pc connect with the main laptop with lan cables to display the node red.
So you asked a similar question yesterday. From the docs you read you should have learned how to store the start time.
So when the voltage changes you can then in a second flow get the end time and then using a function node you can subtract one time from the other to get the difference. (google javascript time to find out how)