Merge branch 'master' into dev

This commit is contained in:
Yordan Suarez
2022-07-21 20:46:49 -04:00
12 changed files with 975 additions and 29 deletions

View File

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

View File

@@ -30,16 +30,17 @@ class FplEntity(CoordinatorEntity, SensorEntity):
DOMAIN, self.account, self.sensorName.lower().replace(" ", "")
)
@property
def name(self):
return f"{DOMAIN.upper()} {self.account} {self.sensorName}"
@property
def device_info(self):
return {
"identifiers": {(DOMAIN, self.account)},
"name": f"FPL Account {self.account}",
<<<<<<< HEAD:custom_components/fpl1/fplEntity.py
"model": VERSION,
=======
"model": "FPL Monitoring API",
"sw_version": VERSION,
>>>>>>> master:custom_components/fpl/fplEntity.py
"manufacturer": "Florida Power & Light",
}

View File

@@ -12,5 +12,6 @@
"integrationhelper"
],
"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"
}

View File

@@ -23,7 +23,6 @@ from .sensor_ProjectedBillSensor import (
from .sensor_AverageDailySensor import (
DailyAverageSensor,
BudgetDailyAverageSensor,
ActualDailyAverageSensor,
)
from .sensor_DailyUsageSensor import (
FplDailyUsageKWHSensor,
@@ -31,6 +30,10 @@ from .sensor_DailyUsageSensor import (
FplDailyDeliveredKWHSensor,
FplDailyReceivedKWHSensor,
)
<<<<<<< HEAD:custom_components/fpl1/sensor.py
=======
>>>>>>> master:custom_components/fpl/sensor.py
from .const import DOMAIN
# from .TestSensor import TestSensor
@@ -56,10 +59,10 @@ async def async_setup_entry(hass, entry, async_add_devices):
# usage sensors
fpl_accounts.append(DailyAverageSensor(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(FplDailyUsageKWHSensor(coordinator, entry, account))
fpl_accounts.append(FplDailyReceivedKWHSensor(coordinator, entry, account))
fpl_accounts.append(FplDailyDeliveredKWHSensor(coordinator, entry, account))
# date sensors
fpl_accounts.append(CurrentBillDateSensor(coordinator, entry, account))
@@ -72,6 +75,9 @@ async def async_setup_entry(hass, entry, async_add_devices):
fpl_accounts.append(ProjectedKWHSensor(coordinator, entry, account))
fpl_accounts.append(DailyAverageKWHSensor(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(NetDeliveredKWHSensor(coordinator, entry, account))

View File

@@ -17,14 +17,36 @@ class DailyAverageSensor(FplMoneyEntity):
if budget and budget_billing_projected_bill is not None:
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"
<<<<<<< HEAD:custom_components/fpl1/sensor_AverageDailySensor.py
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL
return attributes
=======
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
>>>>>>> master:custom_components/fpl/sensor_AverageDailySensor.py
class BudgetDailyAverageSensor(FplMoneyEntity):
"""budget daily average sensor"""
@@ -34,14 +56,22 @@ class BudgetDailyAverageSensor(FplMoneyEntity):
@property
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:custom_components/fpl1/sensor_AverageDailySensor.py
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL
return attributes
=======
<<<<<<< HEAD
>>>>>>> master:custom_components/fpl/sensor_AverageDailySensor.py
class ActualDailyAverageSensor(FplMoneyEntity):
"""Actual daily average sensor"""
@@ -52,9 +82,27 @@ class ActualDailyAverageSensor(FplMoneyEntity):
@property
def state(self):
return self.getData("daily_avg")
<<<<<<< HEAD:custom_components/fpl1/sensor_AverageDailySensor.py
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL
return attributes
=======
=======
@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
>>>>>>> master:custom_components/fpl/sensor_AverageDailySensor.py

View File

@@ -1,48 +1,153 @@
<<<<<<< HEAD:custom_components/fpl1/sensor_DatesSensor.py
"""dates sensors"""
import datetime
from .fplEntity import FplDateEntity, FplDayEntity
=======
<<<<<<< HEAD
from .fplEntity import FplDateEntity
>>>>>>> master:custom_components/fpl/sensor_DatesSensor.py
=======
from .fplEntity import FplEntity
import datetime
>>>>>>> master
class CurrentBillDateSensor(FplDateEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Current Bill Date")
super().__init__(coordinator, config, account, "Billing Current Date")
@property
def state(self):
<<<<<<< HEAD:custom_components/fpl1/sensor_DatesSensor.py
return datetime.date.fromisoformat(self.getData("current_bill_date"))
=======
try:
self._state= datetime.date.fromisoformat(self.getData("current_bill_date"))
except:
pass
return self._state
>>>>>>> master:custom_components/fpl/sensor_DatesSensor.py
<<<<<<< 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):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Next Bill Date")
super().__init__(coordinator, config, account, "Billing Next")
@property
def state(self):
<<<<<<< HEAD:custom_components/fpl1/sensor_DatesSensor.py
return datetime.date.fromisoformat(self.getData("next_bill_date"))
class ServiceDaysSensor(FplDayEntity):
=======
try:
self._state= datetime.date.fromisoformat(self.getData("next_bill_date"))
except:
pass
return self._state
<<<<<<< HEAD
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
>>>>>>> master:custom_components/fpl/sensor_DatesSensor.py
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Service Days")
super().__init__(coordinator, config, account, "Billing Total Days")
@property
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(FplDayEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "As Of Days")
super().__init__(coordinator, config, account, "Billing As Of")
@property
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(FplDayEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Remaining Days")
super().__init__(coordinator, config, account, "Billing Remaining")
@property
def state(self):
<<<<<<< HEAD
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

View File

@@ -10,11 +10,15 @@ from .fplEntity import FplEnergyEntity
class ProjectedKWHSensor(FplEnergyEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Projected KWH")
super().__init__(coordinator, config, account, "Projected")
@property
def state(self):
return self.getData("projectedKWH")
try:
self._state = self.getData("projectedKWH")
except:
pass
return self._state
def customAttributes(self):
"""Return the state attributes."""
@@ -23,28 +27,69 @@ class ProjectedKWHSensor(FplEnergyEntity):
return attributes
<<<<<<< HEAD
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):
super().__init__(coordinator, config, account, "Daily Average KWH")
@property
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"
<<<<<<< HEAD:custom_components/fpl1/sensor_KWHSensor.py
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL
return attributes
=======
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
>>>>>>> master:custom_components/fpl/sensor_KWHSensor.py
class BillToDateKWHSensor(FplEnergyEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Bill To Date KWH")
super().__init__(coordinator, config, account, "Bill To Date")
@property
def state(self):
return self.getData("billToDateKWH")
try:
self._state = self.getData("billToDateKWH")
except:
pass
return self._state
def customAttributes(self):
"""Return the state attributes."""
@@ -60,13 +105,33 @@ class BillToDateKWHSensor(FplEnergyEntity):
return attributes
<<<<<<< HEAD
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):
super().__init__(coordinator, config, account, "Received Meter Reading KWH")
super().__init__(coordinator, config, account, "Received Reading")
@property
def state(self):
return self.getData("recMtrReading")
try:
self._state = self.getData("recMtrReading")
except:
pass
return self._state
def customAttributes(self):
"""Return the state attributes."""
@@ -74,17 +139,58 @@ class NetReceivedKWHSensor(FplEnergyEntity):
attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
return attributes
<<<<<<< HEAD
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):
super().__init__(coordinator, config, account, "Delivered Meter Reading KWH")
super().__init__(coordinator, config, account, "Delivered Reading")
@property
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
<<<<<<< HEAD:custom_components/fpl1/sensor_KWHSensor.py
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
=======
@property
def icon(self):
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")
>>>>>>> master:custom_components/fpl/sensor_KWHSensor.py
return attributes

View File

@@ -28,17 +28,35 @@ class FplProjectedBillSensor(FplMoneyEntity):
budget = self.getData("budget_bill")
budget_billing_projected_bill = self.getData("budget_billing_projected_bill")
<<<<<<< HEAD:custom_components/fpl1/sensor_ProjectedBillSensor.py
if budget and budget_billing_projected_bill is not None:
return self.getData("budget_billing_projected_bill")
return self.getData("projected_bill")
"""
=======
try:
if budget == True and budget_billing_projected_bill is not None:
self._state = self.getData("budget_billing_projected_bill")
else:
self._state = self.getData("projected_bill")
except:
self._state = None
return self._state
>>>>>>> master:custom_components/fpl/sensor_ProjectedBillSensor.py
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
<<<<<<< HEAD:custom_components/fpl1/sensor_ProjectedBillSensor.py
attributes["state_class"] = STATE_CLASS_TOTAL
attributes["budget_bill"] = self.getData("budget_bill")
=======
attributes["friendly_name"] = "Projected Bill Payment Due"
attributes["device_class"] = "monetary"
attributes["state_class"] = "total"
attributes["unit_of_measurement"] = "$"
>>>>>>> master:custom_components/fpl/sensor_ProjectedBillSensor.py
return attributes
@@ -47,10 +65,11 @@ class DeferedAmountSensor(FplMoneyEntity):
"""Defered amount sensor"""
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Defered Amount")
super().__init__(coordinator, config, account, "Deferred Amount")
@property
def state(self):
<<<<<<< HEAD:custom_components/fpl1/sensor_ProjectedBillSensor.py
if self.getData("budget_bill"):
return self.getData("defered_amount")
return 0
@@ -61,6 +80,31 @@ class DeferedAmountSensor(FplMoneyEntity):
attributes["state_class"] = STATE_CLASS_TOTAL
return attributes
=======
try:
self._state = self.getData("deferred_amount")
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
>>>>>>> master:custom_components/fpl/sensor_ProjectedBillSensor.py
class ProjectedBudgetBillSensor(FplMoneyEntity):
"""projected budget bill sensor"""
@@ -70,14 +114,37 @@ class ProjectedBudgetBillSensor(FplMoneyEntity):
@property
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
<<<<<<< HEAD:custom_components/fpl1/sensor_ProjectedBillSensor.py
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL
return attributes
=======
>>>>>>> master
>>>>>>> master:custom_components/fpl/sensor_ProjectedBillSensor.py
class ProjectedActualBillSensor(FplMoneyEntity):
"""projeted actual bill sensor"""
@@ -87,10 +154,35 @@ class ProjectedActualBillSensor(FplMoneyEntity):
@property
def state(self):
<<<<<<< HEAD
return self.getData("projected_bill")
<<<<<<< HEAD:custom_components/fpl1/sensor_ProjectedBillSensor.py
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
attributes["state_class"] = STATE_CLASS_TOTAL
return attributes
=======
=======
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
>>>>>>> master:custom_components/fpl/sensor_ProjectedBillSensor.py