From 69ac6527f6cdea128e0830df9e76ba3ee027f645 Mon Sep 17 00:00:00 2001 From: Yordan Suarez Date: Sun, 24 Jul 2022 03:04:30 -0400 Subject: [PATCH] minimal validation before return data from coordinator --- custom_components/fpl/fplEntity.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/custom_components/fpl/fplEntity.py b/custom_components/fpl/fplEntity.py index ecb6728..22f585f 100644 --- a/custom_components/fpl/fplEntity.py +++ b/custom_components/fpl/fplEntity.py @@ -60,7 +60,11 @@ class FplEntity(CoordinatorEntity, SensorEntity): def getData(self, field): """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):