Help with automation THANK´S

Hello, I have a couple of automations that control my bathroom lights, I’ll explain how it is configured to see if you can help me…

I have a first automation that with a presence sensor turns on 3 lights that are grouped in a group, turns them on through a scene (to adjust tone and intensity) then the same presence sensor, when it does not detect anything, waits 2 minutes and sends a service to turn off the lights, but lately I am detecting that some of the 3 lights stay on arbitrarily, so I want to make another automation or know how I can do to turn off that light that stays on, the idea was to launch a new automation after For example, 1 minute after executing the first one and with the condition that if the group remains on, it sends a lights-off service again… someone help me make that template for this second automation, thanks!!!

Couple of options.

  1. Add a wait for time to pass action after your turn off action for 1 minute. Then add another action to turn the group off again. You can also an an if statement to check if they are on in that action.
  2. In your first automation add an action to fire an event with your own event name. Then create a new automation that triggers on that event, add the same wait and turn off actions.

You can then write an

Thanks for your help …

I never used the events topic, there is documentation to know how to create one. As you say, I understand that it is a service that is executed from the first automation and then that same event what I create with a specific name I use as a trigger for the second automation…

Thank’s

Seems no good documentation so here are some examples for you.

Example of firing a custom event as an action. Add this to your turn off automation as another action.

alias: Test Event Fire
description: ""
trigger:
  - type: not_present
    platform: device
    device_id: 3d8a26df590a11c98ec9da3ef89d9bdb
    entity_id: binary_sensor.presence_sensor_presence
    domain: binary_sensor
condition: []
action:
  - delay:
      hours: 0
      minutes: 2
      seconds: 0
      milliseconds: 0
  - service: light.turn_off
    data: {}
    target:
      entity_id: light.lounge_main_light
  - event: custom_light_off_event
    event_data: {}
mode: single

New automation to trigger on your event, wait 1 minute, then if lights are on, turn them off.

description: ""
mode: single
trigger:
  - platform: event
    event_type: custom_light_off_event
condition: []
action:
  - delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
  - if:
      - condition: state
        entity_id: light.lounge_main_light
        state: "on"
    then:
      - type: turn_off
        device_id: 95c4891f8fbafcfb898b84c72125c92d
        entity_id: light.lounge_main_light
        domain: light

Ok, Thanks, I’ll try and see how it goes.