return none if no data is available
This commit is contained in:
@@ -80,7 +80,7 @@ class FplDailyReceivedKWHSensor(FplEntity):
|
|||||||
try:
|
try:
|
||||||
return data[-1]["netReceivedKwh"]
|
return data[-1]["netReceivedKwh"]
|
||||||
except:
|
except:
|
||||||
return 0
|
return None
|
||||||
|
|
||||||
def defineAttributes(self):
|
def defineAttributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
@@ -113,7 +113,7 @@ class FplDailyDeliveredKWHSensor(FplEntity):
|
|||||||
try:
|
try:
|
||||||
return data[-1]["netDeliveredKwh"]
|
return data[-1]["netDeliveredKwh"]
|
||||||
except:
|
except:
|
||||||
return 0
|
return None
|
||||||
|
|
||||||
def defineAttributes(self):
|
def defineAttributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class BillToDateKWHSensor(FplEntity):
|
|||||||
attributes["device_class"] = "energy"
|
attributes["device_class"] = "energy"
|
||||||
attributes["state_class"] = "total_increasing"
|
attributes["state_class"] = "total_increasing"
|
||||||
attributes["unit_of_measurement"] = "kWh"
|
attributes["unit_of_measurement"] = "kWh"
|
||||||
|
if self.getData("billStartDate") is not None:
|
||||||
attributes["last_reset"] = self.getData("billStartDate")
|
attributes["last_reset"] = self.getData("billStartDate")
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ class NetReceivedKWHSensor(FplEntity):
|
|||||||
try:
|
try:
|
||||||
return self.getData("recMtrReading")
|
return self.getData("recMtrReading")
|
||||||
except:
|
except:
|
||||||
return 0
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
@@ -86,6 +87,7 @@ class NetReceivedKWHSensor(FplEntity):
|
|||||||
attributes["device_class"] = "energy"
|
attributes["device_class"] = "energy"
|
||||||
attributes["state_class"] = "total_increasing"
|
attributes["state_class"] = "total_increasing"
|
||||||
attributes["unit_of_measurement"] = "kWh"
|
attributes["unit_of_measurement"] = "kWh"
|
||||||
|
if self.getData("billStartDate") is not None:
|
||||||
attributes["last_reset"] = self.getData("billStartDate")
|
attributes["last_reset"] = self.getData("billStartDate")
|
||||||
|
|
||||||
return attributes
|
return attributes
|
||||||
@@ -99,7 +101,10 @@ class NetDeliveredKWHSensor(FplEntity):
|
|||||||
try:
|
try:
|
||||||
return self.getData("delMtrReading")
|
return self.getData("delMtrReading")
|
||||||
except:
|
except:
|
||||||
|
try:
|
||||||
return self.getData("billToDateKWH")
|
return self.getData("billToDateKWH")
|
||||||
|
except:
|
||||||
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
@@ -112,6 +117,7 @@ class NetDeliveredKWHSensor(FplEntity):
|
|||||||
attributes["device_class"] = "energy"
|
attributes["device_class"] = "energy"
|
||||||
attributes["state_class"] = "total_increasing"
|
attributes["state_class"] = "total_increasing"
|
||||||
attributes["unit_of_measurement"] = "kWh"
|
attributes["unit_of_measurement"] = "kWh"
|
||||||
|
if self.getData("billStartDate") is not None:
|
||||||
attributes["last_reset"] = self.getData("billStartDate")
|
attributes["last_reset"] = self.getData("billStartDate")
|
||||||
|
|
||||||
return attributes
|
return attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user