Skip to content

Commit

Permalink
Fix blocking call inside the event loop (#89)
Browse files Browse the repository at this point in the history
* Fix blocking call inside the event loop

* Adjust
  • Loading branch information
epenet authored Jun 18, 2024
1 parent 89f3880 commit 000e3b1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions custom_components/rte_ecowatt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import json
import urllib.parse
import logging
from datetime import timedelta, datetime
from datetime import datetime, timedelta, tzinfo
from zoneinfo import ZoneInfo
from typing import Any, Dict, Optional, Tuple
from dateutil import tz
Expand All @@ -27,6 +27,7 @@
from homeassistant.helpers.httpx_client import get_async_client
from homeassistant.components.sensor import RestoreSensor
from homeassistant.components.calendar import CalendarEntity, CalendarEvent
from homeassistant.util import dt as dt_util

from .const import (
CONF_CLIENT_ID,
Expand Down Expand Up @@ -133,9 +134,8 @@ async def async_oauth_client(self):
self.token = client.token
return client

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

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

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

def _find_ecowatt_level(self) -> Optional[int]:
raise NotImplementedError()
Expand Down

0 comments on commit 000e3b1

Please sign in to comment.