Sunset automation causes light to turn on and off

Hello! I’m brand new to Home Assistant and I’m looking for some help with automations. I want my front porch light to turn on 10 minutes before sunset and then turn off at 2:10 AM. I’m trying to do this with two automations written in HassIO’s GUI automation editor. When I look at the logbook it looks like the light turns on and off several times during the night until the morning. What am I doing wrong?

Here’s my automations.yaml:

  - action:
  - alias: Porch Light On
      entity_id: light.front_porch
      transition: '20'
    service: light.turn_on
  - data:
      message: 10 minutes until sundown - front porch light is on
      title: Front Porch
    service: notify.ios_brendans_iphone
  alias: Sunset Porch Light
  condition: []
  id: '1503600070165'
  - event: sunset
    offset: -00:10:00
    platform: sun
- action:
  - data:
      entity_id: light.front_porch
      transition: '100'
    service: light.light_off
  - data:
      message: Late night - turning off the front porch light
      title: Front Porch
    service: notify.ios_brendans_iphone
  alias: Late Night Lights Out
  condition: []
  id: '1504105801569'
  - at: 02:10:00
    platform: time

And here’s the logs:

5:13 AM Front Porch turned on
5:10 AM Front Porch turned off
4:45 AM Front Porch turned on
4:45 AM Front Porch turned off
4:44 AM Front Porch turned on
4:44 AM Front Porch turned off
4:04 AM yr Symbol changed to 3
3:04 AM yr Symbol changed to 2
2:40 AM Front Porch turned on
2:40 AM Front Porch turned off
2:25 AM Front Porch turned on
2:25 AM Front Porch turned off
2:10 AM Late Night Lights Out has been triggered

Did you also get notifications? Are there any other automations that interact with the light?

I get the notifications on the first time that they fire. I have no other automations in hass and I have no routines in my Hue app that interact with that light.

Looks very much like this:

wow, the formatting for automations.yaml written by the automation editor is a nightmare !
Are you sure light.light_off is a valid service to turn_off the lights ? Shouldn’t it be light.turn_off ?

To me the automation (for turning off lights) itself is not even working. As on the log the automation is executed a 2:10, but the lights only turn off at 2:25…
So the flickering thing is not related to the automations, and your automation is not working due to the wrong service called.

For the flickering, my guess is that the bulbs loose connections or something and when they do there is some parameter that tells them to turn on automatically when they reconnect or something. (absolutely not sure about it, as I do not own the same bulbs, but that’s the first thing that comes to my mind when I see it turning off and then immediately back on).

Just looked at the hue component and there is an allow_unreachable option

This will allow unreachable bulbs to report their state correctly

This automation is one that I previously had using IFTTT but I wanted to move locally. I have disabled all of my home related IFTTT applets the first day that I got haps up and running. I’ve made the change to light.turn_off and I’ll see if that fixes the problem tonight.

So yes, I’m calling the wrong service but the strange part is that the light ever turns off. If I’m calling the wrong service, does hass continue to call the service forever? I could see how this would continue to change the state of the light.

I don’t believe the connection to the light is loose. The Hue bulbs require constant power and if they power cycle the light bulbs with come on at full brightness and stay on. They claim this is for safety reasons. If the connection was loose, I would come home to the porch light on at full brightness from a power cycle in the middle of the day. Why would the connection only be loose from 2am - 6am.

Something goes if the light was unreachable, the state of the light doesn’t change until sunset. This would make me believe that the light is only unreachable from 2am - 6am.

The light is turned off by somthing other than the automation, same for it turning it on. Otherwise you would see that automation X has been triggered between each state change.
So your problem will likely not be fixed by just calling the proper service, but at least the automation will work and the light will turn off at precisely 2:10…