linuxha / node-red-contrib-mytimeout

A dynamic count down timer for node-red
MIT License
10 stars 10 forks source link

Timer does not stop for FLOAT timeout values #10

Open tsprivate opened 5 years ago

tsprivate commented 5 years ago

Hi, I was experimenting a bit further with your timeout.

I have a calculated timeout which is a float value. When passing the float ast msg.timeout into your

[{"id":"7dd3409d.0daae","type":"mytimeout","z":"b1d09add.6b04a8","name":"timer","outtopic":"","outsafe":"on","outwarning":"Warning","outunsafe":"off","warning":"5","timer":"20.001","debug":"0","repeat":false,"again":false,"x":510,"y":380,"wires":[["559dcc7d.65e6f4"],["559dcc7d.65e6f4"]]},{"id":"745c54b6.b9a71c","type":"inject","z":"b1d09add.6b04a8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":380,"wires":[["cd407dbc.6a09"]]},{"id":"cd407dbc.6a09","type":"change","z":"b1d09add.6b04a8","name":"timeout","rules":[{"t":"set","p":"timeout","pt":"msg","to":"6.1234567","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"ON","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":380,"wires":[["7dd3409d.0daae"]]},{"id":"559dcc7d.65e6f4","type":"debug","z":"b1d09add.6b04a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":710,"y":380,"wires":[]}]

image

linuxha commented 5 years ago

I need to add in the document that mytimeout can only handle integer numbers. The issue is that the design counts down in 1 second intervals. So the time never hit 0 but was less than 0. Zero means timer has stopped, less than zero means time is not running. I coudn't come up with a decent design to handle floats.

I will look at the input to see if I can force it to an int to make sure it behaves better (hits zero and sends the off).

tsprivate commented 5 years ago

I just used a function node in front of the timeout and did a simple parseInt() to the timeout value. This sorted the issue for me

readeral commented 5 years ago

With #14 meaning that the Interval starts and stops (rather than continues to run) changing else if(ticks == 0) to else if(ticks <= 0) in the 'TIX' event listener should now be possible (as it won't continue to trigger, and respond to a -1 value). This would resolve this problem without the need for a function node.