Sunrise automation working - sunset fails


I had this simple automation working a while ago then it stopped some time back. I can go into developer states and set the “sun” state to “above_horizon” and my second automation here works just fine and turns the lights off. The first one for “below_horizon” never triggers for me to turn the lights on. Turning them on manually then the automation for turning them off works fine though.

I’ve tried switching it to other things like the examples from the site:

It just isn’t working though. Can’t tell what’s going wrong and the configuration says it’s valid.

Here’s my entire automations.yaml file (it’s small with only a few):

- id: '1535596055769'
  alias: Outdoor Lights on at Dusk
  - entity_id: sun.sun
    from: above_horizon
    platform: state
    to: below_horizon
  - entity_id: group.lights_outdoor
    service: homeassistant.turn_on
- id: '1535596055772'
  alias: Outdoor Lights off at Sunrise
    platform: state
    from: below_horizon
    entity_id: sun.sun
    to: above_horizon
  - entity_id: group.lights_outdoor
    service: homeassistant.turn_off
- id: bysoab
  alias: Backyard String Lights off around bedtime
  - platform: time
    at: '19:12:00'
  - service: homeassistant.turn_off
    entity_id: switch.outdoor_switch

Did you try using:

    platform: sun
    event: sunset

I think I had tried it previously, but can verify again.

How can you mimic the ‘sunset’ event through the dev tools? That’s one thing I’m uncertain of how to do to see if that event will trigger it properly.

After trying many, many things for some reason it was my alias name.

I ended up making a clone of my sunset automation and trying things with it. It would work fine, but my alias as “Outdoor Lights on at Dusk” just flat out refused to work. I changed to “Outdoor Lights on at Sunset” and it’s working now. I don’t understand it at all and still drives me a bit crazy. Not sure if something is cached somewhere screwing with things.

Well then I typed that and went back to my “States” screen and saw both my automations for “sun” showed on. In interest of figuring it out I switched the name back and sure enough the “automation.outdoor_lights_on_at_dusk” is set as “off”

Not sure when/how the automation was set as “off” or what purpose it’s for exactly. The UI screen shows nothing on it for the automations so it made it very odd to figure out and not intuitive.

Two things:

  1. I always put my aliases in single quotes, not sure if it is required. Examples in the docs dont have them.
  2. set initial_state to true if you dont want the automation disabled when an interrupted shutdown occurs:


  alias: 'Hass startup'
  initial_state: True

Thanks, i’ll do the initial_state to true. From what I read they are all true by default though, so unsure if this will help. My guess is I may have at some point tried to manually “trigger” my automations from the home “states” page. That toggle is setting the state to “false” and not triggering it.

That whole thing isn’t all that intuitive how it’ll pop up on your home screen, toggle it, then it’s permanently disabled unless you figure this out.

Also from all my tinkering I know that the alias does not need quotes

Definitely not the case. See this.

…if you shut down Home Assistant again before it finishes starting, any automation that doesn’t have the initial state set to true will be stored as being off, and those automations will be disabled at the next startup.

Not really sure what you’re talking about here.