So I am trying to update my switch so the vacuum cleaner wont empty the bin if it has already done so:
switch:
- platform: template
switches:
stovsuge:
friendly_name: "Hermann"
value_template: "{{ is_state('vacuum.hermann', 'cleaning') }}"
turn_on:
service: vacuum.start
data:
entity_id: vacuum.hermann
turn_off:
{% if is_state('vacuum.hermann', 'cleaning') %}
service: vacuum.return_to_base
{% else %}
service: vacuum.stop
{% endif %}
data:
entity_id: vacuum.hermann
icon_template: mdi-robot-vacuum-variant
So the error is on the line where the {% if is_state is.
So this switch works great. When I active, it starts the vacuum. When I switch it off, it returns to dock and empties. But if it is already docked and emptied it will still try to empty, creating a lot of sound. So I tried to only make it return to dock if it is cleaning.
But am I using the IF incorrectly?