#Introduce another sensor to the automation - binary sensor

1 messages · Page 1 of 1 (latest)

tame sonnet
#

Hi,
I have the following automation and I used Triggers in it. I learned about it from some online video.
How can I introduce Sensor6 to this automation I mean combine it with Sensor4 as a single binary sensor?

`- id: '1718231664600'
alias: Hallway_temporary_lamp
description: Turn on the entrance light upstairs
trigger:

  • type: motion
    platform: device
    device_id: b6768ec1f085ee7f1929773d33c5dae3
    entity_id: 8b35a5aea18064f332bc359c7db48840
    domain: binary_sensor
    id: MotionSensor4_Hallway_Detected
  • type: no_motion
    platform: device
    device_id: b6768ec1f085ee7f1929773d33c5dae3
    entity_id: 8b35a5aea18064f332bc359c7db48840
    domain: binary_sensor
    id: MotionSensor4_Hallway_Cleared
    for:
    hours: 0
    minutes: 6
    seconds: 0
    condition:
  • condition: sun
    before: sunrise
    after: sunset
    before_offset: -01:00:00
    after_offset: -01:00:00
    action:
  • if:
    • condition: trigger
      id:
      • MotionSensor4_Hallway_Detected
        then:
    • type: turn_on
      device_id: d1359a619afdc6b0460905931e9d3ab5
      entity_id: b8325217e48512071316c07325e9e70e
      domain: switch
      else:
    • if:
      • condition: trigger
        id:
        • MotionSensor4_Hallway_Cleared
          then:
      • type: turn_off
        device_id: d1359a619afdc6b0460905931e9d3ab5
        entity_id: b8325217e48512071316c07325e9e70e
        domain: switch
        mode: single`
dusty jacinth
#

Create a binary sensor group and add both sensors to that.

tame sonnet
#

ok, so this is what last time I put in place according to your recommendation
Entity ID: binary_sensor.hallway_sensor4and6
what do I have to do now to reflect it onto my existing automation?

dusty jacinth
#

Just use the entity of the group (it'll be whatever you named it: binary_sensor.hallway_sensor4and6). (duh you did put that in the message lol)

tame sonnet
#

ok so chuck the existing triggers away and specify:
When: Hallway_Sensors4and6
From (optional): Off
To (options): On
And if
Then do
....
Else
....

dusty jacinth
#

Yup. Pretty much 🙂

tame sonnet
#

I think this is correct:
mode: single
`- id: '1718231664600'
alias: Hallway_temporary_lamp
description: Turn on the entrance light from upstairs
triggers:

  • trigger: state
    entity_id:
    • binary_sensor.hallway_bathroom_sensor4and6
      from: 'off'
      to: 'on'
      conditions:
  • condition: sun
    before: sunrise
    after: sunset
    before_offset: -01:00:00
    after_offset: -01:00:00
    actions:
  • if:
    • condition: state
      entity_id: binary_sensor.hallway_bathroom_sensor4and6
      state: 'off'
      then:
    • type: turn_on
      device_id: d1359a619afdc6b0460905931e9d3ab5
      entity_id: b8325217e48512071316c07325e9e70e
      domain: switch
      else:
    • if:
      • condition: state
        entity_id: binary_sensor.hallway_bathroom_sensor4and6
        state: 'on'
        for:
        hours: 0
        minutes: 6
        seconds: 0
        then:
      • type: turn_off
        device_id: d1359a619afdc6b0460905931e9d3ab5
        entity_id: b8325217e48512071316c07325e9e70e
        domain: switch`
#

with the triggers I had this "Cleared" thing

#

I think it does not make sense, before I had two triggers
it's easier to make changes in the code than making changes from the editor

#

what I did would make it stay on forever

dusty jacinth
#

It does make sense. You need to have 2 triggers: one from off to on and another for on to off.

#

Give me a few and I’ll throw up something cleaner.

tame sonnet
#

once I have the above do I need to tweak the "Then do" conditional statements?

dusty jacinth
#
description: ""
mode: restart
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.hallway_motion_sensor_occupancy
    from: "on"
    to: "off"
    id: motion_off
    for:
      hours: 0
      minutes: 6
      seconds: 0
  - trigger: state
    entity_id:
      - binary_sensor.hallway_motion_sensor_occupancy
    from: "off"
    to: "on"
    id: motion_on
    for:
      hours: 0
      minutes: 0
      seconds: 0
conditions:
  - condition: sun
      after: sunset
      before: sunrise
      before_offset: "1:00:00"
      after_offset: "1:00:00"
actions:
  - if:
      - condition: trigger
        id:
          - motion_on
    then:
      - action: light.turn_on
        data: {}
        target:
          entity_id: light.hallway_light_1
    else:
      - action: light.turn_off
        data: {}
        target:
          entity_id: light.hallway_light_1
tame sonnet
#

ok, where do I define the actions?
light.turn_on, light.turn_off
in my case it's a plug so plug.switch_on/off

dusty jacinth
#

Change light to switch. Should work the same way.

tame sonnet
#
  • id: '1718231664600'
    alias: Hallway_temporary_lamp
    description: X
    mode: restart
    triggers:
    • trigger: state
      entity_id:
      • binary_sensor.hallway_bathroom_sensor4and6
        from: "on"
        to: "off"
        id: motion_off
        for:
        hours: 0
        minutes: 6
        seconds: 0
    • trigger: state
      entity_id:
      • binary_sensor.hallway_bathroom_sensor4and6
        from: "off"
        to: "on"
        id: motion_on
        for:
        hours: 0
        minutes: 0
        seconds: 0
        conditions:
    • condition: sun
      after: sunset
      before: sunrise
      before_offset: "1:00:00"
      after_offset: "1:00:00"
      actions:
    • if:
      • condition: trigger
        id:
        • motion_on
          then:
      • action: switch.turn_on
        data: {}
        target:
        device_id: d1359a619afdc6b0460905931e9d3ab5
        entity_id: b8325217e48512071316c07325e9e70e
        else:
      • action: switch.turn_off
        data: {}
        target:
        device_id: d1359a619afdc6b0460905931e9d3ab5
        entity_id: b8325217e48512071316c07325e9e70e
tame sonnet
#

I got some configuration warnings that will not prevent HA from starting

Integration error: triggers - Integration 'triggers' not found
same for 'actions'

#

I think these are not related, it looks like the group binary sensor works
thank you very much

dusty jacinth
tame sonnet
#

I have upgraded to the latest very recently

dusty jacinth
#

Can you reformat your YML properly? It's hard to tell what you have there.