Timer triggering incorrect automation

I have two automations which use timers, one turns on lights when arriving home and counts down five minutes before shutting off the hall light. The other will detect weather conditions in the morning and make a determination to extend the lighting schedule for another hour before shutting the lights off.

I am seeing strange behavior where a timer for a specific automation (hallway_lights_off) is causing another automation (extended_lights_off_am) to trigger the timer.finish and turn off the lights associated with its automation.

Each of the automatons have their own timers.

  hallway_lights:
    name: Hallway Lights
    duration: '00:05:00'
  cloudy_lights:
    name: Cloudy Lights
    duration: 01:00:00

When I trigger the “arriving home automation” It will turn on both Kitchen and Hallway lights. The timer will turn off the hallway lights after 5 minutes, this works fine in addition to turning off a group of lights “group.downstairs” which is part of the other automation.

Below is the behavior of the timer and the log showing “extended_lights_off_am” triggering with out its associated timer starting.

Code for “arriving_home” automation which uses timer.hallway_lights

- id: arrive_home
  alias: arrive_home
  trigger:
  - entity_id: sensor.home_presence
    from: Away
    platform: state
    to: Home
  condition:
    after: sunset
    condition: sun
  action:
  - entity_id: group.kitchen
    service: light.turn_on
  - entity_id: group.hallway
    service: light.turn_on
  - data:
      entity_id: timer.hallway_lights
    service: timer.cancel
  - delay: 00:00:05
  - data:
      duration: 00:00:20
      entity_id: timer.hallway_lights
    service: timer.start
    
    
- id: hallway_lights_off
  alias: hallway_lights_off
  trigger:
  - event_data:
      entity_id: timer.hallway_lights
    event_type: timer.finished
    platform: event
  action:
  - entity_id: group.hallway
    service: light.turn_off

Code for “extended_lights_off_am” which uses timer.cloudy_lights.

  action:
  - data:
      entity_id: group.downstairs
    service: light.turn_on
  - data:
      entity_id: timer.cloudy_lights
    service: timer.cancel
  - delay: 00:00:05
  - data:
      duration: 01:00:00
      entity_id: timer.cloudy_lights
    service: timer.start
- id: extended_lights_off_am
  alias: Extended Lights off a.m.
  trigger:
  - event_data:
      entiry_id: timer.cloudy_lights
    event_type: timer.finished
    platform: event
  action:
  - entity_id: group.downstairs
    service: light.turn_off

Any help would be appreciated!

that’s your problem

- id: extended_lights_off_am
  alias: Extended Lights off a.m.
  trigger:
  - event_data:
      entiry_id: timer.cloudy_lights #<-------------------- HERE
    event_type: timer.finished
    platform: event
  action:
  - entity_id: group.downstairs
    service: light.turn_off

change to

- id: extended_lights_off_am
  alias: Extended Lights off a.m.
  trigger:
  - event_data:
      entity_id: timer.cloudy_lights
    event_type: timer.finished
    platform: event
  action:
  - entity_id: group.downstairs
    service: light.turn_off
1 Like

Thanks! I am realizing the check config doesn’t catch everything. :face_with_raised_eyebrow:

It throws out unknown fields. Also, without that field, it’s a valid event trigger that would trigger on all timer entities. Which is why you were seeing it go off with the other timer.

Can I assume I need to change this from entity_id: to entity: for the timer in other lines of the automation as well as my other automation? You had only specified a change to the one line.

Ooops, typo, it should be entity_id. I’ll edit it.

I think you are good, I was reading on my phone.

Thanks, I looked at the code a hundred times over last night and didn’t catch the typo.

I only caught it because I know the behavior so I knew where to look. Otherwise I would have missed it too. The take away from this is that you now know how events are handled. I.E. if you omit information, you catch more events. It’s kind of like a inverted filter.

1 Like