I’m trying ot create a ‘counter’ script. The script gets passed a counter entity, a value ‘up’ or ‘down’ and a delay to set the counting speed.
I’m having trouble getting it to trigger however. It seems that the templates that compare the state of count_up_or_down are never set to true.
Any help is welcome, below is the full yaml:
counter:
alias: Counter
mode: parallel
icon: mdi:counter
fields:
counter:
name: Counter
description: The counter entity you want to manipulate
selector:
target:
entity:
domain: counter
required: true
count_up_or_down:
name: Count up or down
description: Do you want to count up or down?
selector:
select:
mode: dropdown
options:
- up
- down
required: true
counting_speed:
name: Counting speed
description: How much time between each counting step
selector:
duration:
required: true
sequence:
- choose:
- conditions:
- condition: template
value_template: "{{ is_state('count_up_or_down', 'up') }}"
sequence:
- repeat:
until:
- condition: template
value_template: "{{ states(counter) == state_attr('counter', 'maximum')}}"
sequence:
- service: counter.increment
data: {}
target: "{{ counter }}"
- delay: "{{ counting_speed }}"
- conditions:
- condition: template
value_template: "{{ is_state('count_up_or_down', 'down') }}"
sequence:
- repeat:
until:
- condition: template
value_template: "{{ states(counter) == state_attr('counter', 'maximum')}}"
sequence:
- service: counter.decrement
data: {}
target: "{{ counter }}"
- delay: "{{ counting_speed }}"