Manual vs Automation of switching lights ON/OFF

No it doesn’t. It only turns off if there is no motion for 3 minutes. If there was more motion after 2 minutes and 59 seconds that automation would not trigger.

Your automation just turns off the light straight away with no grace period, which is often undesirable as you will come to see when your automation regularly leaves you in the dark.

No because his turn-off routine does not work based on the motion sensor, but it’s based on the input.boolean. So if ‘input.boolean’ ‘on’ after 3 minutes the ‘light is off’.

:roll_eyes:

The entity_id is irrelevant, it’s the ‘for:’ statement that causes the system to wait until the state has been the same for a certain amount of time.

I know what “for” is for. But his always shuts off 3 minutes after turning on the Motion Sensor, no matter if someone is still moving there, but if I (for your sake) put “for: 3 minutes” in it, mine will turn off 3 minutes after the Motion Sensor is off. I tried it with ‘for: 10 seconds’ and the Motion Sensor was still active but the light went off.

Then something else is wrong with your configuration.

Hello all, I want to start by telling you that I am new to HA and this is my first automation.

Let me tell you about the setup, I have a bathroom windows that is actioned by a motor, with 2 relays. Relay1 ON, Relay2 OFF the window will open, Relay1 OFF, Relay2 ON windows will close, Relay1 ON and Relay2 ON windows stops (also used for close/open position).

What do I want to achieve is a way to prevent the automation to run multiple times when the trigger value is above the value configured using input_bolean.

Here is the open automation:

alias: Bathroom window open
description: open bathroom windows
trigger:
  - platform: numeric_state
    entity_id: sensor.bathroom1_si7021_humidity
    for: '00:01:00'
    above: '50'
condition:
  - condition: state
    entity_id: input_boolean.bathroom_manual
    state: 'off'
action:
  - type: turn_on
    device_id: 030eab3206bc4ddcf775ca7b0497500e
    entity_id: switch.bathroom1_2
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 4
      milliseconds: 500
  - type: turn_off
    device_id: 030eab3206bc4ddcf775ca7b0497500e
    entity_id: switch.bathroom1_2
    domain: switch
  - service: input_boolean.turn_on
    target:
      entity_id: input_boolean.bathroom_window
mode: single

Here is the close automation:

alias: Bathroom window close
description: close bathroom window
trigger:
  - platform: numeric_state
    entity_id: sensor.bathroom1_si7021_humidity
    for: '00:10:00'
    below: '40'
condition: []
action:
  - type: turn_on
    device_id: 030eab3206bc4ddcf775ca7b0497500e
    entity_id: switch.bathroom1
    domain: switch
  - delay:
      hours: 0
      minutes: 0
      seconds: 12
      milliseconds: 0
  - type: turn_off
    device_id: 030eab3206bc4ddcf775ca7b0497500e
    entity_id: switch.bathroom1
    domain: switch
  - service: input_boolean.turn_off
    target:
      entity_id:
        - input_boolean.bathroom_window
        - input_boolean.bathroom_manual
mode: single

The problem is that when the condition is set, the automation is not triggered any more, regardless the state of input_boolean.bathroom_manual state, on or off.

I figured I’d throw this out there if anyone stumbles upon this thread like me looking for a solution to this issue. I had a similar problem where I have a light switch in our bathroom that I wanted to be able to “override” motion control from when I wanted. Since this switch is z-wave based I was able to use the z-wave event to accomplish this control.

I always have modes and then actions for my automations so in my mode automation I flip the status of an input select to my desired value:

initial_state: "on"
alias: Master ensuite motion
trigger:
  - platform: state
    entity_id: binary_sensor.master_bedroom_ensuite_sensor_motion
    to: "on"
condition:
  - condition: template
    value_template: "{{ states('input_select.master_ensuite') not in ('On') }}"
action:
  - service: input_select.select_option
    data:
      entity_id: input_select.master_ensuite
      option: Motion
mode: single

This would trigger my lighting motion automation. Which looks like this:

initial_state: "on"
alias: "Master ensuite lights motion"
trigger:
  - platform: state
    entity_id: input_select.master_ensuite
    to: "Motion"
condition:
  - condition: state
    entity_id: input_boolean.lighting_automations
    state: "on"
action:
  - service: light.turn_on
    data:
      transition: 10
      brightness_pct: 50
    entity_id:
      - light.master_ensuite_shower_light_dimmer

I then setup an “On” mode with the following:

id: master_ensuite_on
initial_state: "on"
alias: Master ensuite on
trigger:
  - platform: event
    event_type: zwave_js_value_notification
    event_data:
      value: KeyPressed
      property_key_name: "001"
      node_id: 19
action:
  - service: input_select.select_option
    data:
      entity_id: input_select.master_ensuite
      option: "On"
mode: single

Here I’m listening for the zwave_js event notification from my switch and using that to then set the input_select to “On” which overrides my “Motion” value allowing anyone to manually take over control of the light.

Any way hope this helps anyone who has this same problem in the future and stumbles upon this thread.

FWIW, that’s the usual way to handle the situation assuming the device reports its button events.

Given a device that does not report its button events, the fallback is to monitor its brightness attribute but only if it’s a dimmer. For a switch, the only recourse is to adopt some less-than-natural behavior like turning off the switch then turning it back on immediately to serve as a signal that the user wants to override the automatic-off feature.

Lastly, it’s possible to consolidate your three automations into one (but it’s purely optional).