Device_sun_light_trigger not working as expected

Hi all,

I had a setup that switched the lights when the sun was setting or when someone comes home in the dark, but that broke after a recent update. I was looking to fix the 2 automations and I came across “device_sun_light_trigger”. (Presence-based lights - Home Assistant)
This component is exactly what I need, but it doesn’t work as expected.

This is what is should do:
Fade in the lights when the sun is setting and there are people home
Turn on the lights when people get home after the sun has set
Turn off the lights when all people leave the house

When I come home or leave the house, the lights turn on. But when I’m home and the sun is settings, the lights don’t turn on or when they do, they don’t fade in and they go on when it’s already dark outside. I’m thinking that it’s a bug in the system, because it does work when I’m coming home or leaving.

I’m guessing that is a bug, but I can’t find a lot of information about the component…

The lights I’m using are Philips Hue lamp, so they should support fading. And the sun component is enabled in my system.

This is the piece of code I’m using

device_sun_light_trigger:
  light_group: group.lights_livingroom
  device_group: group.all_devices

Is your time and location data correct? Sounds like it’s working as expected but it’s getting the timing wrong (possibly because it thinks your sunset time is for like Nairobi when it should be for Naples or whatever)

1 Like

Yes, when I check the map in the front end, the marked location is correct.
I had some other automations before using the sun, and they worked correctly.

I’ve changed some settings in my config file and now it seems to work correctly. I added a fixed elevation to the sun component and I think that fixed it. Or maybe it was the reboot/python update :stuck_out_tongue:

But unfortunately, the lights start to fade in 15 minutes before sunset and this is too late. It is already quite dark inside when it’s 15 minutes before sunset. I’d wish you could specify an optional offset to make the lights go on earlier.

It worked for fine until the weekend. I wasn’t home during sunset in the weekend, so I couldn’t check. But on Monday and Tuesday, the component stopped working again. All my other triggers are still working fine so there must be something going on with the component.