Stoptimer is not restarting Looptimer?

I've been having some weird intermittent behavior with a part of my nodered flow that involves "pausing" a message at a Stoptimer node, then passing it to a Looptimer node if not "stopped". The message (not "stop" payload) is making it out of the Stoptimer node to the Looptimer, but the looptimer is only changing from "Stopped" to blank, not "running". What's really wierd is if I add a debug node to the output of the stoptimer, the same message will now correctly start the looptimer. It's almost as if the looptimer won't work without a debug node reading the incoming signal?

Incidentally, when the looptimer gets a "stop" message, it always correctly updates to the "stopped" state, with or without an additional debug node. Also, directly injecting any random message to the looptimer will reliably start it, regardless what message(s) I send (except payload:"stop" of course). It's just the messages emitted from the stoptimer that aren't starting the looptimer.

Any ideas why this is happening? I'd post the flow export, but I noticed it contains a lot of personal info. So I am hoping the pic and text description are adequate.

Some background on the goal of the flow: it uses a beeper to remind occupants to close certain exterior doors that should not remain open very long. It beeps every 20sec if a door is left open longer than it's connected stoptimer node (20sec to get through normal doors, and 60sec to pass through the 'garage cover'). Closing the door will immediately stop beepers and reset associated timers. There's also a telegram command node to override (kill the beeps) if a door is intentionally left open. The flow has worked as expected in the past, but recently I noticed this issue has resulted in intermittent operation (beepers aren't working like they should every time).

[edit: Just noticed the 3 switch nodes seem to be redundant, and the same could be done with just 1 "change to stop" node with 3 stoptimers... but that shouldn't cause/fix any problems I don't think.]

This simplified version also does not work:
stoptimerLooptimerBug2

Did some quick testing, and the flow works the first time around after deploying. For example, deploy the flow, open the garage entry, and 20sec later the beeps start and loop runs as expected. Then, I close the garage entry, and go open the front door. It beeps initially (the wire that bypasses the timer nodes). After 20sec the stoptimer goes from "running" to blank (as expected), but the looptimer goes from "stopped" to blank ("running" is expected). It seems the looptimer is not starting upon msg receipt like it should.

What are these Stoptimer and Looptimer nodes of which you speak?
If you think you have a problem with a particular node then the best thing to do is to make a small flow exhibiting the problem with inject node(s) to send the mesages that cause the problem. Then you can export that here so we can try it and see if we can understand what is going on

1 Like

I hear you, and even before reading your post I have been trying to get a straightforward injection sample to exhibit the same behavior. So far my efforts haven't resulted in anything of use (no matter how closely I try to match the problematic messages, they seem to work fine with inject nodes... go figure). I'll keep at it a little longer, since there's some info in "data" that's different (though I assumed that wouldn't change anything... but might as well try at this point).

OK, I did manage to come up with a minimal flow that will reproduce the issue (of course with shorter loops to speed the testing process):

[{"id":"bd3d2e7.9d5aad","type":"looptimer","z":"d6bde18e.b9016","duration":"5","units":"Second","maxloops":"500","maxtimeout":"60","maxtimeoutunits":"Minute","name":"","x":1500,"y":220,"wires":[["319c4ea6.57ce62"],[]]},{"id":"319c4ea6.57ce62","type":"debug","z":"d6bde18e.b9016","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1680,"y":220,"wires":[]},{"id":"941b1ed8.0f9d3","type":"inject","z":"d6bde18e.b9016","name":"","topic":"some_random_injection","payload":"stop","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1400,"y":100,"wires":[["bd3d2e7.9d5aad"]]},{"id":"c456c156.39472","type":"inject","z":"d6bde18e.b9016","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1350,"y":40,"wires":[["272f5e94.1cd8d2"]]},{"id":"272f5e94.1cd8d2","type":"change","z":"d6bde18e.b9016","name":"","rules":[{"t":"set","p":"","pt":"msg","to":"{\"topic\":\"binary_sensor.garage_entry\",\"payload\":\"on\",\"data\":{\"entity_id\":\"binary_sensor.garage_entry\",\"old_state\":{\"entity_id\":\"binary_sensor.garage_entry\",\"state\":\"off\",\"attributes\":{\"node_id\":22,\"value_index\":0,\"value_instance\":1,\"value_id\":\"72057594412007424\",\"friendly_name\":\"Garage Entry\",\"device_class\":\"opening\"},\"last_changed\":\"2019-07-21T21:28:21.549849+00:00\",\"last_updated\":\"2019-07-21T21:28:21.549849+00:00\",\"context\":{\"id\":\"677b19a32506409187299521dcd4c571\",\"parent_id\":null,\"user_id\":null}},\"new_state\":{\"entity_id\":\"binary_sensor.garage_entry\",\"state\":\"on\",\"attributes\":{\"node_id\":22,\"value_index\":0,\"value_instance\":1,\"value_id\":\"72057594412007424\",\"friendly_name\":\"Garage Entry\",\"device_class\":\"opening\"},\"last_changed\":\"2019-07-21T21:32:32.291917+00:00\",\"last_updated\":\"2019-07-21T21:32:32.291917+00:00\",\"context\":{\"id\":\"0d69573dc373443388ff27b931362a35\",\"parent_id\":null,\"user_id\":null},\"timeSinceChangedMs\":25}},\"_msgid\":\"ea6a6252.215de\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":40,"wires":[["87c9cc67.9b6d8"]]},{"id":"87c9cc67.9b6d8","type":"stoptimer","z":"d6bde18e.b9016","duration":"5","units":"Second","payloadtype":"str","payloadval":"stop","name":"","x":1700,"y":40,"wires":[["bd3d2e7.9d5aad"],[]]}]

stoptimerLooptimerBug3
First, inject "on", then wait for the stoptimer node to start the looptimer. Now, inject "stop" to stop the looptimer. Now, try to repeat this by injecting "on" again... when the message passes the stoptimer this time it fails to restart the looptimer. Notice how the "stopped" state gets cleared from the looptimer at this time. [edit Further testing shows that injecting "on" additional times will never restart the looptimer. IE, once it is stopped it seems a looptimer can't be restarted from a stoptimer again?]

I formulated the "on" injection to match closely what was coming from the sensor state nodes ahead of it. Of course some of the data from the real sensor will be more dynamic (like state times etc), but I can reassure you the same behavior occurs when my real sensors are sending real messages, and when I use that 'static' inject node to send simulate those messages. Not sure if it's something in that message content that causes this, or if this is just a straight up bug in the interaction of these 2 nodes (or maybe it is both).

[edit: Forgot... rpi3b+, hassio 0.96.2, and nodered, ssh, mqtt broker are all current release... everything else is running like a top.]

What is the name of the timer node? you know node-red-contrib-?????

As posted above - stoptimer - node-red-contrib-stoptimer?

Sorry all... somehow pasting the flow above was borked and appears to only have included the injector node. I fixed it in my above post, and pasted it here again to be clear:

[{"id":"bd3d2e7.9d5aad","type":"looptimer","z":"d6bde18e.b9016","duration":"5","units":"Second","maxloops":"500","maxtimeout":"60","maxtimeoutunits":"Minute","name":"","x":1500,"y":220,"wires":[["319c4ea6.57ce62"],[]]},{"id":"319c4ea6.57ce62","type":"debug","z":"d6bde18e.b9016","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1680,"y":220,"wires":[]},{"id":"941b1ed8.0f9d3","type":"inject","z":"d6bde18e.b9016","name":"","topic":"some_random_injection","payload":"stop","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1400,"y":100,"wires":[["bd3d2e7.9d5aad"]]},{"id":"c456c156.39472","type":"inject","z":"d6bde18e.b9016","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1350,"y":40,"wires":[["272f5e94.1cd8d2"]]},{"id":"272f5e94.1cd8d2","type":"change","z":"d6bde18e.b9016","name":"","rules":[{"t":"set","p":"","pt":"msg","to":"{\"topic\":\"binary_sensor.garage_entry\",\"payload\":\"on\",\"data\":{\"entity_id\":\"binary_sensor.garage_entry\",\"old_state\":{\"entity_id\":\"binary_sensor.garage_entry\",\"state\":\"off\",\"attributes\":{\"node_id\":22,\"value_index\":0,\"value_instance\":1,\"value_id\":\"72057594412007424\",\"friendly_name\":\"Garage Entry\",\"device_class\":\"opening\"},\"last_changed\":\"2019-07-21T21:28:21.549849+00:00\",\"last_updated\":\"2019-07-21T21:28:21.549849+00:00\",\"context\":{\"id\":\"677b19a32506409187299521dcd4c571\",\"parent_id\":null,\"user_id\":null}},\"new_state\":{\"entity_id\":\"binary_sensor.garage_entry\",\"state\":\"on\",\"attributes\":{\"node_id\":22,\"value_index\":0,\"value_instance\":1,\"value_id\":\"72057594412007424\",\"friendly_name\":\"Garage Entry\",\"device_class\":\"opening\"},\"last_changed\":\"2019-07-21T21:32:32.291917+00:00\",\"last_updated\":\"2019-07-21T21:32:32.291917+00:00\",\"context\":{\"id\":\"0d69573dc373443388ff27b931362a35\",\"parent_id\":null,\"user_id\":null},\"timeSinceChangedMs\":25}},\"_msgid\":\"ea6a6252.215de\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":40,"wires":[["87c9cc67.9b6d8"]]},{"id":"87c9cc67.9b6d8","type":"stoptimer","z":"d6bde18e.b9016","duration":"5","units":"Second","payloadtype":"str","payloadval":"stop","name":"","x":1700,"y":40,"wires":[["bd3d2e7.9d5aad"],[]]}]

So I'm referring to the node-red-contrib-stoptimer and node-red-contrib-looptimer nodes. I'm a newb learning new stuff here (if you couldn't tell)... all I know is these nodes came "built in" with the nodered plugin for hassio.

I may be on to something, and it smells like inadequate documentation is all. Here is a slightly modified version of the flow that works as expected:

[{"id":"bd3d2e7.9d5aad","type":"looptimer","z":"d6bde18e.b9016","duration":"5","units":"Second","maxloops":"500","maxtimeout":"60","maxtimeoutunits":"Minute","name":"","x":1500,"y":220,"wires":[["319c4ea6.57ce62"],[]]},{"id":"319c4ea6.57ce62","type":"debug","z":"d6bde18e.b9016","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1680,"y":220,"wires":[]},{"id":"941b1ed8.0f9d3","type":"inject","z":"d6bde18e.b9016","name":"","topic":"some_random_injection","payload":"stop","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1400,"y":100,"wires":[["bd3d2e7.9d5aad"]]},{"id":"c456c156.39472","type":"inject","z":"d6bde18e.b9016","name":"","topic":"","payload":"on","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1350,"y":40,"wires":[["272f5e94.1cd8d2"]]},{"id":"272f5e94.1cd8d2","type":"change","z":"d6bde18e.b9016","name":"","rules":[{"t":"set","p":"","pt":"msg","to":"{\"topic\":\"binary_sensor.garage_entry\",\"payload\":\"on\",\"data\":{\"entity_id\":\"binary_sensor.garage_entry\",\"old_state\":{\"entity_id\":\"binary_sensor.garage_entry\",\"state\":\"off\",\"attributes\":{\"node_id\":22,\"value_index\":0,\"value_instance\":1,\"value_id\":\"72057594412007424\",\"friendly_name\":\"Garage Entry\",\"device_class\":\"opening\"},\"last_changed\":\"2019-07-21T21:28:21.549849+00:00\",\"last_updated\":\"2019-07-21T21:28:21.549849+00:00\",\"context\":{\"id\":\"677b19a32506409187299521dcd4c571\",\"parent_id\":null,\"user_id\":null}},\"new_state\":{\"entity_id\":\"binary_sensor.garage_entry\",\"state\":\"on\",\"attributes\":{\"node_id\":22,\"value_index\":0,\"value_instance\":1,\"value_id\":\"72057594412007424\",\"friendly_name\":\"Garage Entry\",\"device_class\":\"opening\"},\"last_changed\":\"2019-07-21T21:32:32.291917+00:00\",\"last_updated\":\"2019-07-21T21:32:32.291917+00:00\",\"context\":{\"id\":\"0d69573dc373443388ff27b931362a35\",\"parent_id\":null,\"user_id\":null},\"timeSinceChangedMs\":25}},\"_msgid\":\"ea6a6252.215de\"}","tot":"json"}],"action":"","property":"","from":"","to":"","reg":false,"x":1500,"y":40,"wires":[["87c9cc67.9b6d8"]]},{"id":"87c9cc67.9b6d8","type":"stoptimer","z":"d6bde18e.b9016","duration":"5","units":"Second","payloadtype":"str","payloadval":"stop","name":"","x":1700,"y":40,"wires":[["d46c32f1.35f72","5e839302.66ee5c"],[]]},{"id":"d46c32f1.35f72","type":"debug","z":"d6bde18e.b9016","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1890,"y":40,"wires":[]},{"id":"5e839302.66ee5c","type":"change","z":"d6bde18e.b9016","name":"","rules":[{"t":"set","p":"_timerpass","pt":"msg","to":"false","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1670,"y":160,"wires":[["bd3d2e7.9d5aad","4ab3fb81.6d8a24"]]},{"id":"4ab3fb81.6d8a24","type":"debug","z":"d6bde18e.b9016","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1850,"y":160,"wires":[]}]

So it seems _timerpass:true is the problem. By just changing "_timerpass" to 'false' with a change node, now the stoptimer node can repeatedly restart the looptimer. I see nothing about the usage of "_timerpass" in the info tabs for either node. Even a quicky (admitedly weak) google search "nodered _timerpass" turns up junk. Adding a little more info on "_timerpass" to the node's info tabs would be a solution.

Does anyone know where the repository for these nodes is, if they exist? I wouldn't mind helping with a fix, but the only thing I found was the npm page... no github.

Also generally variable names starting with _ are meant to be internal only so I wouldn’t expect them to be needed to be mentioned in info. So it sounds like there is something more amiss that just docs.

Could you not create the same functionality using core nodes?
ie break down the flow, and look at what you want to happen. The core nodes are surprisingly flexible, and with a bit of ingenuity...
There are also a number of well used and well supported contrib nodes that are mentioned here frequently, such as the gate nodes published by Mike Bell - @drmibell to consider.