Merge pull request #23 from adamoutler/master

Sensor metadata update
This commit is contained in:
Yordan Suarez
2022-01-12 19:17:43 -05:00
committed by GitHub
13 changed files with 408 additions and 91 deletions

View File

@@ -24,13 +24,12 @@ class FplProjectedBillSensor(FplSensor):
@property @property
def device_state_attributes(self): def device_state_attributes(self):
"""Return the state attributes.""" """Return the state attributes."""
try:
if "budget_bill" in self.data.keys(): if "budget_bill" in self.data.keys():
self.attr["budget_bill"] = self.data["budget_bill"] self.attr["budget_bill"] = self.data["budget_bill"]
except:
pass
return self.attr
return self._state
@property @property
def icon(self): def icon(self):

View File

@@ -3,7 +3,7 @@
NAME = "FPL Integration" NAME = "FPL Integration"
DOMAIN = "fpl" DOMAIN = "fpl"
DOMAIN_DATA = f"{DOMAIN}_data" DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "0.0.1" VERSION = "0.1.0"
PLATFORMS = ["sensor"] PLATFORMS = ["sensor"]
REQUIRED_FILES = [ REQUIRED_FILES = [
".translations/en.json", ".translations/en.json",

View File

@@ -7,7 +7,7 @@ from datetime import timedelta
from .fplapi import FplApi from .fplapi import FplApi
from .const import DOMAIN from .const import DOMAIN
SCAN_INTERVAL = timedelta(seconds=7200) SCAN_INTERVAL = timedelta(seconds=1200)
_LOGGER: logging.Logger = logging.getLogger(__package__) _LOGGER: logging.Logger = logging.getLogger(__package__)

View File

@@ -19,16 +19,13 @@ class FplEntity(CoordinatorEntity):
) )
return id return id
@property
def name(self):
return f"{DOMAIN.upper()} {self.account} {self.sensorName}"
@property @property
def device_info(self): def device_info(self):
return { return {
"identifiers": {(DOMAIN, self.account)}, "identifiers": {(DOMAIN, self.account)},
"name": f"Account {self.account}", "name": f"FPL Account {self.account}",
"model": VERSION, "model": "FPL Monitoring API",
"sw_version": VERSION,
"manufacturer": "Florida Power & Light", "manufacturer": "Florida Power & Light",
} }

View File

@@ -300,6 +300,9 @@ class FplApi(object):
"cost": daily["billingCharge"], "cost": daily["billingCharge"],
"date": daily["date"], "date": daily["date"],
"max_temperature": daily["averageHighTemperature"], "max_temperature": daily["averageHighTemperature"],
"netDeliveredKwh": daily["netDeliveredKwh"],
"netReceivedKwh": daily["netReceivedKwh"],
"readTime": daily["readTime"],
} }
) )
# totalPowerUsage += int(daily["kwhUsed"]) # totalPowerUsage += int(daily["kwhUsed"])
@@ -312,6 +315,7 @@ class FplApi(object):
data["billToDateKWH"] = r["CurrentUsage"]["billToDateKWH"] data["billToDateKWH"] = r["CurrentUsage"]["billToDateKWH"]
data["recMtrReading"] = r["CurrentUsage"]["recMtrReading"] data["recMtrReading"] = r["CurrentUsage"]["recMtrReading"]
data["delMtrReading"] = r["CurrentUsage"]["delMtrReading"] data["delMtrReading"] = r["CurrentUsage"]["delMtrReading"]
data["billStartDate"] = r["CurrentUsage"]["billStartDate"]
return data return data
async def __getDataFromApplianceUsage(self, account, lastBilledDate) -> dict: async def __getDataFromApplianceUsage(self, account, lastBilledDate) -> dict:

View File

@@ -12,6 +12,6 @@
"bs4", "bs4",
"integrationhelper" "integrationhelper"
], ],
"homeassistant": "0.96.0", "homeassistant": "2021.12.7",
"version": "1.0.0" "version": "1.0.0"
} }

View File

