Hey fellow “homeassistant” I am since a while ago, a bit confused.
I thought I have enough experience to do whatever I want with Home Assistant but I gave up and I’m asking YOUR help!
That’s where I couldn’t reach the result I wish:
My script:
Read a sensor who contains attributes such:
warning_count: (int)
warning_(an int from 1 to warning_count)_type: (int)
example:
warning_count: 2
warning_1_type: 21
warning_2_type: 81
Now I thought I will use the repeat service, steps: warning count and do the following:
repeat:
count: >-
{{ state_attr('sensor.wetter_warnung_current_warning_level','warning_count')
}}
sequence:
- choose:
- conditions:
- condition: template
value_template: >-
'{ {((state_attr("sensor.wetter_warnung_current_warning_level","warning_"+repeat.index+"_type")
> 21)) }}'
sequence:
- service: input_text.set_value
data:
value: '{{states("input_text.wetter_warnung")}}, Snow'
entity_id: input_text.wetter_warnung
I only included one condition to short-down the code, but you got the point.
So, if I have a warning_count: 2
and I replace the +repeat.index+
with 1 I got as expected two times “Snow” in the input_text.wetter_warnung
.
So how can I use the repeat.index
variable in the middle of warning__type attribute?
Thank you very much for your precious time!