Bluscream
(Bluscream)
January 10, 2023, 7:13pm
1
I would like to request a UI way to define Fallback devices in case a device/entity becomes “unavailable”. Then it goes through its internal list and “replaces itself” without actually replacing anything in the background with the first fallback device listed, that is available.
Basically this:
Bluscream
(Bluscream)
February 10, 2023, 6:07am
2
I case someone wants it; here’s a fallback light template for a light with a third simple switch fallback:
src: https://github.com/Bluscream/homeassistant-config/blob/main/light/ceiling_light.yaml
- platform: template
lights:
ceiling_light:
unique_id: ceiling_light
friendly_name: "Ceiling Light"
icon_template: "mdi:ceiling-light"
value_template: >
{% if not is_state('light.ceiling_light_local', 'unavailable') %}{{states('light.ceiling_light_local')}}
{% elif not is_state('light.ceiling_light_cloud', 'unavailable') %}{{states('light.ceiling_light_cloud')}}
{% else %}{{states('switch.smart_ceiling_lamp_relay')}}
{% endif %}
turn_on:
- service: switch.turn_on
target:
entity_id: switch.smart_ceiling_lamp_relay
- service: light.turn_on
target:
entity_id: "{{ 'light.ceiling_light_local' if not is_state('light.ceiling_light_local', 'unavailable') else 'light.ceiling_light_cloud'}}"
turn_off:
- service: >
{% if not is_state('light.ceiling_light_local', 'unavailable') %}light.turn_off
{% elif not is_state('light.ceiling_light_cloud', 'unavailable') %}light.turn_off
{% else %}switch.turn_off
{% endif %}
target:
entity_id: >
{% if not is_state('light.ceiling_light_local', 'unavailable') %}light.ceiling_light_local
{% elif not is_state('light.ceiling_light_cloud', 'unavailable') %}light.ceiling_light_cloud
{% else %}switch.smart_ceiling_lamp_relay
{% endif %}
set_level:
service: light.turn_on
data_template:
entity_id: "{{ 'light.ceiling_light_local' if not is_state('light.ceiling_light_local', 'unavailable') else 'light.ceiling_light_cloud' }}"
brightness: "{{ brightness }}"
set_temperature:
service: light.turn_on
data_template:
entity_id: "{{ 'light.ceiling_light_local' if not is_state('light.ceiling_light_local', 'unavailable') else 'light.ceiling_light_cloud' }}"
color_temp: "{{ color_temp }}"
set_color:
service: light.turn_on
data_template:
entity_id: "{{ 'light.ceiling_light_local' if not is_state('light.ceiling_light_local', 'unavailable') else 'light.ceiling_light_cloud' }}"
hs_color:
- "{{ h }}"
- "{{ s }}"
supports_transition_template: false
Bluscream
(Bluscream)
February 10, 2023, 6:12am
3
Here’s one for a single fallback fan:
src: https://github.com/Bluscream/homeassistant-config/blob/main/fan/ventilator.yaml
- platform: template
fans:
ventilator:
unique_id: ventilator
friendly_name: "Ventilator"
# icon_template: "mdi:fan"
value_template: "{{ states('switch.fan_socket_local') if not is_state('switch.fan_socket_local', 'unavailable') else states('switch.fan_socket_cloud') }}"
percentage_template: 100
turn_on:
- service: switch.turn_on
target:
entity_id: "{{ 'switch.fan_socket_local' if not is_state('switch.fan_socket_local', 'unavailable') else 'switch.fan_socket_cloud'}}"
turn_off:
- service: switch.turn_off
target:
entity_id: "{{ 'switch.fan_socket_local' if not is_state('switch.fan_socket_local', 'unavailable') else 'switch.fan_socket_cloud' }}"