Merge remote-tracking branch 'origin/master'
This commit is contained in:
36
custom_components/fpl/ProjectedBillSensor.py
Normal file
36
custom_components/fpl/ProjectedBillSensor.py
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
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
|
||||||
|
try:
|
||||||
|
if "budget_bill" in data.keys():
|
||||||
|
if data["budget_bill"]:
|
||||||
|
if "budget_billing_projected_bill" in data.keys():
|
||||||
|
self._state = data["budget_billing_projected_bill"]
|
||||||
|
else:
|
||||||
|
if "projected_bill" in data.keys():
|
||||||
|
self._state = data["projected_bill"]
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
return self._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._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
return "mdi:currency-usd"
|
||||||
@@ -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",
|
||||||
|
|||||||
@@ -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__)
|
||||||
|
|
||||||
|
|||||||
@@ -29,16 +29,13 @@ class FplEntity(CoordinatorEntity, SensorEntity):
|
|||||||
)
|
)
|
||||||
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",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -298,6 +298,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"])
|
||||||
@@ -310,6 +313,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:
|
||||||
|
|||||||
@@ -11,6 +11,12 @@
|
|||||||
"requirements": [
|
"requirements": [
|
||||||
"integrationhelper"
|
"integrationhelper"
|
||||||
],
|
],
|
||||||
|
<<<<<<< HEAD
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"issue_tracker": "https://github.com/dotKrad/hass-fpl/issues"
|
"issue_tracker": "https://github.com/dotKrad/hass-fpl/issues"
|
||||||
|
=======
|
||||||
|
"homeassistant": "2021.12.7",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"issue_tracker" : "https://github.com/dotKrad/hass-fpl/issues"
|
||||||
|
>>>>>>> master
|
||||||
}
|
}
|
||||||
@@ -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 .TestSensor import TestSensor
|
from .TestSensor import TestSensor
|
||||||
@@ -51,10 +56,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))
|
||||||
@@ -67,6 +72,9 @@ 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))
|
||||||
|
|
||||||
|
|
||||||
fpl_accounts.append(NetReceivedKWHSensor(coordinator, entry, account))
|
fpl_accounts.append(NetReceivedKWHSensor(coordinator, entry, account))
|
||||||
fpl_accounts.append(NetDeliveredKWHSensor(coordinator, entry, account))
|
fpl_accounts.append(NetDeliveredKWHSensor(coordinator, entry, account))
|
||||||
|
|||||||
33
custom_components/fpl/sensor_AllData.py
Normal file
33
custom_components/fpl/sensor_AllData.py
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
from .fplEntity import FplEntity
|
||||||
|
|
||||||
|
|
||||||
|
class AllDataSensor(FplEntity):
|
||||||
|
def __init__(self, coordinator, config, account):
|
||||||
|
super().__init__(coordinator, config, account, "")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state(self):
|
||||||
|
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:
|
||||||
|
return self.getData("budget_billing_projected_bill")
|
||||||
|
|
||||||
|
try:
|
||||||
|
self._state=self.getData("projected_bill")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
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
|
||||||
@@ -13,8 +13,27 @@ class FplAverageDailySensor(FplMoneyEntity):
|
|||||||
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
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
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
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
class BudgetDailyAverageSensor(FplMoneyEntity):
|
class BudgetDailyAverageSensor(FplMoneyEntity):
|
||||||
def __init__(self, coordinator, config, account):
|
def __init__(self, coordinator, config, account):
|
||||||
@@ -22,8 +41,13 @@ class BudgetDailyAverageSensor(FplMoneyEntity):
|
|||||||
|
|
||||||
@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
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
class ActualDailyAverageSensor(FplMoneyEntity):
|
class ActualDailyAverageSensor(FplMoneyEntity):
|
||||||
def __init__(self, coordinator, config, account):
|
def __init__(self, coordinator, config, account):
|
||||||
@@ -32,3 +56,18 @@ class ActualDailyAverageSensor(FplMoneyEntity):
|
|||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
return self.getData("daily_avg")
|
return self.getData("daily_avg")
|
||||||
|
=======
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
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
|
||||||
|
|
||||||
|
>>>>>>> master
|
||||||
|
|||||||
@@ -9,19 +9,34 @@ class FplDailyUsageSensor(FplMoneyEntity):
|
|||||||
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
|
||||||
|
|
||||||
|
|
||||||
class FplDailyUsageKWHSensor(FplEnergyEntity):
|
class FplDailyUsageKWHSensor(FplEnergyEntity):
|
||||||
@@ -32,16 +47,126 @@ class FplDailyUsageKWHSensor(FplEnergyEntity):
|
|||||||
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"
|
||||||
|
|
||||||
|
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 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")
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
return {}
|
return {}
|
||||||
|
=======
|
||||||
|
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"
|
||||||
|
>>>>>>> master
|
||||||
|
|||||||
@@ -1,46 +1,136 @@
|
|||||||
|
<<<<<<< HEAD
|
||||||
from .fplEntity import FplDateEntity
|
from .fplEntity import FplDateEntity
|
||||||
|
|
||||||
|
=======
|
||||||
|
from .fplEntity import FplEntity
|
||||||
|
import datetime
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
class CurrentBillDateSensor(FplDateEntity):
|
class CurrentBillDateSensor(FplDateEntity):
|
||||||
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
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
return "mdi:calendar"
|
||||||
|
|
||||||
|
def defineAttributes(self):
|
||||||
|
"""Return the state attributes."""
|
||||||
|
attributes = {}
|
||||||
|
attributes["device_class"] = "date"
|
||||||
|
attributes["friendly_name"] = "Billing Current"
|
||||||
|
return attributes
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
class NextBillDateSensor(FplDateEntity):
|
class NextBillDateSensor(FplDateEntity):
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
class ServiceDaysSensor(FplDateEntity):
|
class ServiceDaysSensor(FplDateEntity):
|
||||||
|
=======
|
||||||
|
def defineAttributes(self):
|
||||||
|
"""Return the state attributes."""
|
||||||
|
attributes = {}
|
||||||
|
attributes["device_class"] = "date"
|
||||||
|
attributes["friendly_name"] = "Billing Next"
|
||||||
|
return attributes
|
||||||
|
|
||||||
|
class ServiceDaysSensor(FplEntity):
|
||||||
|
>>>>>>> master
|
||||||
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
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
return "mdi:calendar"
|
||||||
|
|
||||||
|
def defineAttributes(self):
|
||||||
|
"""Return the state attributes."""
|
||||||
|
attributes = {}
|
||||||
|
attributes["unit_of_measurement"] = "days"
|
||||||
|
attributes["friendly_name"] = "Billing Total"
|
||||||
|
return attributes
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
class AsOfDaysSensor(FplDateEntity):
|
class AsOfDaysSensor(FplDateEntity):
|
||||||
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
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
return "mdi:calendar"
|
||||||
|
|
||||||
|
def defineAttributes(self):
|
||||||
|
"""Return the state attributes."""
|
||||||
|
attributes = {}
|
||||||
|
attributes["unit_of_measurement"] = "days"
|
||||||
|
attributes["friendly_name"] = "Billing As Of"
|
||||||
|
return attributes
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
class RemainingDaysSensor(FplDateEntity):
|
class RemainingDaysSensor(FplDateEntity):
|
||||||
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):
|
||||||
|
<<<<<<< HEAD
|
||||||
return self.getData("remaining_days")
|
return self.getData("remaining_days")
|
||||||
|
=======
|
||||||
|
try:
|
||||||
|
self._state= self.getData("remaining_days")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
return "mdi:calendar"
|
||||||
|
|
||||||
|
def defineAttributes(self):
|
||||||
|
"""Return the state attributes."""
|
||||||
|
attributes = {}
|
||||||
|
attributes["unit_of_measurement"] = "days"
|
||||||
|
attributes["friendly_name"] = "Billing Remaining"
|
||||||
|
return attributes
|
||||||
|
>>>>>>> master
|
||||||
|
|||||||
@@ -4,56 +4,154 @@ from .fplEntity import FplEnergyEntity
|
|||||||
|
|
||||||
class ProjectedKWHSensor(FplEnergyEntity):
|
class ProjectedKWHSensor(FplEnergyEntity):
|
||||||
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
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
class DailyAverageKWHSensor(FplEnergyEntity):
|
class DailyAverageKWHSensor(FplEnergyEntity):
|
||||||
|
=======
|
||||||
|
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):
|
||||||
|
>>>>>>> master
|
||||||
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
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
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
|
||||||
|
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
class BillToDateKWHSensor(FplEnergyEntity):
|
class BillToDateKWHSensor(FplEnergyEntity):
|
||||||
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 state_class(self) -> str:
|
def state_class(self) -> str:
|
||||||
"""Return the state class of this entity, from STATE_CLASSES, if any."""
|
"""Return the state class of this entity, from STATE_CLASSES, if any."""
|
||||||
|
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
class NetReceivedKWHSensor(FplEnergyEntity):
|
class NetReceivedKWHSensor(FplEnergyEntity):
|
||||||
|
=======
|
||||||
|
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):
|
||||||
|
>>>>>>> master
|
||||||
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"
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
class NetDeliveredKWHSensor(FplEnergyEntity):
|
class NetDeliveredKWHSensor(FplEnergyEntity):
|
||||||
|
=======
|
||||||
|
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):
|
||||||
|
>>>>>>> master
|
||||||
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
|
||||||
|
|||||||
@@ -10,34 +10,55 @@ class FplProjectedBillSensor(FplMoneyEntity):
|
|||||||
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")
|
||||||
|
|
||||||
if budget == True and budget_billing_projected_bill is not None:
|
try:
|
||||||
return self.getData("budget_billing_projected_bill")
|
if budget == True and budget_billing_projected_bill is not None:
|
||||||
|
self._state = self.getData("budget_billing_projected_bill")
|
||||||
return self.getData("projected_bill")
|
else:
|
||||||
|
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
|
||||||
|
|
||||||
|
|
||||||
# Defered Amount
|
# Defered Amount
|
||||||
class DeferedAmountSensor(FplMoneyEntity):
|
class DeferedAmountSensor(FplMoneyEntity):
|
||||||
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
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
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
|
||||||
|
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
class ProjectedBudgetBillSensor(FplMoneyEntity):
|
class ProjectedBudgetBillSensor(FplMoneyEntity):
|
||||||
def __init__(self, coordinator, config, account):
|
def __init__(self, coordinator, config, account):
|
||||||
@@ -45,8 +66,28 @@ class ProjectedBudgetBillSensor(FplMoneyEntity):
|
|||||||
|
|
||||||
@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
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
|
=======
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
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
|
||||||
|
|
||||||
|
>>>>>>> master
|
||||||
|
|
||||||
class ProjectedActualBillSensor(FplMoneyEntity):
|
class ProjectedActualBillSensor(FplMoneyEntity):
|
||||||
def __init__(self, coordinator, config, account):
|
def __init__(self, coordinator, config, account):
|
||||||
@@ -54,4 +95,26 @@ class ProjectedActualBillSensor(FplMoneyEntity):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def state(self):
|
def state(self):
|
||||||
|
<<<<<<< HEAD
|
||||||
return self.getData("projected_bill")
|
return self.getData("projected_bill")
|
||||||
|
=======
|
||||||
|
try:
|
||||||
|
self._state = self.getData("projected_bill")
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return self._state
|
||||||
|
|
||||||
|
@property
|
||||||
|
def icon(self):
|
||||||
|
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
|
||||||
|
>>>>>>> master
|
||||||
|
|||||||
Reference in New Issue
Block a user