Automation triggered, but actions does not run

This has happened for a few days now.
Automation:

- id: '1607324400756'
  alias: Utebelysning tid av
  description: ''
  trigger:
  - platform: sun
    event: sunrise
    offset: 00:18:00
  condition: []
  action:
  - type: turn_off
    device_id: d6c8351b17d011eb9ca47195cb70ee77
    entity_id: switch.utebelysning_hus
    domain: switch
  - type: turn_off
    device_id: d65e525117d011eb96ef1156e6e6a06c
    entity_id: light.entrelampor
    domain: light
  - type: turn_off
    device_id: d696ec4217d011eb8a8d3b6044f39b65
    entity_id: switch.gavel
    domain: switch
  - type: turn_off
    device_id: d76309ed17d011ebb7b9ef824d790877
    entity_id: switch.staket
    domain: switch
  mode: single

The automation does run 18 minutes after sunrise, but the lights are still on. And looking into the history of the devices nothing has happened.
Running the automation with run works. As you can see there are no conditions.

Device automations are an unknown to me, but you could try using services instead:

action:
  - service: switch.turn_off
    target:
      entity_id: 
        - switch.utebelysning_hus
        - switch.gavel
        - switch.staket
  - service: light.turn_off
    target:
      entity_id: light.entrelampor

Alternatively you can use the homeassistant service to turn off switches and lights in one go:

action:
  - service: homeassistant.turn_off
    target:
      entity_id: 
        - switch.utebelysning_hus
        - switch.gavel
        - switch.staket
        - light.entrelampor

Another thing to check, are all the referenced lights and switches available?

1 Like

I will try that, it is strange, because it has been working for at least half a year.
Since I’m not very good at the syntax, I’m using the editor.

Thank you for a quick reply!

You can use service type actions in the UI automation editor.

I just discovered yet another automation that behaves the same.

It is strange, it looks like it is always the “off” that doesn’t work.

I think learning automation yaml the best way is to make them in UI and then read the yaml file.

What puzzles me is that it has worked, and there are no updates as far as I can see,

So, I have upgraded the hardware. Now it is running on a Pi 4-8.
Now the 18 minutes before sunset does not trigger…

- id: '1607324439165'
  alias: Utebelysning tid  pĂĄ
  description: ''
  trigger:
  - platform: sun
    event: sunset
    offset: -00:18:00
  condition: []
  action:
  - type: turn_on
    device_id: d6c8351b17d011eb9ca47195cb70ee77
    entity_id: switch.utebelysning_hus
    domain: switch
  - service: light.turn_on
    data:
      brightness_pct: 19
    target:
      device_id: d65e525117d011eb96ef1156e6e6a06c
  - type: turn_on
    device_id: d696ec4217d011eb8a8d3b6044f39b65
    entity_id: switch.gavel
    domain: switch
  - type: turn_on
    device_id: d76309ed17d011ebb7b9ef824d790877
    entity_id: switch.staket
    domain: switch
  mode: single

But sometimes it does...
Very strange! 
What approach shall I use "at 18 minutes before sunset" this and this and this occurs, or
"this light turns on at 18 minutes before sunset" ?

The documentation has the offset amount in quotes. Perhaps try that, or use the sun elevation instead as recommended in that linked document.

Also, if you have upgraded your hardware, have you made sure to set your latitude and longitude correctly?

Yes, I restored the configuration from the old PI 3.
Otherwise it works like a charm!

I will check, this is generated from the editor…

I tried the quotes, I will se how it works this evening.
But the editor did not like them…

It did not trigger… :cry:

What happens if you trigger it manually?

Works like a charm!

It looks like the quotes is accepted by HA, but not the editor.

But what is the best way to go when creating automations?
“when 18 minutes before sunset, do sthis and that and more” or
“turn on outdoor light when 18 minutes before sunset”, “turn on some other lights when 18 minutes before sunset”…?

Suddenly since saturday it works! I have not done any modifications at all! Very strange!