Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 106468

Binary_sensor state based on two other binary_sensors

$
0
0

Hello,

I want to create a binary_sensor that is set to on when two other binary_sensors change from off to on (and condition) and is set to off when the same two binary_sensors change from on to off (also and condition).

Currently I do it with a couple automations and an input_boolean helper, which is set to on or off based on state of the two binary_sensors, and then the binary_sensor changes it state based on the state of the input_boolean.

Is there a way of doing if without the helper? I know that triggers may be used in sensors and binary_sensors, but I don’t get to replicate the desired behaviour.

input_boolean:
  movimiento_piso

automation:
  - id: alarma_movimiento_piso_on
    alias: Alarma:Movimiento piso on
    description: ''
    trigger:
      - platform: state
        entity_id: binary_sensor.sonoff_a480019e03
        from: 'off'
        to: 'on'
      - platform: state
        entity_id: binary_sensor.sonoff_a480028dba
        from: 'off'
        to: 'on'
    condition:
      - condition: and
        conditions:
          - condition: state
            entity_id: binary_sensor.sonoff_a480019e03
            state: 'on'
          - condition: state
            entity_id: binary_sensor.sonoff_a480028dba
            state: 'on'
    action:
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.movimiento_piso
    mode: single
 
  - id: alarma_movimiento_piso_off
    alias: Alarma:Movimiento piso off
    description: ''
    trigger:
      - platform: state
        entity_id: binary_sensor.sonoff_a480019e03
        from: 'on'
        to: 'off'
      - platform: state
        entity_id: binary_sensor.sonoff_a480028dba
        from: 'on'
        to: 'off'
    condition:
      - condition: and
        conditions:
          - condition: state
            entity_id: binary_sensor.sonoff_a480019e03
            state: 'off'
          - condition: state
            entity_id: binary_sensor.sonoff_a480028dba
            state: 'off'
    action:
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.movimiento_piso
    mode: single

binary_sensor:
  - platform: template
    sensors:      
      movimiento_piso:
        friendly_name: Sensor Movimiento piso
        device_class: motion
        value_template: "{{ is_state('input_boolean.movimiento_piso', 'on') }}"

Thank you!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 106468

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>