I have set up a template fan based on a switch entity and in the value template I use:
value_template: "{{ states('switch.office_fan') }}"
All works OK but if the fan is unplugged I get:
Received invalid fan is_on state: unavailable. Expected: on, off.
I tried
value_template: "{{ is_state('switch.office_fan', 'on') }}"
but get an error something like:
Received invalid fan is_on state: true or false. Expected: on, off.
Is there a way to catch the unavailable error ?