Addressing array index

I’m running across a scenario trying to access an array index, and something does not work as I need to.

I am wondering if someone can check my code and see what the problem is
TYA

{% set test_var = ['00','01','11','10'] %}
{{states('counter.aly_bed_swtich_count')}} / this outputs 1 correctly
{{test_var[2]}} //this outputs 11 correctly
{{test_var[states('counter.aly_bed_swtich_count')]}} // this outputs nothing, vs expected 01
{{test_var[states('counter.aly_bed_swtich_count')|int(0)]}}

You have to convert the entity’s state value from string to integer.

It works, thanks.
I thought I tried that, but most likely my syntax was wrong.

1 Like