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 @@
"""Projected bill sensors"""
from .fplEntity import FplMoneyEntity
class FplProjectedBillSensor(FplMoneyEntity):
"""projected bill sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Projected Bill")
@@ -10,7 +13,7 @@ class FplProjectedBillSensor(FplMoneyEntity):
budget = self.getData("budget_bill")
budget_billing_projected_bill = self.getData("budget_billing_projected_bill")
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_projected_bill")
return self.getData("projected_bill")
@@ -18,28 +21,34 @@ class FplProjectedBillSensor(FplMoneyEntity):
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
try:
if self.getData("budget_bill") == True:
attributes["budget_bill"] = self.getData("budget_bill")
except:
pass
attributes["state_class"] = "total"
attributes["budget_bill"] = self.getData("budget_bill")
return attributes
# Defered Amount
class DeferedAmountSensor(FplMoneyEntity):
"""Defered amount sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Defered Amount")
@property
def state(self):
if self.getData("budget_bill") == True:
if self.getData("budget_bill"):
return self.getData("defered_amount")
return 0
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = "total"
return attributes
class ProjectedBudgetBillSensor(FplMoneyEntity):
"""projected budget bill sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Projected Budget Bill")
@@ -47,11 +56,25 @@ class ProjectedBudgetBillSensor(FplMoneyEntity):
def state(self):
return self.getData("budget_billing_projected_bill")
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = "total"
return attributes
class ProjectedActualBillSensor(FplMoneyEntity):
"""projeted actual bill sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Projected Actual Bill")
@property
def state(self):
return self.getData("projected_bill")
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = "total"
return attributes