merge changes into primary folder

This commit is contained in:
Adam Outler
2021-12-30 14:44:27 -05:00
parent 0a75b189b7
commit 621fea3042
29 changed files with 244 additions and 1467 deletions

View File

@@ -9,7 +9,7 @@ class FplDailyUsageSensor(FplEntity):
def state(self):
data = self.getData("daily_usage")
if len(data) > 0:
if ((data is not None) and (len(data) > 0)):
return data[-1]["cost"]
return None
@@ -17,11 +17,14 @@ class FplDailyUsageSensor(FplEntity):
def defineAttributes(self):
"""Return the state attributes."""
data = self.getData("daily_usage")
if len(data) > 0:
return {"date": data[-1]["date"]}
return {}
attributes = {}
attributes["friendly_name"] = "Daily Usage"
attributes["device_class"] = "monetary"
attributes["state_class"] = "total_increasing"
attributes["unit_of_measurement"] = "$"
if ((data is not None) and (data[-1]["cost"] is not None)):
attributes["date"] = data[-1]["readTime"]
return attributes
@property
def icon(self):
@@ -36,7 +39,7 @@ class FplDailyUsageKWHSensor(FplEntity):
def state(self):
data = self.getData("daily_usage")
if len(data) > 0:
if ((data is not None) and (data[-1]["usage"] is not None)):
return data[-1]["usage"]
return None
@@ -45,11 +48,73 @@ class FplDailyUsageKWHSensor(FplEntity):
"""Return the state attributes."""
data = self.getData("daily_usage")
if len(data) > 0:
return {"date": data[-1]["date"]}
attributes = {}
attributes["friendly_name"] = "Daily Usage"
attributes["device_class"] = "energy"
attributes["state_class"] = "total_increasing"
attributes["unit_of_measurement"] = "kWh"
return {}
if data is not None:
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
@property
def icon(self):
return "mdi:currency-usd"
return "mdi:flash"
class FplDailyReceivedKWHSensor(FplEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Daily Received KWH")
@property
def state(self):
data = self.getData("daily_usage")
return data[-1]["netReceivedKwh"]
def defineAttributes(self):
"""Return the state attributes."""
data = self.getData("daily_usage")
attributes = {}
attributes["friendly_name"] = "Daily Return to Grid"
attributes["device_class"] = "energy"
attributes["state_class"] = "total_increasing"
attributes["unit_of_measurement"] = "kWh"
attributes["date"] = data[-1]["readTime"]
attributes["last_reset"] = data[-2]["readTime"]
return attributes
@property
def icon(self):
return "mdi:flash"
class FplDailyDeliveredKWHSensor(FplEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Daily Delivered KWH")
@property
def state(self):
data = self.getData("daily_usage")
return data[-1]["netDeliveredKwh"]
def defineAttributes(self):
"""Return the state attributes."""
data = self.getData("daily_usage")
attributes = {}
attributes["friendly_name"] = "Daily Consumption"
attributes["device_class"] = "energy"
attributes["state_class"] = "total_increasing"
attributes["unit_of_measurement"] = "kWh"
attributes["date"] = data[-1]["readTime"]
attributes["last_reset"] = data[-2]["readTime"]
return attributes
@property
def icon(self):
return "mdi:flash"