4 hours ago I started what I expected to be a straightforward UI button in lovelace. The button when tapped should toggle the HVAC fan on or off (obviously the opposite of the current state). This climate system doesn’t have a toggle on the fan it only responds to climate.set_fan_mode
with value on / off
.
I expected that a template switch was what I wanted. Alas, I now understand that this doesn’t execute different sections of code depending on the template value. I’m basically looking for a stupid dumb simple if then else statement I think. Some awful pseudo code now:
if fan == on then turn it off
else if fan == off then turn it on
I have the value extracted nicely using a template and can access the attribute I want with
{{ states.climate.upstairs.attributes['fan_state'] }}
You can see the data structure returned here - https://imgur.com/a/odb7BlO. Note I have been flipping around between fan_mode
and fan_state
all evening but I’m happy with the current state of the value_template using fan_state
which returns 1 or 0.
I’m getting a bit tired I suppose but it’d be great to have someone weigh in with the correct solution here. I think what I want is a switch that when toggled sets the climate.set_fan_mode
to the opposite value of what it was, also reading in the current value of the fan if Home Assistant restarts to ensure we don’t get out of sync.
Thanks in advance.