Automation is failing to run

Hi –

Any idea why this automation is failing to run? Thank you.

image

dont use comma for entities …

        entity_id:
          - media_player.kitchen
          - media_player.library
          - media_player.living_room
          - media_player.office

btw paste the code rather then picture of your codes

If I click the automation it runs as I would expect but it is not executing on its own every 5 mins.

description: “Lights off after 5 min”
mode: single
trigger:

  • platform: state
    entity_id:
    • switch.laundry_area_ceiling_light
    • switch.basement_lights
      to: “on”
      for:
      hours: 0
      minutes: 5
      seconds: 0
      condition: []
      action:
  • service: switch.turn_off
    entity_id:
    • switch.laundry_area_ceiling_light
    • switch.basement_lights

Clicking “Run” only executes the automation’s action.

Reference: Testing your automation

I understand that but the automation sometimes runs at 5 min intervals and other times it don’t.

The State Trigger you created will trigger when either switch’s state changes to on and stays on for at least 5 continuous minutes.

It doesn’t trigger the way you described:

  • every 5 minutes
  • runs at 5 min intervals

so its not every 5 mins, but at random 5 minute intervals assuming lights are on?? Or am I misunderstanding you? On a side not Is there any script that can be used for dashboard to tell you when the next automation(s) run? I imagine not but figured to ask. Thanks for replying and tips

use that for your codes

As Taras said, the automation you written said …

  1. when the light turns on and stay on for 5 min then move next step
  2. turn off light
  3. end

You’re misunderstanding how a State Trigger works with the for option. It’s not “at random 5 minute intervals” but the way I described above.

  • If the switch is off and then you turn it on, if you turn it off 4 minutes later it won’t serve to trigger the automation. It must be on for at least 5 minutes.

  • If the switch is off and then you turn it on, if you leave it on for at least 5 minutes it will serve to trigger the automation.

@Taras i think the confusion because it a single mode, therefore if he turn on a different light the old automation is still in affect hence turn off both light before the 5minutes of the second light? he got 2 lights as trigger

Single mode isn’t a factor.

Got it. To wrap this I think I was led to believe if on for 5 mins and the automation did not trigger as I expected. I believe its working now. As opposed to wrestling with a scene if this works consistently then that is what I am after. Now if I could only get a Rasperry Pi, home assistant is currently on a vmware vm. Freaking scalpers are loving this chip shortage to charge double prices.

If my explanation of the State Trigger’s operation helped explain its behavior, please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.