From 1cfec6fd3968c20970570a81946a1e4987a9f8d0 Mon Sep 17 00:00:00 2001 From: mampfes Date: Mon, 22 Jan 2024 20:35:12 +0100 Subject: [PATCH] use datetime.timestamp to get time since epoch The previous solution is prone to misconfigurations of time zones. --- custom_components/epex_spot/EPEXSpot/Awattar/__init__.py | 3 +-- custom_components/epex_spot/manifest.json | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/custom_components/epex_spot/EPEXSpot/Awattar/__init__.py b/custom_components/epex_spot/EPEXSpot/Awattar/__init__.py index e015133..514cae6 100644 --- a/custom_components/epex_spot/EPEXSpot/Awattar/__init__.py +++ b/custom_components/epex_spot/EPEXSpot/Awattar/__init__.py @@ -1,6 +1,5 @@ import logging from datetime import datetime, timedelta, timezone -from time import mktime import aiohttp from homeassistant.util import dt @@ -42,7 +41,7 @@ def price_ct_per_kwh(self): def toEpochMilliSec(dt: datetime) -> int: - return mktime(dt.timetuple()) * 1000 + return int(dt.timestamp() * 1000) class Awattar: diff --git a/custom_components/epex_spot/manifest.json b/custom_components/epex_spot/manifest.json index 30c8990..8cff739 100644 --- a/custom_components/epex_spot/manifest.json +++ b/custom_components/epex_spot/manifest.json @@ -8,5 +8,5 @@ "iot_class": "cloud_polling", "issue_tracker": "https://github.com/mampfes/ha_epex_spot/issues", "requirements": ["bs4"], - "version": "2.3.2" + "version": "2.3.3.2" }