Hello, could somebody let me know why is not working the following automation?
I just want a lamp to be switch on when a combination of door/windows are closed, but it does not work and I can’t figure out what is the problem.
This is the automation:
alias: Lampara Auto On con Ventanas
description: ''
trigger:
- platform: state
entity_id: sensor.cierres_casa_contact
to: 'off'
from: 'on'
condition: []
action:
- type: turn_on
device_id: add6e2a654b14e9fce3f7e6319224b0c
entity_id: switch.lampara_salon_2
domain: switch
mode: single
while the custom sensor, which is correctly working, is the following one:
cierres_casa_contact:
friendly_name: "Cierres de Casa"
value_template: >-
{% if is_state('binary_sensor.puerta_terraza_contact', 'off') and is_state('binary_sensor.ventana_despacho_contact', 'off')
and is_state('binary_sensor.ventana_dormitorio_contact', 'off') and is_state('binary_sensor.ventana_habitacion_contact', 'off') and is_state('binary_sensor.ventana_vestidor_contact', 'off') and is_state('binary_sensor.puerta_cocina_contact', 'off') %}
Off
{% elif is_state('binary_sensor.puerta_terraza_contact', 'off') and is_state('binary_sensor.ventana_despacho_contact', 'off')
and is_state('binary_sensor.ventana_dormitorio_contact', 'off') and is_state('binary_sensor.ventana_habitacion_contact', 'off') and is_state('binary_sensor.ventana_vestidor_contact', 'off') and is_state('binary_sensor.puerta_lavadero_contact', 'off') %}
Off
{% elif is_state('binary_sensor.puerta_terraza_contact', 'off') and is_state('binary_sensor.ventana_despacho_contact', 'off')
and is_state('binary_sensor.ventana_dormitorio_contact', 'off') and is_state('binary_sensor.ventana_habitacion_contact', 'off') and is_state('binary_sensor.ventana_vestidor_contact', 'off') and is_state('binary_sensor.ventana_lavadero_contact', 'off') %}
Off
{% else %}
On
{% endif %}
Many thanks in advance