Can't get a basic trigger working

I’m totally new at this (but have a programmer background)
I’m trying the most basic thing that I could come up with. A “Hello world” for automations.
To toggle a hue lamp every minute.
To see if I can get an automation working.

The only thing in my automations.yaml file is

- id: '1659182131604'
  alias: Trigger light every minute
  description: ''
  trigger:
  - platform: time_pattern
    minutes: /1
  condition: []
  action:
  - type: toggle
    device_id: a67b5113374dc9e2aa00ec8d5df57a4d
    entity_id: light.runda_bords_lampan
    domain: light
  mode: single

But it never gets triggered.

Can anyone spot a bug in the code?

Do I need to reload something or restart home assistant?

If I do “run action” then the lamp is toggled. But I’ve understood there’s no way actually to debug och trigger a trigger?

Well, it suddenly started to work.
I have no idea why it didn’t work before.

I now changed the code to change the lamp every 5 seconds.

- id: '1659182131604'
  alias: Trigger light every 5 seconds
  description: ''
  trigger:
  - platform: time_pattern
    seconds: /5
  condition: []
  action:
  - type: toggle
    device_id: a67b5113374dc9e2aa00ec8d5df57a4d
    entity_id: light.runda_bords_lampan
    domain: light
  mode: single

But it still run every minute.

Do I need to do something to reload an automation after I change it?

In the automation tab it still has the old naming, but if I click in the pen, it is changed.
What do I need to do to get HA to understand that I’ve changed it?


OK, ymal files need to be reloaded!

Since you have to reload your automation.yaml and other *.yaml regularly after editing, you might find the shortcut system helpful:
just type c r in your Home Assistant UI, then hit <enter> to reload automations (top of the list that pops up) or pick any of the other configuration sections you want to reload from the list.

1 Like

Great tip!

Why doesn’t HA reload automatically when saving?

Probably because the configs would be invalid/broken most of the time while editing. It’s much more convenient to validate/debug the config after editing, then reload (very quick shortcuts) than to have your whole system become dysfunctional while editing. (And, in the no so distant past, reloading configs could be very slow - it is one of the areas where there have been very substantial performance improvements.)

(Note however that Python scripts do update continuously while editing and that if they are called in the middle of editing will often fail and generate errors.)

1 Like

I never use the UI editor but it was my understanding that it did.

Unless I’m mis-remembering again… :laughing:

but from the docs:

Automations created or edited via the user interface are activated immediately after saving the automation.

1 Like