Visual Timer Countdown In UI Using Variable Time Delay

To anyone who can help,

I’ve recently started using node red in HA to try automate a few processes in my home. I’ve created a sleep timer for my ducted heating/cooling system that turns the A/C off after a certain period of time.

I’m using a time helper to select the duration of the sleep timer & an input boolean to start the automation. It uses a state node to check what state the A/C is in & if it’s on (heat/cool/fan etc) that the timer helper outputs the value selected. This payload is converted to a delay, which then activates a trigger node (delay node can be used interchangably here). The trigger then turns off the A/C & resets the input boolean.

What I’m after is a way to visually see the time remaining on the delay prior to triggering shutdown of the A/C. I’ve played around with timer/counter nodes, but can’t get it to work. Here’s how the current setup appears in Lovelace.

Capture

And here’s my node red flow. Any help would be much appreciated!!

[{"id":"1bd824deebac1848","type":"api-call-service","z":"0d4fa5a32083bb91","name":"A/C Shutdown","server":"5085ef33.d0a66","version":3,"debugenabled":false,"service_domain":"climate","service":"turn_off","entityId":"climate.a_c","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":440,"y":660,"wires":[[]]},{"id":"e3118fa5653650dc","type":"function","z":"0d4fa5a32083bb91","name":"Change ms to s","func":"msg.delay = msg.delay * 60000;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":440,"y":540,"wires":[["5088c235e9655164"]]},{"id":"870d691cf360e831","type":"change","z":"0d4fa5a32083bb91","name":"Change Payload To Delay","rules":[{"t":"move","p":"payload","pt":"msg","to":"delay","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":480,"wires":[["e3118fa5653650dc"]]},{"id":"bd19b045351642df","type":"api-current-state","z":"0d4fa5a32083bb91","name":"Time Until Shutdown","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"120","halt_if_type":"num","halt_if_compare":"lte","entity_id":"input_number.time","state_type":"num","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":460,"y":420,"wires":[["870d691cf360e831"],[]]},{"id":"b34e091586a2b3a4","type":"api-current-state","z":"0d4fa5a32083bb91","name":"A/C Status","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"cool","halt_if_type":"str","halt_if_compare":"is","entity_id":"climate.a_c","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"500","forType":"num","forUnits":"milliseconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":430,"y":120,"wires":[["bd19b045351642df"],[]]},{"id":"b97733f0afc936bb","type":"server-state-changed","z":"0d4fa5a32083bb91","name":"A/C Sleep Timer","server":"5085ef33.d0a66","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.ac_sleep_timer","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"500","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":440,"y":40,"wires":[["b34e091586a2b3a4","1b9df89c5627677b","9caafc4810bf936c","f04555d5a42ddbea","ba6a09d3d85f8e5b"],["de6ecbbf6f8ce482"]]},{"id":"de6ecbbf6f8ce482","type":"change","z":"0d4fa5a32083bb91","name":"Reset A/C Shutdown Delay","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":180,"y":600,"wires":[["5088c235e9655164"]]},{"id":"5088c235e9655164","type":"trigger","z":"0d4fa5a32083bb91","name":"A/C Shutdown Trigger","op1":"","op2":"","op1type":"nul","op2type":"pay","duration":"1","extend":false,"overrideDelay":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":460,"y":600,"wires":[["1bd824deebac1848","728c2d48901329c1"]]},{"id":"1b9df89c5627677b","type":"api-current-state","z":"0d4fa5a32083bb91","name":"A/C Status","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"heat","halt_if_type":"str","halt_if_compare":"is","entity_id":"climate.a_c","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"500","forType":"num","forUnits":"milliseconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":430,"y":180,"wires":[["bd19b045351642df"],[]]},{"id":"9caafc4810bf936c","type":"api-current-state","z":"0d4fa5a32083bb91","name":"A/C Status","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"heat_cool","halt_if_type":"str","halt_if_compare":"is","entity_id":"climate.a_c","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"500","forType":"num","forUnits":"milliseconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":430,"y":240,"wires":[["bd19b045351642df"],[]]},{"id":"f04555d5a42ddbea","type":"api-current-state","z":"0d4fa5a32083bb91","name":"A/C Status","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"dry","halt_if_type":"str","halt_if_compare":"is","entity_id":"climate.a_c","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"500","forType":"num","forUnits":"milliseconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":430,"y":300,"wires":[["bd19b045351642df"],[]]},{"id":"ba6a09d3d85f8e5b","type":"api-current-state","z":"0d4fa5a32083bb91","name":"A/C Status","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"fan_only","halt_if_type":"str","halt_if_compare":"is","entity_id":"climate.a_c","state_type":"str","blockInputOverrides":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"entity"}],"for":"500","forType":"num","forUnits":"milliseconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":430,"y":360,"wires":[["bd19b045351642df"],[]]},{"id":"728c2d48901329c1","type":"api-call-service","z":"0d4fa5a32083bb91","name":"A/C Sleep Timer","server":"5085ef33.d0a66","version":3,"debugenabled":false,"service_domain":"input_boolean","service":"turn_off","entityId":"input_boolean.ac_sleep_timer","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":440,"y":720,"wires":[[]]},{"id":"5085ef33.d0a66","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}]

I also had a long way to get this kinda working - but have a look at flipdown timer card

I have a loop interval that I countdown till the next event. When the switch triggers it gets the time next interval (remaining time) from an input_number. It changes that from seconds to ms. Nodered almost always wants ms for time/timers by the way.

It sets that time in the counter which is then decreased by an inject node every second. The ms are then turned to mm:ss format. The current state node checks if the loop is enabled an stops it otherwise.

[{"id":"be21a6ee47e504b5","type":"inject","z":"93bee8c2cc0f11ba","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"$globalContext('homeAssistant.states.input_number.grow_pump_interval')","payloadType":"jsonata","x":870,"y":560,"wires":[["535a35ac2a6c6cc0"]]},{"id":"9c5fa4982650ac9e","type":"api-current-state","z":"93bee8c2cc0f11ba","name":"","server":"","version":3,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","entity_id":"binary_sensor.loop_template","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":1590,"y":620,"wires":[["403f631cfd1dbc01"],[]]},{"id":"403f631cfd1dbc01","type":"moment","z":"93bee8c2cc0f11ba","name":"","topic":"","input":"count","inputType":"msg","inTz":"America/New_York","adjAmount":0,"adjType":"days","adjDir":"add","format":"m:ss","locale":"en","output":"payload","outputType":"msg","outTz":"America/New_York","x":1900,"y":620,"wires":[["fdfc202ab6aefba4"]]},{"id":"fdfc202ab6aefba4","type":"ha-entity","z":"93bee8c2cc0f11ba","name":"last interval","server":"","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"last_interval"},{"property":"device_class","value":"time"},{"property":"icon","value":"mdi:clock"},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"payload","outputLocationType":"none","inputOverride":"block","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2110,"y":620,"wires":[[]]},{"id":"ae57b32c265f2cc6","type":"counter","z":"93bee8c2cc0f11ba","name":"","init":"0","step":"1000","lower":"","upper":"","mode":"decrement","outputs":"1","x":1320,"y":620,"wires":[["9c5fa4982650ac9e"]]},{"id":"535a35ac2a6c6cc0","type":"change","z":"93bee8c2cc0f11ba","name":"","rules":[{"t":"set","p":"x","pt":"msg","to":"homeassistant.homeAssistant.states[\"input_number.loop_interval\"].state","tot":"global"},{"t":"set","p":"x","pt":"msg","to":"($number(msg.x))*60000","tot":"jsonata"},{"t":"move","p":"x","pt":"msg","to":"reset","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1100,"y":620,"wires":[["ae57b32c265f2cc6"]]},{"id":"6c4555996ff3bedd","type":"inject","z":"93bee8c2cc0f11ba","name":"","props":[{"p":"payload"}],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":1130,"y":560,"wires":[["ae57b32c265f2cc6"]]},{"id":"988e7ab349807887","type":"server-state-changed","z":"93bee8c2cc0f11ba","name":"","server":"","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"switch.gtc_switch_01","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":570,"y":620,"wires":[["6ce6bb11cc7165ab"],[]]},{"id":"6ce6bb11cc7165ab","type":"delay","z":"93bee8c2cc0f11ba","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":880,"y":620,"wires":[["535a35ac2a6c6cc0","1355a78a5ca86bbe"]]}]

1 Like

Thanks for the input Mike,

I’m pretty new to HA, can you advise how I can add what you’ve suggested to what I already have to make this work? Specifically, setting up the binary_sensor.loop_template & input_number.loop_interval?

Those two entities control my variable loop on an esp. The timer counts down the time of the loop.

You would need to use the time info for the entity you want the count down for. Creating those entities will just make a random timer not tied to any entities.

The varistop timer is a straight forward approach and is simpler to implement. I suggest giving that a try first. If you have trouble getting that to work, please post your flow it will make it easier to help.

I redid your flow to make it more compact but it’s the same you posted in the first post. Go to the top right menu, the three white bars, manage palette, install. Then paste this: node-red-contrib-stoptimer-varidelay and install it. With this the flow below should do what you want.

The Timer entity for lovelace node creates a sensor.ac_timer in HA which you can use in lovelace to see the remaining time. It does survive restarts which is great when you are dealing with long timespans like 2 hours. Whithin the varidelay node (the green one), you can choose whether it reports every second or every minute and the last minute every second. It’s up to you.

msg.delay is set whithin the Time Until Shutdown node. There’s no need to translate it to milliseconds because varidelay will interpret the incoming msg.delay according to the unit the node is set to.

[{"id":"5268c0e0.d435d","type":"server-state-changed","z":"937ef78.ec6b408","name":"A/C Sleep Timer","server":"5085ef33.d0a66","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.ac_sleep_timer","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"500","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":1300,"y":300,"wires":[["39fbe05f.cee5b"],["8edafefb.b40a2"]]},{"id":"39fbe05f.cee5b","type":"api-current-state","z":"937ef78.ec6b408","name":"A/C Status","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"cool, heat, heat_cool, dry, fan_only","halt_if_type":"str","halt_if_compare":"includes","entity_id":"climate.a_c","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"500","forType":"num","forUnits":"milliseconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1470,"y":260,"wires":[["bf4812a2.188ab"],[]]},{"id":"bf4812a2.188ab","type":"api-current-state","z":"937ef78.ec6b408","name":"Time Until Shutdown","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"120","halt_if_type":"num","halt_if_compare":"lte","entity_id":"input_number.time","state_type":"num","blockInputOverrides":true,"outputProperties":[{"property":"delay","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":1660,"y":260,"wires":[["6a8f4f18.6a24b"],[]]},{"id":"6a8f4f18.6a24b","type":"stoptimer-varidelay","z":"937ef78.ec6b408","duration":"5","durationType":"num","units":"Minute","payloadtype":"num","payloadval":"0","name":"","reporting":"every_second","persist":true,"x":1860,"y":320,"wires":[["739b85ab.35ce5c"],[],["5a48ccac.fdfd44"]]},{"id":"8edafefb.b40a2","type":"change","z":"937ef78.ec6b408","name":"stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":1450,"y":320,"wires":[["6a8f4f18.6a24b"]]},{"id":"739b85ab.35ce5c","type":"api-call-service","z":"937ef78.ec6b408","name":"Input & climate off","server":"9405c3fe.d0a6c","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_off","entityId":"climate.a_c, input_boolean.ac_sleep_timer","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":2070,"y":300,"wires":[[]]},{"id":"5a48ccac.fdfd44","type":"ha-entity","z":"937ef78.ec6b408","name":"Timer entity for lovelace","server":"9405c3fe.d0a6c","version":1,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"ac_timer"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":2090,"y":360,"wires":[[]]},{"id":"5085ef33.d0a66","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},{"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}]

I would personally add the input_number as a trigger too (like in the picture below), just in case you want to change the timespan when the AC is already on. This way everything will update. Just my 2 cents.

1 Like

Thank you obaldius! This has worked perfectly, I added the input_number as suggested.

The only issue is that if I turn off the A/C via the lovelace UI, neither the sleep timer slider or countdown timer resets. Any advice for this?

Thanks again!

[{"id":"be7aebe9398ae273","type":"tab","label":"A/C Sleep Timer","disabled":false,"info":"","env":[]},{"id":"bbe1877518084f6a","type":"server-state-changed","z":"be7aebe9398ae273","name":"A/C Sleep Timer","server":"5085ef33.d0a66","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.ac_sleep_timer","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"500","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":100,"y":200,"wires":[["1d876714ce7a229b"],["e655d938ef419ed8"]]},{"id":"1d876714ce7a229b","type":"api-current-state","z":"be7aebe9398ae273","name":"A/C Status","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"cool, heat, heat_cool, dry, fan_only","halt_if_type":"str","halt_if_compare":"includes","entity_id":"climate.a_c","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"500","forType":"num","forUnits":"milliseconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":310,"y":80,"wires":[["c28ce2b2088ff886"],[]]},{"id":"c28ce2b2088ff886","type":"api-current-state","z":"be7aebe9398ae273","name":"Time Until Shutdown","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"120","halt_if_type":"num","halt_if_compare":"lte","entity_id":"input_number.time","state_type":"num","blockInputOverrides":true,"outputProperties":[{"property":"delay","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":380,"y":140,"wires":[["5566af7da94b3dc4"],[]]},{"id":"5566af7da94b3dc4","type":"stoptimer-varidelay","z":"be7aebe9398ae273","duration":"5","durationType":"num","units":"Minute","payloadtype":"num","payloadval":"0","name":"","reporting":"every_second","persist":true,"ignoretimerpass":false,"x":460,"y":200,"wires":[["fd6b3af9a9d9957a"],[],["6878398dec1417b1"]]},{"id":"e655d938ef419ed8","type":"change","z":"be7aebe9398ae273","name":"stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":200,"wires":[["5566af7da94b3dc4"]]},{"id":"fd6b3af9a9d9957a","type":"api-call-service","z":"be7aebe9398ae273","name":"Input & climate off","server":"167cc80b04eb4959","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_off","entityId":"climate.a_c, input_boolean.ac_sleep_timer","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":650,"y":180,"wires":[[]]},{"id":"6878398dec1417b1","type":"ha-entity","z":"be7aebe9398ae273","name":"Timer entity for lovelace","server":"167cc80b04eb4959","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Sleep Timer"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":670,"y":240,"wires":[[]]},{"id":"81d06311889204c9","type":"server-state-changed","z":"be7aebe9398ae273","name":"Time Until Shutdown","server":"5085ef33.d0a66","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.time","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"120","halt_if_type":"num","halt_if_compare":"lte","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[{"property":"payload","propertyType":"msg","value":"","valueType":"entityState"},{"property":"data","propertyType":"msg","value":"","valueType":"eventData"},{"property":"topic","propertyType":"msg","value":"","valueType":"triggerId"}],"x":110,"y":80,"wires":[["1d876714ce7a229b"],[]]},{"id":"5085ef33.d0a66","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},{"id":"167cc80b04eb4959","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}]

set your climate entity as a trigger too. You needn’t set a specific value to the input number node. If you leave it blank, it’ll trigger with any state changed event.

[{"id":"de43305a.18c67","type":"server-state-changed","z":"937ef78.ec6b408","name":"A/C Sleep Timer","server":"5085ef33.d0a66","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_boolean.ac_sleep_timer","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":"500","forType":"num","forUnits":"milliseconds","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":160,"y":280,"wires":[["99d1e31.0b0362"],["4090bfd6.b4503"]]},{"id":"99d1e31.0b0362","type":"api-current-state","z":"937ef78.ec6b408","name":"A/C Status","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"cool, heat, heat_cool, dry, fan_only","halt_if_type":"str","halt_if_compare":"includes","entity_id":"climate.a_c","state_type":"str","blockInputOverrides":true,"outputProperties":[],"for":"500","forType":"num","forUnits":"milliseconds","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":370,"y":160,"wires":[["28d653fe.e7569c"],[]]},{"id":"28d653fe.e7569c","type":"api-current-state","z":"937ef78.ec6b408","name":"Time Until Shutdown","server":"5085ef33.d0a66","version":3,"outputs":2,"halt_if":"120","halt_if_type":"num","halt_if_compare":"lte","entity_id":"input_number.time","state_type":"num","blockInputOverrides":true,"outputProperties":[{"property":"delay","propertyType":"msg","value":"","valueType":"entityState"}],"for":0,"forType":"num","forUnits":"minutes","override_topic":false,"state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","x":440,"y":220,"wires":[["82bcc948.6c6b78"],[]]},{"id":"82bcc948.6c6b78","type":"stoptimer-varidelay","z":"937ef78.ec6b408","duration":"5","durationType":"num","units":"Minute","payloadtype":"num","payloadval":"0","name":"","reporting":"every_second","persist":true,"x":520,"y":280,"wires":[["5c35013c.d5f85"],[],["b3f69d5e.f2654"]]},{"id":"4090bfd6.b4503","type":"change","z":"937ef78.ec6b408","name":"stop","rules":[{"t":"set","p":"payload","pt":"msg","to":"stop","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":280,"wires":[["82bcc948.6c6b78"]]},{"id":"5c35013c.d5f85","type":"api-call-service","z":"937ef78.ec6b408","name":"Input & climate off","server":"cfd476d1.6b0ac8","version":3,"debugenabled":false,"service_domain":"homeassistant","service":"turn_off","entityId":"climate.a_c, input_boolean.ac_sleep_timer","data":"","dataType":"jsonata","mergecontext":"","mustacheAltTags":false,"outputProperties":[],"queue":"none","x":710,"y":260,"wires":[[]]},{"id":"b3f69d5e.f2654","type":"ha-entity","z":"937ef78.ec6b408","name":"Timer entity for lovelace","server":"cfd476d1.6b0ac8","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":"Sleep Timer"},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":730,"y":320,"wires":[[]]},{"id":"b33ea8ba.474778","type":"server-state-changed","z":"937ef78.ec6b408","name":"Input number","server":"5085ef33.d0a66","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.time","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"num","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":150,"y":160,"wires":[["99d1e31.0b0362"]]},{"id":"9ec0b22a.5c0ba","type":"server-state-changed","z":"937ef78.ec6b408","name":"Climate off?","server":"9405c3fe.d0a6c","version":3,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"climate.your_climate","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"off","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"outputProperties":[],"x":150,"y":340,"wires":[["4090bfd6.b4503"],[]]},{"id":"5085ef33.d0a66","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},{"id":"cfd476d1.6b0ac8","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},{"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}]

Awesome. Now hopefully the last issue…

When I adjust the sleep timer inpu to a different value, the timer starts counting down automatically. I would like the timer to only start the countdown when the input_boolean slider is toggled on. The countdown shouldn’t operate at all if it is toggled off.

Thanks again.

[{"id":"6878398dec1417b1","type":"ha-entity","z":"be7aebe9398ae273","name":"Timer entity for lovelace","server":"167cc80b04eb4959","version":2,"debugenabled":false,"outputs":1,"entityType":"sensor","config":[{"property":"name","value":""},{"property":"device_class","value":""},{"property":"icon","value":""},{"property":"unit_of_measurement","value":""},{"property":"state_class","value":""},{"property":"last_reset","value":""}],"state":"payload","stateType":"msg","attributes":[],"resend":true,"outputLocation":"","outputLocationType":"none","inputOverride":"allow","outputOnStateChange":false,"outputPayload":"$entity().state ? \"on\": \"off\"","outputPayloadType":"jsonata","x":670,"y":280,"wires":[[]]},{"id":"167cc80b04eb4959","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}]

you called it. Add that condition right after the input number trigger

Thanks mate, that worked perfectly.

It’s awesome to have such a helpful community, much appreciated!!

1 Like