#adding 'latching' behaviour to a motion controlled light

1 messages · Page 1 of 1 (latest)

agile raptor
#

here is my exisitng yaml

alias: Rear Driveway Light
description: ""
triggers:
  - entity_id: sensor.sonoff_10023cecd4_action
    to: single
    trigger: state
  - entity_id:
      - binary_sensor.0x00158d008b118175_occupancy
    trigger: state
    to: "on"
  - trigger: state
    entity_id:
      - binary_sensor.0x00158d008b118175_occupancy
    to: "off"
    for:
      hours: 0
      minutes: 2
      seconds: 0
  - at: "00:00:00"
    trigger: time
  - trigger: sun
    event: sunrise
    offset: 0
conditions: []
actions:
  - choose:
      - conditions:
          - condition: state
            state: "on"
            entity_id: binary_sensor.0x00158d008b118175_occupancy
          - condition: sun
            before: sunrise
            after: sunset
        sequence:
          - target:
              entity_id: switch.sonoff_10023cecd4_1
            action: switch.turn_on
            data: {}
      - conditions:
          - condition: state
            entity_id: binary_sensor.0x00158d008b118175_occupancy
            state: "off"
        sequence:
          - target:
              entity_id: switch.sonoff_10023cecd4_1
            action: switch.turn_off
            data: {}
      - conditions:
          - condition: state
            entity_id: sensor.sonoff_10023cecd4_action
            state: single
        sequence:
          - target:
              entity_id: switch.sonoff_10023cecd4_1
            action: switch.toggle
            data: {}
      - conditions:
          - condition: time
            after: "23:58:00"
            before: "07:00:00"
        sequence:
          - target:
              entity_id: switch.sonoff_10023cecd4_1
            action: switch.turn_off
            data: {}
mode: single
```
agile raptor
#

hmm,

I guess i could have a and if boolean is 0

and then have a seperate automation that if the light is switch, toggle light and set helper to 1, and reset helper at sunup -1 minute

agile raptor
#

Ok, I think this will work

The first automation is relatively unchanged, except it checks the state of a boolean, if false it proceeds like normal

I've added this as a second automation

alias: Rear door switch
description: ""
triggers:
  - trigger: state
    entity_id:
      - sensor.sonoff_10023cecd4_action
    to: single
conditions: []
actions:
  - action: switch.toggle
    metadata: {}
    data: {}
    target:
      entity_id: switch.sonoff_10023cecd4_1
  - action: input_boolean.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.rear_door_light_toggle
  - wait_for_trigger:
      - trigger: sun
        event: sunrise
        offset: 0
  - action: input_boolean.turn_off
    metadata: {}
    data: {}
    target:
      entity_id: input_boolean.rear_door_light_toggle
mode: single
#

I'd love to have this combined into a single automation... But that's a challange for next time

Think I can do it via building blocks