Sun state is wrong

It appears my sun state is wrong and I’m not sure how to fix it. It was working fine, but for some reason is showing incorrect state and very wrong sunrise/sunset times. I just have “sun:” in my configuration.yaml to enable it.

Currently I am seeing sun.sun state as “above_horizon” (it’s 9pm in the evening, it showed “below_horizon” most of the day).

next_rising: 2017-01-10T15:24:25+00:00 friendly_name: Sun next_setting: 2017-01-10T01:08:24+00:00 elevation: 29.02 azimuth: 193.81

next setting at 1:08AM and sunrise at 3:24PM?

I noticed this because my automations were acting weird. I’ve restarted HA and the same values come up.

I think the sun component uses the latitude and longitude settings in configuration.yaml. Have you set these to your location?

I believe elevation is needed as well - if not HA put’s it in but generates a info error.

I have latitude, longitude, and elevation set correctly in my configuration.yaml. This was all working until about 2 days ago when I noticed.

I just checked my system clock with ‘date’ on the command line and it showed it 8 hours ahead. I reset it to the correct time, but if I reboot it’s back to 8 hours ahead. Is this messing up my sun component? How do I get the correct time to stick?

I could certainly see that affecting the set/rise times; did you compare the times given with another source off the web? If they are off by 8 hours then you might have your answer.

What platform are you on?

You are right, they were off by exactly the same amount as my system clock. I don’t know why using “sudo date” didn’t do it.

On my Raspberry Pi, I solved the problem by running raspi-config and then selecting my Time Zone in the International Options section.

1 Like

sudo date only prints the current time. You’d need to select the correct time zone (appears Raspberry has a menu to do this for you) and perhaps configure NTPd so the clock doesn’t drift over time.

2 Likes