Skip to content

Conversation

massimopalmieri
Copy link

Fix timezone-related bug by using timezone-aware datetime to handle DST correctly

Description

Replaced all instances of datetime.now() with timezone-aware datetime.now(pytz.timezone("Europe/London")) to ensure correct behaviour around Daylight Saving Time (DST) transitions.

Motivation and Context

This change addresses a bug where the integration would behave incorrectly during Daylight Saving Time changes, due to the use of naive datetime objects.

How Has This Been Tested?

Tested with Home Assistant Core 2025.4.2 in a Docker environment with Europe/London timezone.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@massimopalmieri massimopalmieri changed the title use timezone Fix timezone-related bug Apr 16, 2025
@pjw345
Copy link

pjw345 commented May 15, 2025

This certainly fixes the issue for those in the living in the UK, tz = timezone("Europe/London"), but long term it should get the timezone from the HA configuration, which I believe is on the User itself, which is probably not ideal, as there should be a HA system-wide parameter (if that does not already exist).

@massimopalmieri
Copy link
Author

@pjw345 good point, I've pushed a change to get the timezone from HA

@jonandel
Copy link

jonandel commented Jun 26, 2025

Using timezone for setting to to and from api calls to get data isn't the correct way to do it, and introduces errors with the HA Energy dashboard.
In my rewrite of this integration, I use the (api documented) offset parameter.

As this project us officially abandoned, I published my repo to HACS, so you can see it in the Store.
Alternatively, you can contribute to the project via issues, PR's etc at https://github.com/jonandel/ha-hildebrandglow-dcc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants