I’ve been trying to make this template trigger whenever I set its state to unavailable
but it does not trigger.
{% if trigger.id == "availability" %}
and {% elif trigger.idx == 3 %}
doing same thing, but neither work.
States on
and off
works well. Tried removing availability
section but it didn’t help.
Am I wrong somewhere or it can be a bug?
- trigger:
- platform: homeassistant
event: start
- platform: state
entity_id: binary_sensor.bath_motion_sensor
from: "on"
to: "off"
for: "00:01:00"
- platform: state
entity_id: binary_sensor.bath_motion_sensor
from: "off"
to: "on"
- platform: state
entity_id: binary_sensor.bath_motion_sensor
to: "unavailable"
id: "availability"
binary_sensor:
- unique_id: bath_motion_sensor_template
name: "Bath motion sensor"
device_class: motion
state: >
{% if trigger.id == "availability" %}
unavailable
{% elif trigger.idx == 1 %}
off
{% elif trigger.idx == 2 %}
on
{% elif trigger.idx == 3 %}
unavailable
{% else %}
{% if is_state('binary_sensor.bath_motion_sensor', 'on') %}
on
{% else %}
off
{% endif %}
{% endif %}
icon: mdi:shower
availability: >
{% if states.binary_sensor.bath_motion_sensor and not is_state('binary_sensor.bath_motion_sensor', 'unavailable') %}
True
{% endif %}