Binary sensor base on state of other binary sensors - 433mhz Rflink

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 %}

Thanks!

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

Thanks again :smiley:

Sorted, I got there in the end! :smiley:

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