Guard against missing data in ReCollect Waste (#59177)

pull/59264/head
Aaron Bach 2021-11-06 14:10:58 -06:00 committed by GitHub
parent c5b5c8c3ce
commit 3d0d038597
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 2 deletions

View File

@ -78,8 +78,13 @@ class ReCollectWasteSensor(CoordinatorEntity, SensorEntity):
@callback
def update_from_latest_data(self) -> None:
"""Update the state."""
pickup_event = self.coordinator.data[0]
next_pickup_event = self.coordinator.data[1]
try:
pickup_event = self.coordinator.data[0]
next_pickup_event = self.coordinator.data[1]
except IndexError:
self._attr_native_value = None
self._attr_extra_state_attributes = {}
return
self._attr_extra_state_attributes.update(
{