minimal validation before return data from coordinator

This commit is contained in:
Yordan Suarez
2022-07-24 03:04:30 -04:00
parent 3dcf55d384
commit 69ac6527f6

View File

@@ -60,7 +60,11 @@ class FplEntity(CoordinatorEntity, SensorEntity):
def getData(self, field): def getData(self, field):
"""call this method to retrieve sensor data""" """call this method to retrieve sensor data"""
return self.coordinator.data.get(self.account).get(field, None) if self.coordinator.data is not None:
account = self.coordinator.data.get(self.account)
if account is not None:
return account.get(field, None)
return None
class FplEnergyEntity(FplEntity): class FplEnergyEntity(FplEntity):