Skip to content

Commit 000e3b1

Browse files
authored
Fix blocking call inside the event loop (#89)
* Fix blocking call inside the event loop * Adjust
1 parent 89f3880 commit 000e3b1

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

custom_components/rte_ecowatt/__init__.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import json
44
import urllib.parse
55
import logging
6-
from datetime import timedelta, datetime
6+
from datetime import datetime, timedelta, tzinfo
77
from zoneinfo import ZoneInfo
88
from typing import Any, Dict, Optional, Tuple
99
from dateutil import tz
@@ -27,6 +27,7 @@
2727
from homeassistant.helpers.httpx_client import get_async_client
2828
from homeassistant.components.sensor import RestoreSensor
2929
from homeassistant.components.calendar import CalendarEntity, CalendarEvent
30+
from homeassistant.util import dt as dt_util
3031

3132
from .const import (
3233
CONF_CLIENT_ID,
@@ -133,9 +134,8 @@ async def async_oauth_client(self):
133134
self.token = client.token
134135
return client
135136

136-
def _timezone(self):
137-
timezone = self.hass.config.as_dict()["time_zone"]
138-
return tz.gettz(timezone)
137+
def _timezone(self) -> tzinfo:
138+
return dt_util.get_default_time_zone()
139139

140140
def skip_refresh(self) -> Optional[str]:
141141
"""
@@ -407,9 +407,8 @@ def __init__(
407407
}
408408
self._attr_extra_state_attributes["options"] = list(self.options.values()) + ["Coupure d'électricité en cours"]
409409

410-
def _timezone(self):
411-
timezone = self.hass.config.as_dict()["time_zone"]
412-
return tz.gettz(timezone)
410+
def _timezone(self) -> tzinfo:
411+
return dt_util.get_default_time_zone()
413412

414413
def _find_ecowatt_level(self) -> Optional[int]:
415414
raise NotImplementedError()

0 commit comments

Comments
 (0)