make use of _attr_
This commit is contained in:
@@ -7,7 +7,9 @@ from .fplEntity import FplMoneyEntity
|
||||
|
||||
|
||||
class FplProjectedBillSensor(FplMoneyEntity):
|
||||
"""projected bill sensor"""
|
||||
"""Projected bill sensor"""
|
||||
|
||||
_attr_state_class = STATE_CLASS_TOTAL
|
||||
|
||||
def __init__(self, coordinator, config, account):
|
||||
super().__init__(coordinator, config, account, "Projected Bill")
|
||||
@@ -22,22 +24,9 @@ class FplProjectedBillSensor(FplMoneyEntity):
|
||||
|
||||
return self.getData("projected_bill")
|
||||
|
||||
"""
|
||||
@property
|
||||
def state(self):
|
||||
budget = self.getData("budget_bill")
|
||||
budget_billing_projected_bill = self.getData("budget_billing_projected_bill")
|
||||
|
||||
if budget and budget_billing_projected_bill is not None:
|
||||
return self.getData("budget_billing_projected_bill")
|
||||
|
||||
return self.getData("projected_bill")
|
||||
"""
|
||||
|
||||
def customAttributes(self):
|
||||
"""Return the state attributes."""
|
||||
attributes = {}
|
||||
attributes["state_class"] = STATE_CLASS_TOTAL
|
||||
attributes["budget_bill"] = self.getData("budget_bill")
|
||||
return attributes
|
||||
|
||||
@@ -46,51 +35,39 @@ class FplProjectedBillSensor(FplMoneyEntity):
|
||||
class DeferedAmountSensor(FplMoneyEntity):
|
||||
"""Defered amount sensor"""
|
||||
|
||||
_attr_state_class = STATE_CLASS_TOTAL
|
||||
|
||||
def __init__(self, coordinator, config, account):
|
||||
super().__init__(coordinator, config, account, "Defered Amount")
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
def native_value(self):
|
||||
if self.getData("budget_bill"):
|
||||
return self.getData("defered_amount")
|
||||
return 0
|
||||
|
||||
def customAttributes(self):
|
||||
"""Return the state attributes."""
|
||||
attributes = {}
|
||||
attributes["state_class"] = STATE_CLASS_TOTAL
|
||||
return attributes
|
||||
|
||||
|
||||
class ProjectedBudgetBillSensor(FplMoneyEntity):
|
||||
"""projected budget bill sensor"""
|
||||
|
||||
_attr_state_class = STATE_CLASS_TOTAL
|
||||
|
||||
def __init__(self, coordinator, config, account):
|
||||
super().__init__(coordinator, config, account, "Projected Budget Bill")
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
def native_value(self):
|
||||
return self.getData("budget_billing_projected_bill")
|
||||
|
||||
def customAttributes(self):
|
||||
"""Return the state attributes."""
|
||||
attributes = {}
|
||||
attributes["state_class"] = STATE_CLASS_TOTAL
|
||||
return attributes
|
||||
|
||||
|
||||
class ProjectedActualBillSensor(FplMoneyEntity):
|
||||
"""projeted actual bill sensor"""
|
||||
|
||||
_attr_state_class = STATE_CLASS_TOTAL
|
||||
|
||||
def __init__(self, coordinator, config, account):
|
||||
super().__init__(coordinator, config, account, "Projected Actual Bill")
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
def native_value(self):
|
||||
return self.getData("projected_bill")
|
||||
|
||||
def customAttributes(self):
|
||||
"""Return the state attributes."""
|
||||
attributes = {}
|
||||
attributes["state_class"] = STATE_CLASS_TOTAL
|
||||
return attributes
|
||||
|
||||
Reference in New Issue
Block a user