Skip to content

Commit

Permalink
Implement PlatformNotReady to Linky + fix TypeError (home-assistant#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentame authored Feb 13, 2020
1 parent be388a4 commit e0a035c
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions homeassistant/components/linky/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
CONF_USERNAME,
ENERGY_KILO_WATT_HOUR,
)
from homeassistant.exceptions import PlatformNotReady
from homeassistant.helpers.entity import Entity
from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import HomeAssistantType
Expand Down Expand Up @@ -73,6 +74,7 @@ def update_linky_data(self, event_time=None):
_LOGGER.debug(json.dumps(self._data, indent=2))
except PyLinkyException as exp:
_LOGGER.error(exp)
raise PlatformNotReady
finally:
client.close_session()

Expand Down Expand Up @@ -146,6 +148,9 @@ def device_info(self):

async def async_update(self) -> None:
"""Retrieve the new data for the sensor."""
if self._account.data is None:
return

data = self._account.data[self._scale][self._when]
self._consumption = data[CONSUMPTION]
self._time = data[TIME]
Expand Down

0 comments on commit e0a035c

Please sign in to comment.