Add daily usage in KWH
This commit is contained in:
@@ -19,7 +19,34 @@ class FplDailyUsageSensor(FplEntity):
|
||||
data = self.getData("daily_usage")
|
||||
|
||||
if len(data) > 0:
|
||||
return {"date": data[-1]["date"], "daily_usage": data}
|
||||
return {"date": data[-1]["date"]}
|
||||
|
||||
return {}
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
return "mdi:currency-usd"
|
||||
|
||||
|
||||
class FplDailyUsageKWHSensor(FplEntity):
|
||||
def __init__(self, coordinator, config, account):
|
||||
super().__init__(coordinator, config, account, "Daily Usage KWH")
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
data = self.getData("daily_usage")
|
||||
|
||||
if len(data) > 0:
|
||||
return data[-1]["usage"]
|
||||
|
||||
return None
|
||||
|
||||
def defineAttributes(self):
|
||||
"""Return the state attributes."""
|
||||
data = self.getData("daily_usage")
|
||||
|
||||
if len(data) > 0:
|
||||
return {"date": data[-1]["date"]}
|
||||
|
||||
return {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user