AitorDB / home-assistant-sun-card

Home assistant sun card based on Google weather design
MIT License
405 stars 183 forks source link

Times are incorrect by 1 hour #118

Open antamy opened 2 years ago

antamy commented 2 years ago

I am on EST and have confirmed that my operating system date and time is correct and in the correct time zone (EST). In Home Assistant configuration.yaml, I also have the correct time zone specified.

When I look at sun.sun in Developer Tools, I see:

next_dawn: 2022-01-26T11:49:05.209042+00:00 next_dusk: 2022-01-26T23:32:27.668985+00:00 next_midnight: 2022-01-26T05:40:39+00:00 next_noon: 2022-01-26T17:40:29+00:00 next_rising: 2022-01-26T12:13:44.614876+00:00 next_setting: 2022-01-26T23:07:48.178739+00:00 elevation: -26.91 azimuth: 260.96 rising: false friendly_name: Sun

Since I am on EST, 5 hours behind UTC, I'd expect sun-card to show 7:13am and 6:07pm respectively for the next sunrise / sunset. Instead, I see:

image

All the times are 6 hours behind the UTC times, as if daylight savings time is in effect. With some other code using a value_template of {{ as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom(' %I:%M %p') | replace(" 0", "") }}, I get the correct results:

image

antamy commented 2 years ago

Follow up to this. The problem is because the card displays the times in the timezone of the user, not the timezone of the home assistant installation. So in my case, the installation is on EST and I am viewing on a system set to CST. Which has the consequence of displaying the incorrect times for these events.

jandirk39 commented 1 year ago

Hi,

I'm having the same issue. Is there already a fix for this?

antamy commented 1 year ago

Hi,

I'm having the same issue. Is there already a fix for this?

See my comment above. This is just how HA works. There was apparently no thought that people would want to use a system in a different time zone, so instead of localizing the UI to pick up the user's current time zone, it just uses the system's time zone. I worked around this by adding code to take care of it myself.

jandirk39 commented 1 year ago

Thanks for the reply. I use HA now for two weeks so I’m still a noob. Used domoticz before. Where do I put the code?