Skip to content
This repository was archived by the owner on Mar 5, 2025. It is now read-only.

Commit 845cc33

Browse files
committed
Fix tzinfo
1 parent f35f2d0 commit 845cc33

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

custom_components/ohme/binary_sensor.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
BinarySensorDeviceClass,
66
BinarySensorEntity
77
)
8-
from datetime import datetime
98
from homeassistant.helpers.update_coordinator import CoordinatorEntity
109
from homeassistant.core import HomeAssistant, callback
1110
from homeassistant.helpers.entity import generate_entity_id
@@ -294,7 +293,7 @@ def unique_id(self) -> str:
294293
@property
295294
def extra_state_attributes(self):
296295
"""Attributes of the sensor."""
297-
now = datetime.now()
296+
now = utcnow()
298297
slots = self._hass.data[DOMAIN][DATA_SLOTS] if DATA_SLOTS in self._hass.data[DOMAIN] else []
299298

300299
return {

custom_components/ohme/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ def charge_graph_slot_list(charge_start, points, skip_format=False):
140140
# Append a dict to the slots list with the start and end time
141141
slots.append(
142142
{
143-
"start": datetime.fromtimestamp(result[0]),
144-
"end": datetime.fromtimestamp(result[1]),
143+
"start": datetime.utcfromtimestamp(result[0]).replace(tzinfo=pytz.utc),
144+
"end": datetime.utcfromtimestamp(result[1]).replace(tzinfo=pytz.utc),
145145
"charge_in_kwh": -(result[3] / 1000),
146146
"source": "smart-charge",
147147
"location": None

0 commit comments

Comments
 (0)