Fix solaredge service data KeyError (#40653)

This commit is contained in:
Maikel Punie 2020-09-27 11:40:56 +02:00 committed by GitHub
parent 66a8edb11e
commit b65583084b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -149,7 +149,7 @@ class SolarEdgeOverviewSensor(SolarEdgeSensor):
def update(self): def update(self):
"""Get the latest data from the sensor and update the state.""" """Get the latest data from the sensor and update the state."""
self.data_service.update() self.data_service.update()
self._state = self.data_service.data[self._json_key] self._state = self.data_service.data.get(self._json_key)
class SolarEdgeDetailsSensor(SolarEdgeSensor): class SolarEdgeDetailsSensor(SolarEdgeSensor):
@ -192,8 +192,8 @@ class SolarEdgeInventorySensor(SolarEdgeSensor):
def update(self): def update(self):
"""Get the latest inventory data and update state and attributes.""" """Get the latest inventory data and update state and attributes."""
self.data_service.update() self.data_service.update()
self._state = self.data_service.data[self._json_key] self._state = self.data_service.data.get(self._json_key)
self._attributes = self.data_service.attributes[self._json_key] self._attributes = self.data_service.attributes.get(self._json_key)
class SolarEdgeEnergyDetailsSensor(SolarEdgeSensor): class SolarEdgeEnergyDetailsSensor(SolarEdgeSensor):