I have an automation that reads minutes from an input_number and will run for that long. That works perfectly but I would like to also know how long the automaton has remaining to display. I attempted the automation below so that when the first automation is triggered, it will start a second automation. The second automaton should read the value from the same input_number, set the value of an counter and then every minute decrement that value to show time remaining. Everything works except the way this is written, it will reload the input_number every minute it runs. I know I can enable and disable an automation but is it possible to enable and disable the service: counter.set_value so it only runs 1 time while this automation is active?
alias: Automation Run Minutes Remaining
description: ""
trigger:
- platform: time_pattern
minutes: /1
enabled: false
condition:
- condition: numeric_state
entity_id: counter.counter
above: 0
- condition: template
value_template: " {{ (as_timestamp(now()) - as_timestamp(states.input_button.active_test_button.last_updated))/60 < 2 }}"
action:
- service: counter.set_value
data_template:
entity_id: counter.counter
value: >-
{{ states('input_number.timed_toggle_time_input_fan') | int
}}
- service: counter.decrement
data: {}
target:
entity_id: counter.counter
enabled: true
mode: single