Fixing sensor metadata
This commit is contained in:
@@ -27,7 +27,7 @@ class AllDataSensor(FplEntity):
|
|||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
attributes = {}
|
attributes = {}
|
||||||
attributes["friendly_name"] = "Budget Projected Bill"
|
attributes["friendly_name"] = "Budget Projected Bill"
|
||||||
attributes["device_class"] = "monitary"
|
attributes["device_class"] = "monetary"
|
||||||
attributes["state_class"] = "total"
|
attributes["state_class"] = "total"
|
||||||
attributes["unit_of_measurement"] = "$"
|
attributes["unit_of_measurement"] = "$"
|
||||||
return attributes
|
return attributes
|
||||||
@@ -23,7 +23,7 @@ class FplAverageDailySensor(FplEntity):
|
|||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
attributes = {}
|
attributes = {}
|
||||||
attributes["friendly_name"] = "Daily Average"
|
attributes["friendly_name"] = "Daily Average"
|
||||||
attributes["device_class"] = "monitary"
|
attributes["device_class"] = "monetary"
|
||||||
attributes["state_class"] = "total"
|
attributes["state_class"] = "total"
|
||||||
attributes["unit_of_measurement"] = "$"
|
attributes["unit_of_measurement"] = "$"
|
||||||
return attributes
|
return attributes
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class FplDailyUsageSensor(FplEntity):
|
|||||||
def state(self):
|
def state(self):
|
||||||
data = self.getData("daily_usage")
|
data = self.getData("daily_usage")
|
||||||
|
|
||||||
if ((data is not None) and (len(data) > 0)):
|
if (data is not None) and (len(data) > 0):
|
||||||
return data[-1]["cost"]
|
return data[-1]["cost"]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@@ -22,8 +22,11 @@ class FplDailyUsageSensor(FplEntity):
|
|||||||
attributes["device_class"] = "monetary"
|
attributes["device_class"] = "monetary"
|
||||||
attributes["state_class"] = "total_increasing"
|
attributes["state_class"] = "total_increasing"
|
||||||
attributes["unit_of_measurement"] = "$"
|
attributes["unit_of_measurement"] = "$"
|
||||||
if ((data is not None) and (data[-1]["cost"] is not None)):
|
if data is not None:
|
||||||
attributes["date"] = data[-1]["readTime"]
|
if (data[-1] is not None) and (data[-1]["readTime"] is not None):
|
||||||
|
attributes["date"] = data[-1]["readTime"]
|
||||||
|
if (data[-2] is not None) and (data[-2]["readTime"] is not None):
|
||||||
|
attributes["last_reset"] = data[-2]["readTime"]
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -39,7 +42,7 @@ class FplDailyUsageKWHSensor(FplEntity):
|
|||||||
def state(self):
|
def state(self):
|
||||||
data = self.getData("daily_usage")
|
data = self.getData("daily_usage")
|
||||||
|
|
||||||
if ((data is not None) and (data[-1]["usage"] is not None)):
|
if (data is not None) and (data[-1]["usage"] is not None):
|
||||||
return data[-1]["usage"]
|
return data[-1]["usage"]
|
||||||
|
|
||||||
return None
|
return None
|
||||||
@@ -55,17 +58,18 @@ class FplDailyUsageKWHSensor(FplEntity):
|
|||||||
attributes["unit_of_measurement"] = "kWh"
|
attributes["unit_of_measurement"] = "kWh"
|
||||||
|
|
||||||
if data is not None:
|
if data is not None:
|
||||||
if ((data[-1] is not None) and (data[-1]["readTime"] is not None)):
|
if (data[-1] is not None) and (data[-1]["readTime"] is not None):
|
||||||
attributes["date"] = data[-1]["readTime"]
|
attributes["date"] = data[-1]["readTime"]
|
||||||
if ((data[-2] is not None) and (data[-2]["readTime"] is not None)):
|
if (data[-2] is not None) and (data[-2]["readTime"] is not None):
|
||||||
attributes["last_reset"] = data[-2]["readTime"]
|
attributes["last_reset"] = data[-2]["readTime"]
|
||||||
|
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
return "mdi:flash"
|
return "mdi:flash"
|
||||||
|
|
||||||
|
|
||||||
class FplDailyReceivedKWHSensor(FplEntity):
|
class FplDailyReceivedKWHSensor(FplEntity):
|
||||||
def __init__(self, coordinator, config, account):
|
def __init__(self, coordinator, config, account):
|
||||||
super().__init__(coordinator, config, account, "Daily Received KWH")
|
super().__init__(coordinator, config, account, "Daily Received KWH")
|
||||||
@@ -73,7 +77,10 @@ class FplDailyReceivedKWHSensor(FplEntity):
|
|||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
data = self.getData("daily_usage")
|
data = self.getData("daily_usage")
|
||||||
return data[-1]["netReceivedKwh"]
|
try:
|
||||||
|
return data[-1]["netReceivedKwh"]
|
||||||
|
except:
|
||||||
|
return 0
|
||||||
|
|
||||||
def defineAttributes(self):
|
def defineAttributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
@@ -84,15 +91,18 @@ class FplDailyReceivedKWHSensor(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"
|
||||||
attributes["date"] = data[-1]["readTime"]
|
if data is not None:
|
||||||
attributes["last_reset"] = data[-2]["readTime"]
|
if (data[-1] is not None) and (data[-1]["readTime"] is not None):
|
||||||
|
attributes["date"] = data[-1]["readTime"]
|
||||||
|
if (data[-2] is not None) and (data[-2]["readTime"] is not None):
|
||||||
|
attributes["last_reset"] = data[-2]["readTime"]
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
return "mdi:flash"
|
return "mdi:flash"
|
||||||
|
|
||||||
|
|
||||||
class FplDailyDeliveredKWHSensor(FplEntity):
|
class FplDailyDeliveredKWHSensor(FplEntity):
|
||||||
def __init__(self, coordinator, config, account):
|
def __init__(self, coordinator, config, account):
|
||||||
super().__init__(coordinator, config, account, "Daily Delivered KWH")
|
super().__init__(coordinator, config, account, "Daily Delivered KWH")
|
||||||
@@ -100,7 +110,7 @@ class FplDailyDeliveredKWHSensor(FplEntity):
|
|||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
data = self.getData("daily_usage")
|
data = self.getData("daily_usage")
|
||||||
return data[-1]["netDeliveredKwh"]
|
return data[-1]["netDeliveredKwh"]
|
||||||
|
|
||||||
def defineAttributes(self):
|
def defineAttributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
@@ -111,8 +121,11 @@ class FplDailyDeliveredKWHSensor(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"
|
||||||
attributes["date"] = data[-1]["readTime"]
|
if data is not None:
|
||||||
attributes["last_reset"] = data[-2]["readTime"]
|
if (data[-1] is not None) and (data[-1]["readTime"] is not None):
|
||||||
|
attributes["date"] = data[-1]["readTime"]
|
||||||
|
if (data[-2] is not None) and (data[-2]["readTime"] is not None):
|
||||||
|
attributes["last_reset"] = data[-2]["readTime"]
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class ProjectedKWHSensor(FplEntity):
|
|||||||
attributes = {}
|
attributes = {}
|
||||||
attributes["friendly_name"] = "Projected KWH"
|
attributes["friendly_name"] = "Projected KWH"
|
||||||
attributes["device_class"] = "energy"
|
attributes["device_class"] = "energy"
|
||||||
attributes["state_class"] = "total_increasing"
|
attributes["state_class"] = "total"
|
||||||
attributes["unit_of_measurement"] = "kWh"
|
attributes["unit_of_measurement"] = "kWh"
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ class DailyAverageKWHSensor(FplEntity):
|
|||||||
attributes = {}
|
attributes = {}
|
||||||
attributes["friendly_name"] = "Daily Average"
|
attributes["friendly_name"] = "Daily Average"
|
||||||
attributes["device_class"] = "energy"
|
attributes["device_class"] = "energy"
|
||||||
attributes["state_class"] = "total_increasing"
|
attributes["state_class"] = "total"
|
||||||
attributes["unit_of_measurement"] = "kWh"
|
attributes["unit_of_measurement"] = "kWh"
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
@@ -57,10 +57,11 @@ class BillToDateKWHSensor(FplEntity):
|
|||||||
def defineAttributes(self):
|
def defineAttributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
attributes = {}
|
attributes = {}
|
||||||
attributes["friendly_name"] = "Bill To Date"
|
attributes["friendly_name"] = "Billing Usage"
|
||||||
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"
|
||||||
|
attributes["last_reset"] = self.getData("billStartDate")
|
||||||
return attributes
|
return attributes
|
||||||
|
|
||||||
class NetReceivedKWHSensor(FplEntity):
|
class NetReceivedKWHSensor(FplEntity):
|
||||||
@@ -69,7 +70,10 @@ class NetReceivedKWHSensor(FplEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
return self.getData("recMtrReading")
|
try:
|
||||||
|
return self.getData("recMtrReading")
|
||||||
|
except:
|
||||||
|
return 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
@@ -92,7 +96,10 @@ class NetDeliveredKWHSensor(FplEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
return self.getData("delMtrReading")
|
try:
|
||||||
|
return self.getData("delMtrReading")
|
||||||
|
except:
|
||||||
|
return self.getData("billToDateKWH")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def icon(self):
|
def icon(self):
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ class FplProjectedBillSensor(FplEntity):
|
|||||||
def defineAttributes(self):
|
def defineAttributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
attributes = {}
|
attributes = {}
|
||||||
attributes["friendly_name"] = "Projected Bill"
|
attributes["friendly_name"] = "Projected Bill Payment Due"
|
||||||
attributes["device_class"] = "monitary"
|
attributes["device_class"] = "monetary"
|
||||||
attributes["state_class"] = "total"
|
attributes["state_class"] = "total"
|
||||||
attributes["unit_of_measurement"] = "$"
|
attributes["unit_of_measurement"] = "$"
|
||||||
return attributes
|
return attributes
|
||||||
@@ -32,12 +32,12 @@ class FplProjectedBillSensor(FplEntity):
|
|||||||
# Defered Amount
|
# Defered Amount
|
||||||
class DeferedAmountSensor(FplEntity):
|
class DeferedAmountSensor(FplEntity):
|
||||||
def __init__(self, coordinator, config, account):
|
def __init__(self, coordinator, config, account):
|
||||||
super().__init__(coordinator, config, account, "Defered Amount")
|
super().__init__(coordinator, config, account, "Deferred Amount")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
if self.getData("defered_amount") is not None:
|
if self.getData("deferred_amount") is not None:
|
||||||
return self.getData("defered_amount")
|
return self.getData("deferred_amount")
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@@ -47,8 +47,8 @@ class DeferedAmountSensor(FplEntity):
|
|||||||
def defineAttributes(self):
|
def defineAttributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
attributes = {}
|
attributes = {}
|
||||||
attributes["friendly_name"] = "Defered Amount"
|
attributes["friendly_name"] = "Deferred Amount"
|
||||||
attributes["device_class"] = "monitary"
|
attributes["device_class"] = "monetary"
|
||||||
attributes["state_class"] = "total"
|
attributes["state_class"] = "total"
|
||||||
attributes["unit_of_measurement"] = "$"
|
attributes["unit_of_measurement"] = "$"
|
||||||
return attributes
|
return attributes
|
||||||
|
|||||||
Reference in New Issue
Block a user