mostly comments and formatting + 2 sensors

This commit is contained in:
Yordan Suarez
2022-01-22 11:54:54 -05:00
parent d99ea36427
commit 3be969883a
10 changed files with 220 additions and 53 deletions

View File

@@ -1,7 +1,10 @@
"""Average daily sensors"""
from .fplEntity import FplMoneyEntity
class FplAverageDailySensor(FplMoneyEntity):
class DailyAverageSensor(FplMoneyEntity):
"""average daily sensor, use budget value if available, otherwise use actual daily values"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Daily Average")
@@ -10,13 +13,21 @@ class FplAverageDailySensor(FplMoneyEntity):
budget = self.getData("budget_bill")
budget_billing_projected_bill = self.getData("budget_billing_daily_avg")
if budget == True and budget_billing_projected_bill is not None:
if budget and budget_billing_projected_bill is not None:
return self.getData("budget_billing_daily_avg")
return self.getData("daily_avg")
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = "total"
return attributes
class BudgetDailyAverageSensor(FplMoneyEntity):
"""budget daily average sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Budget Daily Average")
@@ -24,11 +35,25 @@ class BudgetDailyAverageSensor(FplMoneyEntity):
def state(self):
return self.getData("budget_billing_daily_avg")
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = "total"
return attributes
class ActualDailyAverageSensor(FplMoneyEntity):
"""Actual daily average sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Actual Daily Average")
@property
def state(self):
return self.getData("daily_avg")
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = "total"
return attributes