This code in configuration.yaml
shell_command:
send_ifeel: |
{% set nst = namespace(temp = state_attr('climate.neviweb130_climate_salon', 'current_temperature')|int(20)) %}
{% set nsl = namespace(list=[]) %}
{% for bit in range(0, 8) %} {% set nsl.list = nsl.list + ["630", (nst.temp / 2**bit) | int | bitwise_and(1) | iif ("1680","550")] %}{% endfor %}
wget --spider -q http://192.168.2.175/cm?cmnd='IRSend 0,5980,3015,{{ nsl.list | join(",")}},630,1680,630,580,630,1680,630,580,630,580,630,1680,630,580,630,1680,630'
Works while running it in the Developer tools - Template. It outputs, as expected
wget --spider -q http://192.168.2.175/cm?cmnd='IRSend 0,5980,3015,630,550,630,1680,630,550,630,550,630,1680,630,550,630,550,630,550,630,1680,630,580,630,1680,630,580,630,580,630,1680,630,580,630,1680,630'
But after restarting Home Assistant (so the entry in configuration.yaml takes effect), running it with Developer tools - Action
action: shell_command.send_ifeel
data: {}
It gives
Failed to perform the action shell_command.send_ifeel. UndefinedError: 'nst' is undefined
I don’t know what I’m doing wrong. At first, temp wasn’t inside a namespace keyword (although it didn’t need one in the Developer tools - Template) and I got the same error but for ‘temp’ instead of ‘nst’, so I added the namespace keyword, just in case, but it still doesn’t want to run. I’m at lost at why it gives this error.
PS. Yes, I do plan on changing this to a mqtt statement but for now, I just want to get it to work.
Thanks.