Implement PlatformNotReady to Linky + fix TypeError (#31768)
This commit is contained in:
1 parent
be388a4797
commit
e0a035ce35
1 file changed
+5
@@ -13,6 +13,7 @@ from homeassistant.const import (
|
|||||||
CONF_USERNAME,
|
CONF_USERNAME,
|
||||||
ENERGY_KILO_WATT_HOUR,
|
ENERGY_KILO_WATT_HOUR,
|
||||||
)
|
)
|
||||||
|
from homeassistant.exceptions import PlatformNotReady
|
||||||
from homeassistant.helpers.entity import Entity
|
from homeassistant.helpers.entity import Entity
|
||||||
from homeassistant.helpers.event import async_track_time_interval
|
from homeassistant.helpers.event import async_track_time_interval
|
||||||
from homeassistant.helpers.typing import HomeAssistantType
|
from homeassistant.helpers.typing import HomeAssistantType
|
||||||
@@ -73,6 +74,7 @@ class LinkyAccount:
|
|||||||
_LOGGER.debug(json.dumps(self._data, indent=2))
|
_LOGGER.debug(json.dumps(self._data, indent=2))
|
||||||
except PyLinkyException as exp:
|
except PyLinkyException as exp:
|
||||||
_LOGGER.error(exp)
|
_LOGGER.error(exp)
|
||||||
|
raise PlatformNotReady
|
||||||
finally:
|
finally:
|
||||||
client.close_session()
|
client.close_session()
|
||||||
|
|
||||||
@@ -146,6 +148,9 @@ class LinkySensor(Entity):
|
|||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
"""Retrieve the new data for the sensor."""
|
"""Retrieve the new data for the sensor."""
|
||||||
|
if self._account.data is None:
|
||||||
|
return
|
||||||
|
|
||||||
data = self._account.data[self._scale][self._when]
|
data = self._account.data[self._scale][self._when]
|
||||||
self._consumption = data[CONSUMPTION]
|
self._consumption = data[CONSUMPTION]
|
||||||
self._time = data[TIME]
|
self._time = data[TIME]
|
||||||
|
|||||||
Reference in new issue
Block a user