@@ -23,9 +23,14 @@ from .sensor_ProjectedBillSensor import (
from .sensor_AverageDailySensor import ( from .sensor_AverageDailySensor import (
FplAverageDailySensor, FplAverageDailySensor,
BudgetDailyAverageSensor, BudgetDailyAverageSensor,
ActualDailyAverageSensor,
) )
from .sensor_DailyUsageSensor import FplDailyUsageKWHSensor, FplDailyUsageSensor from .sensor_DailyUsageSensor import (
FplDailyUsageKWHSensor,
FplDailyUsageSensor,
FplDailyDeliveredKWHSensor,
FplDailyReceivedKWHSensor,
)
from .const import DOMAIN from .const import DOMAIN
from .sensor_AllData import AllDataSensor from .sensor_AllData import AllDataSensor
@@ -54,10 +59,10 @@ async def async_setup_entry(hass, entry, async_add_devices):
# usage sensors # usage sensors
fpl_accounts.append(FplAverageDailySensor(coordinator, entry, account)) fpl_accounts.append(FplAverageDailySensor(coordinator, entry, account))
fpl_accounts.append(BudgetDailyAverageSensor(coordinator, entry, account)) fpl_accounts.append(BudgetDailyAverageSensor(coordinator, entry, account))
fpl_accounts.append(ActualDailyAverageSensor(coordinator, entry, account))
fpl_accounts.append(FplDailyUsageSensor(coordinator, entry, account)) fpl_accounts.append(FplDailyUsageSensor(coordinator, entry, account))
fpl_accounts.append(FplDailyUsageKWHSensor(coordinator, entry, account)) fpl_accounts.append(FplDailyUsageKWHSensor(coordinator, entry, account))
fpl_accounts.append(FplDailyReceivedKWHSensor(coordinator, entry, account))
fpl_accounts.append(FplDailyDeliveredKWHSensor(coordinator, entry, account))
# date sensors # date sensors
fpl_accounts.append(CurrentBillDateSensor(coordinator, entry, account)) fpl_accounts.append(CurrentBillDateSensor(coordinator, entry, account))
@@ -70,5 +75,8 @@ async def async_setup_entry(hass, entry, async_add_devices):
fpl_accounts.append(ProjectedKWHSensor(coordinator, entry, account)) fpl_accounts.append(ProjectedKWHSensor(coordinator, entry, account))
fpl_accounts.append(DailyAverageKWHSensor(coordinator, entry, account)) fpl_accounts.append(DailyAverageKWHSensor(coordinator, entry, account))
fpl_accounts.append(BillToDateKWHSensor(coordinator, entry, account)) fpl_accounts.append(BillToDateKWHSensor(coordinator, entry, account))
fpl_accounts.append(NetReceivedKWHSensor(coordinator, entry, account))
fpl_accounts.append(NetDeliveredKWHSensor(coordinator, entry, account))
async_add_devices(fpl_accounts) async_add_devices(fpl_accounts)

View File

@@ -13,12 +13,21 @@ class AllDataSensor(FplEntity):
if budget == True and budget_billing_projected_bill is not None: if budget == True and budget_billing_projected_bill is not None:
return self.getData("budget_billing_projected_bill") return self.getData("budget_billing_projected_bill")
return self.getData("projected_bill") try:
self._state=self.getData("projected_bill")
def defineAttributes(self): except:
"""Return the state attributes.""" pass
return self.coordinator.data.get(self.account) return self._state
@property @property
def icon(self): def icon(self):
return "mdi:currency-usd" return "mdi:currency-usd"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Budget Projected Bill"
attributes["device_class"] = "monetary"
attributes["state_class"] = "total"
attributes["unit_of_measurement"] = "$"
return attributes

View File

@@ -13,12 +13,24 @@ class FplAverageDailySensor(FplEntity):
if budget == True and budget_billing_projected_bill is not None: if budget == True and budget_billing_projected_bill is not None:
return self.getData("budget_billing_daily_avg") return self.getData("budget_billing_daily_avg")
return self.getData("daily_avg") try:
self._state=self.getData("daily_avg")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:currency-usd" return "mdi:currency-usd"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Daily Average"
attributes["device_class"] = "monetary"
attributes["state_class"] = "total"
attributes["unit_of_measurement"] = "$"
return attributes
class BudgetDailyAverageSensor(FplEntity): class BudgetDailyAverageSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
@@ -26,21 +38,22 @@ class BudgetDailyAverageSensor(FplEntity):
@property @property
def state(self): def state(self):
return self.getData("budget_billing_daily_avg") try:
self._state= self.getData("budget_billing_daily_avg")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:currency-usd" return "mdi:currency-usd"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Budget Daily Average"
attributes["device_class"] = "monitary"
attributes["state_class"] = "total"
attributes["unit_of_measurement"] = "$"
return attributes
class ActualDailyAverageSensor(FplEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Actual Daily Average")
@property
def state(self):
return self.getData("daily_avg")
@property
def icon(self):
return "mdi:currency-usd"

View File

@@ -9,19 +9,34 @@ class FplDailyUsageSensor(FplEntity):
def state(self): def state(self):
data = self.getData("daily_usage") data = self.getData("daily_usage")
if len(data) > 0: try:
return data[-1]["cost"] self._state = data[-1]["cost"]
except:
return None pass
return self._state
def defineAttributes(self): def defineAttributes(self):
"""Return the state attributes.""" """Return the state attributes."""
data = self.getData("daily_usage") data = self.getData("daily_usage")
attributes = {}
if len(data) > 0: attributes["friendly_name"] = "Daily Usage"
return {"date": data[-1]["date"]} attributes["device_class"] = "monetary"
attributes["state_class"] = "total_increasing"
return {} attributes["unit_of_measurement"] = "$"
if data is not None:
if (
(len(data) > 0)
and (data[-1] is not None)
and (data[-1]["readTime"] is not None)
):
attributes["date"] = data[-1]["readTime"]
if (
(len(data) > 1)
and (data[-2] is not None)
and (data[-2]["readTime"] is not None)
):
attributes["last_reset"] = data[-2]["readTime"]
return attributes
@property @property
def icon(self): def icon(self):
@@ -36,20 +51,122 @@ class FplDailyUsageKWHSensor(FplEntity):
def state(self): def state(self):
data = self.getData("daily_usage") data = self.getData("daily_usage")
if len(data) > 0: try:
return data[-1]["usage"] self._state = data[-1]["usage"]
except:
return None pass
return self._state
def defineAttributes(self): def defineAttributes(self):
"""Return the state attributes.""" """Return the state attributes."""
data = self.getData("daily_usage") data = self.getData("daily_usage")
if len(data) > 0: attributes = {}
return {"date": data[-1]["date"]} attributes["friendly_name"] = "Daily Usage"
attributes["device_class"] = "energy"
attributes["state_class"] = "total_increasing"
attributes["unit_of_measurement"] = "kWh"
return {} if data is not None:
if (
(len(data) > 0)
and (data[-1] is not None)
and (data[-1]["readTime"] is not None)
):
attributes["date"] = data[-1]["readTime"]
if (
(len(data) > 1)
and (data[-2] is not None)
and (data[-2]["readTime"] is not None)
):
attributes["last_reset"] = data[-2]["readTime"]
return attributes
@property @property
def icon(self): def icon(self):
return "mdi:currency-usd" return "mdi:flash"
class FplDailyReceivedKWHSensor(FplEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Daily Received KWH")
@property
def state(self):
data = self.getData("daily_usage")
try:
self._state = data[-1]["netReceivedKwh"]
except:
pass
return self._state
def defineAttributes(self):
"""Return the state attributes."""
data = self.getData("daily_usage")
attributes = {}
attributes["friendly_name"] = "Daily Return to Grid"
attributes["device_class"] = "energy"
attributes["state_class"] = "total_increasing"
attributes["unit_of_measurement"] = "kWh"
if data is not None:
if (
(len(data) > 0)
and (data[-1] is not None)
and (data[-1]["readTime"] is not None)
):
attributes["date"] = data[-1]["readTime"]
if (
(len(data) > 1)
and (data[-2] is not None)
and (data[-2]["readTime"] is not None)
):
attributes["last_reset"] = data[-2]["readTime"]
return attributes
@property
def icon(self):
return "mdi:flash"
class FplDailyDeliveredKWHSensor(FplEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Daily Delivered KWH")
@property
def state(self):
data = self.getData("daily_usage")
try:
self._state = data[-1]["netDeliveredKwh"]
except:
pass
return self._state
def defineAttributes(self):
"""Return the state attributes."""
data = self.getData("daily_usage")
attributes = {}
attributes["friendly_name"] = "Daily Consumption"
attributes["device_class"] = "energy"
attributes["state_class"] = "total_increasing"
attributes["unit_of_measurement"] = "kWh"
if data is not None:
if (
(len(data) > 0)
and (data[-1] is not None)
and (data[-1]["readTime"] is not None)
):
attributes["date"] = data[-1]["readTime"]
if (
(len(data) > 1)
and (data[-2] is not None)
and (data[-2]["readTime"] is not None)
):
attributes["last_reset"] = data[-2]["readTime"]
return attributes
@property
def icon(self):
return "mdi:flash"

View File

@@ -1,66 +1,117 @@
from .fplEntity import FplEntity from .fplEntity import FplEntity
import datetime
class CurrentBillDateSensor(FplEntity): class CurrentBillDateSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Current Bill Date") super().__init__(coordinator, config, account, "Billing Current Date")
@property @property
def state(self): def state(self):
return self.getData("current_bill_date") try:
self._state= datetime.date.fromisoformat(self.getData("current_bill_date"))
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:calendar" return "mdi:calendar"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["device_class"] = "date"
attributes["friendly_name"] = "Billing Current"
return attributes
class NextBillDateSensor(FplEntity): class NextBillDateSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Next Bill Date") super().__init__(coordinator, config, account, "Billing Next")
@property @property
def state(self): def state(self):
return self.getData("next_bill_date") try:
self._state= datetime.date.fromisoformat(self.getData("next_bill_date"))
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:calendar" return "mdi:calendar"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["device_class"] = "date"
attributes["friendly_name"] = "Billing Next"
return attributes
class ServiceDaysSensor(FplEntity): class ServiceDaysSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Service Days") super().__init__(coordinator, config, account, "Billing Total Days")
@property @property
def state(self): def state(self):
return self.getData("service_days") try:
self._state= self.getData("service_days")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:calendar" return "mdi:calendar"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["unit_of_measurement"] = "days"
attributes["friendly_name"] = "Billing Total"
return attributes
class AsOfDaysSensor(FplEntity): class AsOfDaysSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "As Of Days") super().__init__(coordinator, config, account, "Billing As Of")
@property @property
def state(self): def state(self):
return self.getData("as_of_days") try:
self._state= self.getData("as_of_days")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:calendar" return "mdi:calendar"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["unit_of_measurement"] = "days"
attributes["friendly_name"] = "Billing As Of"
return attributes
class RemainingDaysSensor(FplEntity): class RemainingDaysSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Remaining Days") super().__init__(coordinator, config, account, "Billing Remaining")
@property @property
def state(self): def state(self):
return self.getData("remaining_days") try:
self._state= self.getData("remaining_days")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:calendar" return "mdi:calendar"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["unit_of_measurement"] = "days"
attributes["friendly_name"] = "Billing Remaining"
return attributes

View File

@@ -3,62 +3,140 @@ from .fplEntity import FplEntity
class ProjectedKWHSensor(FplEntity): class ProjectedKWHSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Projected KWH") super().__init__(coordinator, config, account, "Projected")
@property @property
def state(self): def state(self):
return self.getData("projectedKWH") try:
self._state = self.getData("projectedKWH")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:flash" return "mdi:flash"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Projected KWH"
attributes["device_class"] = "energy"
attributes["state_class"] = "total"
attributes["unit_of_measurement"] = "kWh"
return attributes
class DailyAverageKWHSensor(FplEntity): class DailyAverageKWHSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Daily Average KWH") super().__init__(coordinator, config, account, "Daily Average")
@property @property
def state(self): def state(self):
return self.getData("dailyAverageKWH") try:
self._state = self.getData("dailyAverageKWH")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:flash" return "mdi:flash"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Daily Average"
attributes["device_class"] = "energy"
attributes["state_class"] = "total"
attributes["unit_of_measurement"] = "kWh"
return attributes
class BillToDateKWHSensor(FplEntity): class BillToDateKWHSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Bill To Date KWH") super().__init__(coordinator, config, account, "Bill To Date")
@property @property
def state(self): def state(self):
return self.getData("billToDateKWH") try:
self._state = self.getData("billToDateKWH")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:flash" return "mdi:flash"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Billing Usage"
attributes["device_class"] = "energy"
attributes["state_class"] = "total_increasing"
attributes["unit_of_measurement"] = "kWh"
if self.getData("billStartDate") is not None:
attributes["last_reset"] = self.getData("billStartDate")
return attributes
class NetReceivedKWHSensor(FplEntity): class NetReceivedKWHSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Received Meter Reading KWH") super().__init__(coordinator, config, account, "Received Reading")
@property @property
def state(self): def state(self):
return self.getData("recMtrReading") try:
self._state = self.getData("recMtrReading")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:flash" return "mdi:flash"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Meter Return to Grid"
attributes["device_class"] = "energy"
attributes["state_class"] = "total_increasing"
attributes["unit_of_measurement"] = "kWh"
if self.getData("billStartDate") is not None:
attributes["last_reset"] = self.getData("billStartDate")
return attributes
class NetDeliveredKWHSensor(FplEntity): class NetDeliveredKWHSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Delivered Meter Reading KWH") super().__init__(coordinator, config, account, "Delivered Reading")
@property @property
def state(self): def state(self):
return self.getData("delMtrReading") try:
self._state = self.getData("delMtrReading")
except:
try:
self._state = self.getData("billToDateKWH")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:flash" return "mdi:flash"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Meter Consumption"
attributes["device_class"] = "energy"
attributes["state_class"] = "total_increasing"
attributes["unit_of_measurement"] = "kWh"
if self.getData("billStartDate") is not None:
attributes["last_reset"] = self.getData("billStartDate")
return attributes

View File

@@ -10,20 +10,22 @@ class FplProjectedBillSensor(FplEntity):
budget = self.getData("budget_bill") budget = self.getData("budget_bill")
budget_billing_projected_bill = self.getData("budget_billing_projected_bill") budget_billing_projected_bill = self.getData("budget_billing_projected_bill")
try:
if budget == True and budget_billing_projected_bill is not None: if budget == True and budget_billing_projected_bill is not None:
return self.getData("budget_billing_projected_bill") self._state = self.getData("budget_billing_projected_bill")
else:
return self.getData("projected_bill") self._state = self.getData("projected_bill")
except:
self._state = None
return self._state
def defineAttributes(self): def defineAttributes(self):
"""Return the state attributes.""" """Return the state attributes."""
attributes = {} attributes = {}
try: attributes["friendly_name"] = "Projected Bill Payment Due"
if self.getData("budget_bill") == True: attributes["device_class"] = "monetary"
attributes["budget_bill"] = self.getData("budget_bill") attributes["state_class"] = "total"
except: attributes["unit_of_measurement"] = "$"
pass
return attributes return attributes
@property @property
@@ -34,18 +36,30 @@ class FplProjectedBillSensor(FplEntity):
# Defered Amount # Defered Amount
class DeferedAmountSensor(FplEntity): class DeferedAmountSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Defered Amount") super().__init__(coordinator, config, account, "Deferred Amount")
@property @property
def state(self): def state(self):
if self.getData("budget_bill") == True: try:
return self.getData("defered_amount") self._state = self.getData("deferred_amount")
return 0 except:
self._state = 0
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:currency-usd" return "mdi:currency-usd"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Deferred Amount"
attributes["device_class"] = "monetary"
attributes["state_class"] = "total"
attributes["unit_of_measurement"] = "$"
return attributes
class ProjectedBudgetBillSensor(FplEntity): class ProjectedBudgetBillSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
@@ -53,12 +67,25 @@ class ProjectedBudgetBillSensor(FplEntity):
@property @property
def state(self): def state(self):
return self.getData("budget_billing_projected_bill") try:
self._state = self.getData("budget_billing_projected_bill")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:currency-usd" return "mdi:currency-usd"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Projected Budget Bill"
attributes["device_class"] = "monitary"
attributes["state_class"] = "total"
attributes["unit_of_measurement"] = "$"
return attributes
class ProjectedActualBillSensor(FplEntity): class ProjectedActualBillSensor(FplEntity):
def __init__(self, coordinator, config, account): def __init__(self, coordinator, config, account):
@@ -66,8 +93,22 @@ class ProjectedActualBillSensor(FplEntity):
@property @property
def state(self): def state(self):
return self.getData("projected_bill") try:
self._state = self.getData("projected_bill")
except:
pass
return self._state
@property @property
def icon(self): def icon(self):
return "mdi:currency-usd" return "mdi:currency-usd"
def defineAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["friendly_name"] = "Projected Actual Bill"
attributes["device_class"] = "monitary"
attributes["state_class"] = "total"
attributes["unit_of_measurement"] = "$"
return attributes