rework fpl api

This commit is contained in:
Yordan Suarez
2022-08-02 11:10:57 -04:00
parent a1dbe51f10
commit a9d343f1f5
16 changed files with 1129 additions and 489 deletions

View File

@@ -8,41 +8,47 @@ from .fplEntity import FplEnergyEntity
class ProjectedKWHSensor(FplEnergyEntity):
"""Projected KWH sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Projected KWH")
@property
def state(self):
def native_value(self):
return self.getData("projectedKWH")
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL
# attributes["state_class"] = STATE_CLASS_TOTAL
return attributes
class DailyAverageKWHSensor(FplEnergyEntity):
"""Daily Average KWH sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Daily Average KWH")
@property
def state(self):
def native_value(self):
return self.getData("dailyAverageKWH")
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL
# attributes["state_class"] = STATE_CLASS_TOTAL
return attributes
class BillToDateKWHSensor(FplEnergyEntity):
"""Bill To Date KWH sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Bill To Date KWH")
@property
def state(self):
def native_value(self):
return self.getData("billToDateKWH")
def customAttributes(self):
@@ -54,36 +60,40 @@ class BillToDateKWHSensor(FplEnergyEntity):
last_reset = date.today() - timedelta(days=asOfDays)
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
attributes["last_reset"] = last_reset
# attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
# attributes["last_reset"] = last_reset
return attributes
class NetReceivedKWHSensor(FplEnergyEntity):
"""Received Meter Reading KWH sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Received Meter Reading KWH")
@property
def state(self):
def native_value(self):
return self.getData("recMtrReading")
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
# attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
return attributes
class NetDeliveredKWHSensor(FplEnergyEntity):
"""Delivered Meter Reading KWH sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Delivered Meter Reading KWH")
@property
def state(self):
def native_value(self):
return self.getData("delMtrReading")
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
# attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
return attributes