Is there a way to reset the "For" timer within an 'events: state' node?

I have an event node that initiates if humidity is less than a certain value for 60 minutes. My challenge is that I would like:

  1. to ignore this entire flow if the humidifier is off
  2. to reset the 60 minute counting if the humidifier is turned on

I have sort of accomplished goal 1) with the ‘current state’ node to check if the humidifier is on. I just need to find a way to accomplish 2).

My flow:

Settings for the ‘event: state’ node:

Where You able to solve this ? I have the same problem.

I think there is no way to do that.
The only way around it that I can think of is to remove the for, and after current state node set a get history node to get the history of the humidity and check each value for the past 60 minutes in a function node.

What do you mean by reset? restart the countdown again from 60 minutes or stop it?

I believe you want the first one, right? then this might be what you need.

[{"id":"4cfa860.913c17c","type":"api-current-state","z":"504c4983.a509d8","name":"humidififer on?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"your_humidifier","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":510,"y":2540,"wires":[["8e7fa521.613b78"],["51772f0a.c783c"]]},{"id":"8e7fa521.613b78","type":"api-current-state","z":"504c4983.a509d8","name":"< 37?","server":"9405c3fe.d0a6c","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"sensor.humidity","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":670,"y":2500,"wires":[["1e01252a.3e51db"],["51772f0a.c783c"]]},{"id":"51772f0a.c783c","type":"change","z":"504c4983.a509d8","name":"stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":790,"y":2540,"wires":[["1e01252a.3e51db"]]},{"id":"912ae60a.f93058","type":"trigger-state","z":"504c4983.a509d8","name":"Humidity < 37?","server":"9405c3fe.d0a6c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.humidity","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":"<","comparatorValueDatatype":"num","comparatorValue":"37","propertyValue":"new_state.state"},{"targetType":"this_entity","targetValue":"","propertyType":"previous_state","comparatorType":">=","comparatorValueDatatype":"num","comparatorValue":"37","propertyValue":"old_state.state"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":false,"x":280,"y":2500,"wires":[["4cfa860.913c17c"],[]]},{"id":"56ead76a.daea48","type":"trigger-state","z":"504c4983.a509d8","name":"Humidity >= 37?","server":"9405c3fe.d0a6c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityid":"sensor.humidity","entityidfiltertype":"exact","debugenabled":false,"constraints":[{"targetType":"this_entity","targetValue":"","propertyType":"current_state","comparatorType":">=","comparatorValueDatatype":"num","comparatorValue":"37","propertyValue":"new_state.state"},{"targetType":"this_entity","targetValue":"","propertyType":"previous_state","comparatorType":"<","comparatorValueDatatype":"num","comparatorValue":"37","propertyValue":"old_state.state"}],"inputs":0,"outputs":2,"customoutputs":[],"outputinitially":false,"state_type":"str","enableInput":false,"x":280,"y":2540,"wires":[["4cfa860.913c17c"],[]]},{"id":"4046f79c.319948","type":"server-state-changed","z":"504c4983.a509d8","name":"Humifier","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"your_humidifier","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":300,"y":2580,"wires":[["4cfa860.913c17c"]]},{"id":"1e01252a.3e51db","type":"trigger","z":"504c4983.a509d8","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"60","extend":true,"overrideDelay":false,"units":"min","reset":"stop","bytopic":"all","topic":"topic","outputs":1,"x":950,"y":2500,"wires":[["af284073.7340e"]]},{"id":"af284073.7340e","type":"api-call-service","z":"504c4983.a509d8","name":"Lamp to red","server":"9405c3fe.d0a6c","version":3,"debugenabled":false,"service_domain":"","service":"","entityId":"","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":1110,"y":2500,"wires":[[]]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]

It’s a bit cumbersome but I think it’ll do what you want

I believe the issue is the events state node posted in the image in the first post.
It has a for 60 minutes.
But only if the humidifier is on (or off, whichever it is), but the for thing doesn’t care about that.

The if state can be fulfilled without the humidifier state being correct.
So lets say the humidity is fulfilled for 50 minutes of the for, then the humidifier is turned on, that means after 10 minutes the sequence could trigger and everything would be “true”.
Except that the humidifier has not been on during this time.

So I guess the correct trigger statement should be if humidity < 37 for 60 minutes and humidifier == on for 60 minutes.

That’s exactly what my flow does. If humidty < 37 and humidifier == on are both true for at least 60 minutes each, then do.

1 Like