dingo35 / ha-SmartEVSEv3

Integrate SmartEVSEv3 with HomeAssistant through custom component
13 stars 8 forks source link

Start time is not correct #28

Closed Ferrox85 closed 4 months ago

Ferrox85 commented 4 months ago

If the starting time is set at 3 o'clock in the morning. The time is in the SMART Evse is correct. But in Home Assistant it is 01:00 o'clock, which isn't correct.

It looks like it doesn't take local time in account (or does not contain localization).

starttime raw in smart evse: 1714698000 starttime time stamp in home assistant: 1714698000

But Smart Evse is showing 3 o'clock, home assistant 1 o'clock Same goes for the latest update time. It is also 2 hours later than now.

But when i print now() in home assistant, it gives the correct time.

dingo35 commented 4 months ago

The starttime is in UTC, so if HA does not show the correct local time, your localization is wrong, at one or more levels: -OS -browser -HA.

You can check it at any epoch to human time converter...

Ferrox85 commented 4 months ago

Well, all other integrations (for example Nordpol, buienradar e.t.c.) are showing the correct time. This is the only integration suffering from this. When I use the developer tools it shows this (now and last updated have a maximum of 1 minute difference):

States:
now: {{now()}}
SMARTEVSE last update: {{states.sensor.smartevse_last_data_update.state}}

Raw timestamps
now: {{now() | as_timestamp }}
SMARTEVSE last update: {{states.sensor.smartevse_last_data_update.state | as_timestamp}}

Converted with custom timestamp:
now: {{now() | as_timestamp | timestamp_custom("%H:%M") }}
SMARTEVSE last update: {{states.sensor.smartevse_last_data_update.state | as_timestamp | timestamp_custom("%H:%M") }}

It results in the following output:

States:
now: 2024-05-04 10:10:23.935924+02:00
SMARTEVSE last update: 2024-05-04 08:10:20

Raw timestamps
now: 1714810223.936045
SMARTEVSE last update: 1714810220.0

Converted with custom timestamp:
now: 10:10
SMARTEVSE last update: 10:10

So, the raw timestamps are correct. But the smartevse integration does not take in account the localization settings when presenting the datetime string in the GUI. But when I use the developer tools it shows the correct time, which does take in account the localization settings. If there was a setting wrong in OS, Browser or HA, now() should also not show the correct time.

It is running on a Synology in a docker environment.

Ferrox85 commented 4 months ago

Sorry, I see that my hass logg is suffering from the same problem. I'll try to fix that first.

Ferrox85 commented 4 months ago

It was an error at my end. The TZ info was gone in the Docker Container.

dingo35 commented 4 months ago

Yep, thats what docker does...

Glad you solved it!