generated from dotKrad/blueprint
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from alexandrocampos/master
HA 2025.1.1 Version Broke The Connection to FPL #57
- Loading branch information
Showing
8 changed files
with
284 additions
and
312 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,73 @@ | ||
"""Average daily sensors""" | ||
from homeassistant.components.sensor import ( | ||
SensorDeviceClass, | ||
SensorStateClass, | ||
) | ||
from .fplEntity import FplMoneyEntity | ||
|
||
|
||
class DailyAverageSensor(FplMoneyEntity): | ||
"""average daily sensor, use budget value if available, otherwise use actual daily values""" | ||
"""Average daily sensor, use budget value if available, otherwise use actual daily values""" | ||
|
||
_attr_device_class = SensorDeviceClass.MONETARY | ||
_attr_state_class = SensorStateClass.MEASUREMENT | ||
|
||
def __init__(self, coordinator, config, account): | ||
super().__init__(coordinator, config, account, "Daily Average") | ||
|
||
@property | ||
def native_value(self): | ||
daily_avg = self.getData("daily_avg") | ||
|
||
if daily_avg is not None: | ||
self._attr_native_value = daily_avg | ||
|
||
return self._attr_native_value | ||
|
||
def customAttributes(self): | ||
"""Return the state attributes.""" | ||
# Add any extra attributes you want to expose here | ||
attributes = {} | ||
# attributes["state_class"] = STATE_CLASS_TOTAL | ||
return attributes | ||
|
||
|
||
class BudgetDailyAverageSensor(FplMoneyEntity): | ||
"""budget daily average sensor""" | ||
"""Budget daily average sensor""" | ||
|
||
_attr_device_class = SensorDeviceClass.MONETARY | ||
_attr_state_class = SensorStateClass.MEASUREMENT | ||
|
||
def __init__(self, coordinator, config, account): | ||
super().__init__(coordinator, config, account, "Budget Daily Average") | ||
|
||
@property | ||
def native_value(self): | ||
budget_billing_daily_avg = self.getData("budget_billing_daily_avg") | ||
|
||
if budget_billing_daily_avg is not None: | ||
self._attr_native_value = budget_billing_daily_avg | ||
|
||
return self._attr_native_value | ||
|
||
def customAttributes(self): | ||
"""Return the state attributes.""" | ||
attributes = {} | ||
# attributes["state_class"] = STATE_CLASS_TOTAL | ||
return attributes | ||
|
||
|
||
class ActualDailyAverageSensor(FplMoneyEntity): | ||
"""Actual daily average sensor""" | ||
|
||
_attr_device_class = SensorDeviceClass.MONETARY | ||
_attr_state_class = SensorStateClass.MEASUREMENT | ||
|
||
def __init__(self, coordinator, config, account): | ||
super().__init__(coordinator, config, account, "Actual Daily Average") | ||
|
||
@property | ||
def native_value(self): | ||
daily_avg = self.getData("daily_avg") | ||
|
||
if daily_avg is not None: | ||
self._attr_native_value = daily_avg | ||
|
||
return self._attr_native_value | ||
|
||
def customAttributes(self): | ||
"""Return the state attributes.""" | ||
attributes = {} | ||
# attributes["state_class"] = STATE_CLASS_TOTAL | ||
return attributes |
Oops, something went wrong.