Two different triggers

Hello all,
I need your help.
In my kitchen, the LED lamps are controlled by a motion detector. One hour before sunrise, the lights turn on when motion is detected and after 10 seconds without motion, the lights turn off again.

When cooking, the motion detector does not detect that I am still in the room and the lamps turn off again after 10 seconds.

Now I have bought a smart switch.
With this switch I want to expand the light control. If I press the switch, the light should be turned off after 5 minutes without movement.

I have already tested a bit, but do not get the setting.

I need a little help.

Can you share your code ?

Use the state of your smart switch as condition.

sorry my mistake!
here the codes

Motion Light on:

alias: Kitchen LED Motion on
description: ""
trigger:
  - type: motion
    platform: device
    device_id: 74ff17b8711c98b5ec92cb219a98cee4
    entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone_2
    domain: binary_sensor
    id: Kitchen_LED_Motion_on
condition:
  - condition: or
    conditions:
      - condition: sun
        after: sunset
        after_offset: "-01:00:00"
      - condition: sun
        before: sunrise
        before_offset: "01:00:00"
action:
  - type: turn_on
    device_id: 39b3083a7f3b098904dc9857bebf6421
    entity_id: switch.kitchen_led_switch
    domain: switch
mode: single

Light off

alias: Kitchen LED off
description: ""
trigger:
  - type: no_motion
    platform: device
    device_id: 74ff17b8711c98b5ec92cb219a98cee4
    entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone_2
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 40
condition: []
action:
  - type: turn_off
    device_id: 39b3083a7f3b098904dc9857bebf6421
    entity_id: switch.Kitchen_led_switch
    domain: switch
mode: single

Toggle:

alias: KitchenLED Toggle
description: ""
trigger:
  - device_id: 3496c5f1d55d4e172bf789669ccb5e28
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: remote_button_short_press
condition: []
action:
  - type: toggle
    device_id: 39b3083a7f3b098904dc9857bebf6421
    entity_id: switch.kitchen_led_switch
    domain: switch
mode: single
1 Like

TO BE TESTED but I would add an input_boolean to store if you push the button to switch on or off the kitchen led switch…
That input_boolen would have the same status then the light if you pushed the smart button… So:

alias: KitchenLED Toggle
description: ""
trigger:
  - device_id: 3496c5f1d55d4e172bf789669ccb5e28
    domain: zha
    platform: device
    type: remote_button_short_press
    subtype: remote_button_short_press
condition: []
action:
  - type: toggle
    device_id: 39b3083a7f3b098904dc9857bebf6421
    entity_id: switch.kitchen_led_switch
    domain: switch
  - service: input_boolean.turn_{{ states('switch.kitchen_led_switch') }}
    target:    
      entity_id: input_boolean.status_switch
mode: single

Than you have to adapt the “switch off” automation to the two cases: the switch off due to no motion for x seconds and the second one, switch off after 5 minutes without motion because you pressed the button. I am using a variable to detect in which case we are (X seconds or 5 minutes without movement)… The automation will check that if you pushed the button to switch on the light (input_boolean “on”) and there is 5 minutes without motion (button == “on”), then it will switch off the light and reset the input_boolean. Same if you have no motion for x seconds (button == “off”) but you did no push the button (input_boolean “off”)…

alias: Kitchen LED off
description: ""
trigger:
  - type: no_motion
    platform: device
    device_id: 74ff17b8711c98b5ec92cb219a98cee4
    entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone_2
    domain: binary_sensor
    for:
      hours: 0
      minutes: 0
      seconds: 40
    variables:
      button: "no"
  - type: no_motion
    platform: device
    device_id: 74ff17b8711c98b5ec92cb219a98cee4
    entity_id: binary_sensor.lumi_lumi_motion_ac02_iaszone_2
    domain: binary_sensor
    for:
      hours: 0
      minutes: 5
      seconds: 0
    variables:
      button: "yes"
condition: []
action:
  - condition: "{{ ((states('input_boolean.status_switch') == 'on') and (button == 'yes')) or ((states('input_boolean.status_switch') == 'off') and (button == 'no'))}}"
  - type: turn_off
    device_id: 39b3083a7f3b098904dc9857bebf6421
    entity_id: switch.Kitchen_led_switch
    domain: switch
  - service: input_boolean.turn_off
    target:    
      entity_id: input_boolean.status_switch
mode: single
1 Like

oh man this looks really good.
Thank you so much for taking the time.

Today I am not at home, but will test it tomorrow