How to turn off in Automation with an Switch

Hello,

I’m very new to the HA Universe and trying my best to get this stuff working.
I’ve got a problem, I assume the solution is very easy, but I can’t find it out.

My hallway lights turn on with a P1 and a Light Sensor, but I would like to have a switch that turns on the lights for 30 Minutes, when I’m cleaning. The Switch works, the problem is that the automations with the P1 still triggers so, if it doesn’t sense motion the light switch of after 30 seconds.

Is there a way that if i activate the switch, that the automation for my lights doesn’t trigger for 30 minutes?

Thanks!

I am not 100% sure what you mean with P1 and whicht switch you mean so please correct me if my assumptions are wrong.

I assume you have an automation for the light sensir which triggers the light on an off - maybe the same with th switch

You cloud add an additional helper (input_boolean) to determine how you turned on the light.

Note you need to define the helper under Settings → Integrations first

In the example below I have three triggers

  1. Motion detected
  2. Motion NOT detected for 5 mintues
  3. State of the light switch

every time one of these triggers the automation has three differen options

Option 1.
Motion detected & light value lux < 40 → turn on light

Option 2
No motion detected AND helper turned OFF → turn off light

Option 3
Switch for light triggered → Switch helper to ON - wait 30 minutes - turn helper OFF

Can be hard to read

Example:

alias: Bad_Lampe
description: ""
trigger:
  - type: motion
    platform: device
    entity_id: binary_sensor.bad_bewegung_occupancy
    domain: binary_sensor
    id: Bad-Ein
  - type: no_motion
    platform: device
    entity_id: binary_sensor.bad_bewegung_occupancy
    domain: binary_sensor
    id: Bad-Aus
    for:
      hours: 0
      minutes: 5
      seconds: 0
  - platform: state
    entity_id:
      - switch.light
    to: "on"
    id: Switched_on
condition: []
action:
  - choose:
      - conditions:
          - condition: trigger
            id: Bad-Ein
          - type: is_illuminance
            condition: device
            entity_id: sensor.bad_bewegung_illuminance_lux
            domain: sensor
            below: 40
        sequence:
          - type: turn_on
            entity_id: light.bad_lampe
            domain: light
      - conditions:
          - condition: trigger
            id: Bad-Aus
          - condition: state
            entity_id: input_boolean.light_switched_on
            state: "off"
        sequence:
          - type: turn_off
            entity_id: light.bad_lampe
            domain: light
      - conditions:
          - condition: trigger
            id: Switched_on
        sequence:
          - service: input_boolean.turn_on
            data: {}
            target:
              entity_id: input_boolean.light_switched_on
          - delay:
              hours: 0
              minutes: 30
              seconds: 0
              milliseconds: 0
          - service: input_boolean.turn_off
            data: {}
            target:
              entity_id: input_boolean.light_switched_on
mode: single

Perfect, that is what I was looking for and so I have to use a helper with Input Bootlean, already found the post for that!

With the P1 I mean, the Aqara Motion Sensor P1.

Thanks for your help, will try that later :grinning: