Making a physical switch override an automation?

I’ve got a Ring doorbell motion sensor turning my porch lights on, then turning them off again when the motion sensor resets.

That’s working ok, but if we’re expecting visitors, I’d like to be able to just flip on the switch and have the lights stay on. I’m new at this and having trouble thinking this through algorithmically.

This is what I’ve got so far, mostly generator by the Automations Editor with the Sunset condition added manually. Any help is appreciated.

[code]- action:

  • alias: light on
    data:
    entity_id: light.linear_wd500z1_wall_dimmer_switch_level_6_0
    service: light.turn_on
    alias: ring lights porch on
    id: ‘1498794958732’
    trigger:
  • entity_id: binary_sensor.ring_front_door_motion
    from: ‘off’
    platform: state
    to: ‘on’
    condition:
  • after: sunset
    condition: sun
  • action:
    • alias: light off
      data:
      entity_id: light.linear_wd500z1_wall_dimmer_switch_level_6_0
      service: light.turn_off
      alias: ring porch lights off
      id: ‘1498797313227’
      trigger:
    • entity_id: binary_sensor.ring_front_door_motion
      from: ‘on’
      platform: state
      to: ‘off’
      [/code]

I dont think conditions are supported yet.

You might try it the old fashion way.

This layout is kind of hard to follow…

Here is an example of some of my automation.

- id: b
  alias: Turn off LivingRoomLight with conditions A
  trigger:
    platform: state
    entity_id: binary_sensor.motion_44
    to: 'off'
  condition:
    condition: and
    conditions:
      - condition: time
        after: '21:00:00'
        before: '18:00:00'
      - condition: state
        entity_id: switch.living_room_light
        state: 'on'
        for:
          minutes: 5
  action:
    - service: switch.turn_off
      entity_id: switch.living_room_light
- id: c
  alias: Turn off LivingRoomLight with conditions B
  trigger:
    platform: state
    entity_id: switch.living_room_light
    to: 'on'
    for:
      minutes: 1
  condition:
    - condition: state
      entity_id: binary_sensor.motion_44
      state: 'off'
      for:
        hours: 1
  action:
    - service: switch.turn_off
      entity_id: switch.living_room_light

The conditions I’ve added seem to be working, and I agree the layout is difficult to follow. I wish the code generated by Automations Editor followed a flow similar to the examples here, but it does not.

I think you might have cracked my problem though. I’ll say “If the light isn’t on already, and motion is triggered, turn on the light for 5 minutes.” and forget trying to read the reset-state of the motion detector. Thanks!

You can also create an input_boolean to deactivate automations.

Then add 2 automations :

  • When input_boolean is on, turn off your automation for front porch light
  • When input_boolean is off, turn back on your automation

Here is an exemple

input_boolean:
  guest_mode:
    initial: off

And the automation to kill the automation (just do the opposite to turn them back on)

- alias: 'activate guest mode'
  trigger:
    - platform: state
      entity_id: input_boolean.guest_mode
      to: 'on'
  action:
    - service : automation.turn_off
      entity_id: automation.YOURAUTOMATIONFORLIGHTS

note that if you have one automation that turns on the light and then one that turns them off, you need to deactivate both (or at least the one that turns the lights off, the other one will proceed, but it won’t change a thing if your lights are already on).

The main advantage I find in this method is that you can very simply add other automations to turn_off when you have guest. For instance if your tv automatically turns on, or some lights get dimmer in the evening,… I use it a lot. My wife ‘tolerates’ home assistant, so I was obliged to be able to deactivate every automation with a single button :smiley:

5 Likes