mirror of
https://github.com/home-assistant/core.git
synced 2025-07-14 00:37:13 +00:00
Avoid failing when hub does not provide cover position information (#39826)
The powerview hub, seemingly randomly, will occasionally not provide data for cover positions. Some requests will return the desired response, but minutes later the same request might not. It appears this issue is being experienced by a number of people: https://community.home-assistant.io/t/hunter-douglas-powerview-component-expanding-this-api/88635/48 While an unfortunate bug with the hub, crashing the integration as a result of this missing data appears somewhat excessive. This patch adds a simple check to ensure the 'position' key has been returned by the hub before attempting to access its data.
This commit is contained in:
parent
8adfcf23f0
commit
066a418518
@ -215,7 +215,7 @@ class PowerViewShade(ShadeEntity, CoverEntity):
|
||||
def _async_update_current_cover_position(self):
|
||||
"""Update the current cover position from the data."""
|
||||
_LOGGER.debug("Raw data update: %s", self._shade.raw_data)
|
||||
position_data = self._shade.raw_data[ATTR_POSITION_DATA]
|
||||
position_data = self._shade.raw_data.get(ATTR_POSITION_DATA, {})
|
||||
if ATTR_POSITION1 in position_data:
|
||||
self._current_cover_position = position_data[ATTR_POSITION1]
|
||||
self._is_opening = False
|
||||
|
Loading…
x
Reference in New Issue
Block a user