home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.82k stars 30.51k forks source link

template fan cannot handle unavailable state #31170

Closed thomasdelaet closed 4 years ago

thomasdelaet commented 4 years ago

The problem

The template fan platform does not know how to deal with unavailable state.

Environment

Problem-relevant configuration.yaml

    ventilation:
      friendly_name: Ventilation
      value_template: "{{ states('switch.fan_low') }}"
      speed_template: "
        {% if is_state('switch.fan_low', 'on') %}
          {% if is_state('switch.fan_medium', 'on') %}
            medium
          {% elif is_state('switch.fan_high', 'on') %}
            high
          {% else %}
            low
          {% endif %}
        {% else %}
          off
        {% endif %}
      "
      turn_on:
          - service: switch.turn_on
            entity_id: switch.fan_low
      turn_off:
          - service: switch.turn_off
            entity_id: switch.fan_low
      set_speed:
          - service_template: "{% if speed == 'off' %} switch.turn_off {% else %} switch.turn_on {% endif %}"
            entity_id: switch.fan_low
          - service_template: "{% if speed == 'medium' %} switch.turn_on {% else %} switch.turn_off {% endif %}"
            entity_id: switch.fan_medium
          - service_template: "{% if speed == 'high' %} switch.turn_on {% else %} switch.turn_off {% endif %}"
            entity_id: switch.fan_high
      speeds:
        - 'off'
        - 'low'
        - 'medium'
        - 'high'

Traceback/Error logs

2020-01-26 01:08:50 ERROR (MainThread) [homeassistant.components.template.fan] Received invalid fan is_on state: unavailable. Expected: on, off.

Additional information

I think this might be as simple as allowing the unavailable state.

probot-home-assistant[bot] commented 4 years ago

Hey there @PhracturedBlue, @tetienne, mind taking a look at this issue as its been labeled with a integration (template) you are listed as a codeowner for? Thanks!

tayanov commented 4 years ago

for light template i have it is warning too

stale[bot] commented 4 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

thomasdelaet commented 4 years ago

This is still relevant since PR is not merged yet

cybergrimes commented 4 years ago

I'm seeing this also during startup. My fan is a template from a Z-Wave switch (new Inovelli fan/light combo switch), so it makes sense that it is unavailable while waiting for Z-Wave network to start.