update native value if there are valid values from api

This commit is contained in:
Yordan Suarez
2022-09-13 16:53:58 -04:00
parent d9d27f7ae6
commit d7b1f3fd38
5 changed files with 124 additions and 35 deletions

View File

@@ -15,7 +15,12 @@ class ProjectedKWHSensor(FplEnergyEntity):
@property
def native_value(self):
return self.getData("projectedKWH")
projectedKWH = self.getData("projectedKWH")
if projectedKWH is not None:
self._attr_native_value = projectedKWH
return self._attr_native_value
def customAttributes(self):
"""Return the state attributes."""
@@ -32,7 +37,12 @@ class DailyAverageKWHSensor(FplEnergyEntity):
@property
def native_value(self):
return self.getData("dailyAverageKWH")
dailyAverageKWH = self.getData("dailyAverageKWH")
if dailyAverageKWH is not None:
self._attr_native_value = dailyAverageKWH
return self._attr_native_value
def customAttributes(self):
"""Return the state attributes."""
@@ -49,7 +59,12 @@ class BillToDateKWHSensor(FplEnergyEntity):
@property
def native_value(self):
return self.getData("billToDateKWH")
billToDateKWH = self.getData("billToDateKWH")
if billToDateKWH is not None:
self._attr_native_value = billToDateKWH
return self._attr_native_value
def customAttributes(self):
"""Return the state attributes."""
@@ -73,7 +88,12 @@ class NetReceivedKWHSensor(FplEnergyEntity):
@property
def native_value(self):
return self.getData("recMtrReading")
recMtrReading = self.getData("recMtrReading")
if recMtrReading is not None:
self._attr_native_value = recMtrReading
return self._attr_native_value
def customAttributes(self):
"""Return the state attributes."""
@@ -90,7 +110,12 @@ class NetDeliveredKWHSensor(FplEnergyEntity):
@property
def native_value(self):
return self.getData("delMtrReading")
delMtrReading = self.getData("delMtrReading")
if delMtrReading is not None:
self._attr_native_value = delMtrReading
return self._attr_native_value
def customAttributes(self):
"""Return the state attributes."""