Created new sensor with specific data and group them by devices(account)
This commit is contained in:
31
custom_components/fpl/ProjectedBillSensor.py
Normal file
31
custom_components/fpl/ProjectedBillSensor.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from .FplSensor import FplSensor
|
||||
|
||||
|
||||
class FplProjectedBillSensor(FplSensor):
|
||||
def __init__(self, hass, config, account):
|
||||
FplSensor.__init__(self, hass, config, account, "Projected Bill")
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
data = self.data
|
||||
state = None
|
||||
if "budget_bill" in data.keys():
|
||||
if data["budget_bill"]:
|
||||
if "budget_billing_projected_bill" in data.keys():
|
||||
state = data["budget_billing_projected_bill"]
|
||||
else:
|
||||
if "projected_bill" in data.keys():
|
||||
state = data["projected_bill"]
|
||||
|
||||
return state
|
||||
|
||||
@property
|
||||
def device_state_attributes(self):
|
||||
"""Return the state attributes."""
|
||||
if "budget_bill" in self.data.keys():
|
||||
self.attr["budget_bill"] = self.data["budget_bill"]
|
||||
return self.attr
|
||||
|
||||
@property
|
||||
def icon(self):
|
||||
return "mdi:currency-usd"
|
||||
Reference in New Issue
Block a user