Hi,
Long time HA user, but first time I’ve needed to make a call for help, having exhausted my search capabilities in the forum!. Recently purchased some gs-wds07 sensors (433mhz with Open and Closed state).
I’ve added these into HA as separate binary sensors, then I’m trying to use another binary sensor to determine the overall state (Open or Closed).
Whilst both the Rear Door Open and Rear Door Closed binary sensors update their state correctly when the door sensor is activated, the overall Rear Door Status binary sensor never changes from ‘off’.
The config I’m using for this is below. Is there something obvious that I’m not getting right?
binary_sensor:
- platform: rflink
devices:
rear_door_open:
name: Rear door open
off_delay: 1
aliases:
- ev1527_05af90_0a
- selectplus_0506f5_02
rear_door_closed:
name: Rear door closed
off_delay: 1
aliases:
- ev1527_05af90_0e
- selectplus_0506f1_02
- platform: template
sensors:
rear_door:
friendly_name: Rear door status
entity_id:
- binary_sensor.rear_door_open
- binary_sensor.rear_door_closed
value_template: >-
{% if is_state('binary_sensor.rear_door_open', 'on') %}
on
{% elif is_state('binary_sensor.rear_door_closed', 'on') %}
off
{% endif %}
A bit more trial and error, and I’ve made some changes as below. Mainly changing the value_template to true/false where it was previously on/off.
Now the Rear Door Status sensor reacts to actions from the Open and Closed sensors. However this works fine when I open the door, and when I close it. However on closing it the 'Rear door open` sensor stays on - thus subsequent open and close actions don’t update the Rear Door Status. I’m guessing I need an action to force the ‘Rear Door Open’ to off when ‘Rear Door Closed’ is on. Can this be actioned from within the template sensor?
binary_sensor:
- platform: rflink
devices:
rear_door_open:
name: Rear door open
aliases:
- ev1527_05af90_0a
- selectplus_0506f5_02
rear_door_closed:
name: Rear door closed
aliases:
- ev1527_05af90_0e
- selectplus_0506f1_02
- platform: template
sensors:
rear_door:
friendly_name: Rear door status
value_template: >-
{% if is_state("binary_sensor.rear_door_closed", "on") %}
false
{% elif is_state("binary_sensor.rear_door_open", "on") %}
true
{% endif %}
device_class: door
For anyone else having the same issues as me, I hope this will be of some help. Adding an off_delay to ‘reset’ the Open and Closed sensors after 1 second, and a further ‘else’ in the value_template to pick up the current state of the overall Rear Door Status has resolved the issue for me.
- platform: rflink
devices:
rear_door_open:
name: Rear door open
off_delay: 1
aliases:
- ev1527_05af90_0a
- selectplus_0506f5_02
rear_door_closed:
name: Rear door closed
off_delay: 1
aliases:
- ev1527_05af90_0e
- selectplus_0506f1_02
- platform: template
sensors:
rear_door:
friendly_name: Rear door status
value_template: >-
{% if is_state("binary_sensor.rear_door_open", "on") %}
true
{% elif is_state("binary_sensor.rear_door_closed", "on") %}
false
{% else %}
{{ is_state("binary_sensor.rear_door") }}
{% endif %}
device_class: door
This worked for me, I was using other names for the sensor but the template sensor wasn’t working. So I just copied your code without changing anything but the sensor aliases and it is working fine. Probably I had some typo… For now my sensor will be called “rear_door” also!
Hi, since update 0.115 my template sensor is no longer working : it sticks to the previous state (open or closed) although the binary sensors are working fine (door open or closed) and I can manually update the template state.
here is my setup for sensors and template in my binary_sensors.yaml file:
- platform: rflink
devices:
porte_salon_ouverte:
name: Porte Salon ouverte
off_delay: 1
aliases:
- ev1527_01e76a_0e
porte_salon_fermee:
name: Porte Salon fermée
off_delay: 1
aliases:
- ev1527_01e76a_07
- platform: template
sensors:
porte_salon:
friendly_name: Statut porte Salon
value_template: >-
{% if is_state("binary_sensor.porte_salon_ouverte", "on") %}
true
{% elif is_state("binary_sensor.porte_salon_fermee", "on") %}
false
{% else %}
{{ is_state("binary_sensor.rear_door") }}
{% endif %}
device_class: door
I went through the release notes several times without really getting how templates were affected in my case. Template is one of my (multiple) weak points
Little bit late to the discussion here, however I recently upgraded my version of Home Assistant and also faced the same issue. Tried a few different things but in the end I ‘fixed’ it using node-red, which tbh I’ve been migrating a lot of my more complex automations into over the past few months.
I replaced the template sensor with this
- platform: mqtt
name: Front door
state_topic: "homeassistant/external_sensors/front_door_status"
device_class: door
Then in node-red simply send an ‘ON’ or ‘OFF’ payload to the MQTT topic based when the respective door_open or door_closed sensor triggers on.
HI all,
I wake up this thread, I need your help…
The binary sensor created with this template no stay with le last state. he auto off.
In fact, the door no stay open more than 1 seconde. I try to delete the off_delay of the device, but no succes.
here is my config:
binary_sensor:
- platform: rflink
devices:
baie_vitree_salon_ouverte:
name: Baie vitrée salon ouverte
off_delay: 1
aliases:
- ev1527_023b32_06
baie_vitree_salon_fermee:
name: Baie vitrée salon fermée
off_delay: 1
aliases:
- ev1527_023b32_09
- platform: template
sensors:
baie_vitree_salon:
friendly_name: Statut baie vitrée salon
value_template: >-
{% if is_state("binary_sensor.baie_vitree_salon_ouverte_2", "on") %}
true
{% elif is_state("binary_sensor.baie_vitree_salon_fermee_3", "on") %}
false
{% else %}
{{ is_state("binary_sensor.baie_vitree_salon", "on") }}
{% endif %}
device_class: door