Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating all references to deprecation warnings for 2025.1 #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions custom_components/fpl/fplEntity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

from datetime import datetime, timedelta

from homeassistant.components.sensor import SensorEntity, STATE_CLASS_MEASUREMENT
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
from homeassistant.helpers.update_coordinator import CoordinatorEntity

from homeassistant.const import (
CURRENCY_DOLLAR,
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
DEVICE_CLASS_MONETARY,
UnitOfEnergy,
)
from .const import DOMAIN, VERSION, ATTRIBUTION

Expand Down Expand Up @@ -70,8 +68,8 @@ def getData(self, field):
class FplEnergyEntity(FplEntity):
"""Represents a energy sensor"""

_attr_native_unit_of_measurement = ENERGY_KILO_WATT_HOUR
# _attr_device_class = DEVICE_CLASS_ENERGY
_attr_native_unit_of_measurement = UnitOfEnergy.KILO_WATT_HOUR
# _attr_device_class = SensorDeviceClass.ENERGY
_attr_icon = "mdi:flash"

@property
Expand All @@ -87,7 +85,7 @@ class FplMoneyEntity(FplEntity):
"""Represents a money sensor"""

_attr_native_unit_of_measurement = CURRENCY_DOLLAR
_attr_device_class = DEVICE_CLASS_MONETARY
_attr_device_class = SensorDeviceClass.MONETARY
_attr_icon = "mdi:currency-usd"


Expand Down
7 changes: 4 additions & 3 deletions custom_components/fpl/sensor_AverageDailySensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Average daily sensors"""
from .fplEntity import FplMoneyEntity

from homeassistant.components.sensor import SensorStateClass

class DailyAverageSensor(FplMoneyEntity):
"""average daily sensor, use budget value if available, otherwise use actual daily values"""
Expand All @@ -20,7 +21,7 @@ def native_value(self):
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
# attributes["state_class"] = STATE_CLASS_TOTAL
# attributes["state_class"] = SensorStateClass.TOTAL
return attributes


Expand All @@ -42,7 +43,7 @@ def native_value(self):
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
# attributes["state_class"] = STATE_CLASS_TOTAL
# attributes["state_class"] = SensorStateClass.TOTAL
return attributes


Expand All @@ -64,5 +65,5 @@ def native_value(self):
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
# attributes["state_class"] = STATE_CLASS_TOTAL
# attributes["state_class"] = SensorStateClass.TOTAL
return attributes
16 changes: 8 additions & 8 deletions custom_components/fpl/sensor_DailyUsageSensor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Daily Usage Sensors"""
from datetime import timedelta, datetime
from homeassistant.components.sensor import (
STATE_CLASS_TOTAL_INCREASING,
DEVICE_CLASS_ENERGY,
SensorDeviceClass,
SensorStateClass,
)
from .fplEntity import FplEnergyEntity, FplMoneyEntity

Expand All @@ -26,7 +26,7 @@ def customAttributes(self):
"""Return the state attributes."""
data = self.getData("daily_usage")
attributes = {}
# attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
# attributes["state_class"] = SensorStateClass.TOTAL_INCREASING
if data is not None and len(data) > 0 and "readTime" in data[-1].keys():
attributes["date"] = data[-1]["readTime"]

Expand All @@ -39,8 +39,8 @@ class FplDailyUsageKWHSensor(FplEnergyEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Daily Usage KWH")

_attr_state_class = STATE_CLASS_TOTAL_INCREASING
_attr_device_class = DEVICE_CLASS_ENERGY
_attr_state_class = SensorStateClass.TOTAL_INCREASING
_attr_device_class = SensorDeviceClass.ENERGY

@property
def native_value(self):
Expand Down Expand Up @@ -69,7 +69,7 @@ def customAttributes(self):
# last_reset = date - timedelta(days=1)

attributes = {}
# attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
# attributes["state_class"] = SensorStateClass.TOTAL_INCREASING
# attributes["date"] = date
# attributes["last_reset"] = last_reset
return attributes
Expand All @@ -81,7 +81,7 @@ class FplDailyReceivedKWHSensor(FplEnergyEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Daily Received KWH")

# _attr_state_class = STATE_CLASS_TOTAL_INCREASING
# _attr_state_class = SensorStateClass.TOTAL_INCREASING

@property
def native_value(self):
Expand All @@ -108,7 +108,7 @@ def customAttributes(self):
class FplDailyDeliveredKWHSensor(FplEnergyEntity):
"""daily delivered Kwh sensor"""

# _attr_state_class = STATE_CLASS_TOTAL_INCREASING
# _attr_state_class = SensorStateClass.TOTAL_INCREASING

def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Daily Delivered KWH")
Expand Down
4 changes: 2 additions & 2 deletions custom_components/fpl/sensor_DatesSensor.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""dates sensors"""
import datetime
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT
from homeassistant.components.sensor import SensorStateClass
from .fplEntity import FplDateEntity, FplDayEntity


Expand Down Expand Up @@ -42,7 +42,7 @@ class ServiceDaysSensor(FplDayEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Service Days")

_attr_state_class = STATE_CLASS_MEASUREMENT
_attr_state_class = SensorStateClass.MEASUREMENT

@property
def native_value(self):
Expand Down
17 changes: 8 additions & 9 deletions custom_components/fpl/sensor_KWHSensor.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
"""energy sensors"""
from datetime import date, timedelta
from homeassistant.components.sensor import (
STATE_CLASS_TOTAL_INCREASING,
STATE_CLASS_TOTAL,
DEVICE_CLASS_ENERGY,
SensorDeviceClass,
SensorStateClass,
)
from .fplEntity import FplEnergyEntity

Expand All @@ -26,7 +25,7 @@ def native_value(self):
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
# attributes["state_class"] = STATE_CLASS_TOTAL
# attributes["state_class"] = SensorStateClass.TOTAL
return attributes


Expand All @@ -48,7 +47,7 @@ def native_value(self):
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
# attributes["state_class"] = STATE_CLASS_TOTAL
# attributes["state_class"] = SensorStateClass.TOTAL
return attributes


Expand All @@ -58,8 +57,8 @@ class BillToDateKWHSensor(FplEnergyEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Bill To Date KWH")

_attr_state_class = STATE_CLASS_TOTAL_INCREASING
_attr_device_class = DEVICE_CLASS_ENERGY
_attr_state_class = SensorStateClass.TOTAL_INCREASING
_attr_device_class = SensorDeviceClass.ENERGY

@property
def native_value(self):
Expand Down Expand Up @@ -91,7 +90,7 @@ def native_value(self):
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
# attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
# attributes["state_class"] = SensorStateClass.TOTAL_INCREASING
return attributes


Expand All @@ -113,5 +112,5 @@ def native_value(self):
def customAttributes(self):
"""Return the state attributes."""
attributes = {}
# attributes["state_class"] = STATE_CLASS_TOTAL_INCREASING
# attributes["state_class"] = SensorStateClass.TOTAL_INCREASING
return attributes
16 changes: 7 additions & 9 deletions custom_components/fpl/sensor_ProjectedBillSensor.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"""Projected bill sensors"""
from homeassistant.components.sensor import (
# STATE_CLASS_TOTAL_INCREASING,
STATE_CLASS_TOTAL,
)
# from homeassistant.components.sensor import SensorStateClass.TOTAL

from .fplEntity import FplMoneyEntity


class FplProjectedBillSensor(FplMoneyEntity):
"""Projected bill sensor"""

# _attr_state_class = STATE_CLASS_TOTAL
# _attr_state_class = SensorStateClass.TOTAL

def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Projected Bill")
Expand Down Expand Up @@ -40,7 +38,7 @@ def customAttributes(self):
class DeferedAmountSensor(FplMoneyEntity):
"""Defered amount sensor"""

# _attr_state_class = STATE_CLASS_TOTAL
# _attr_state_class = SensorStateClass.TOTAL

def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Defered Amount")
Expand All @@ -59,7 +57,7 @@ def native_value(self):
class ProjectedBudgetBillSensor(FplMoneyEntity):
"""projected budget bill sensor"""

# _attr_state_class = STATE_CLASS_TOTAL
# _attr_state_class = SensorStateClass.TOTAL

def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Projected Budget Bill")
Expand All @@ -77,7 +75,7 @@ def native_value(self):
class ProjectedActualBillSensor(FplMoneyEntity):
"""projeted actual bill sensor"""

# _attr_state_class = STATE_CLASS_TOTAL
# _attr_state_class = SensorStateClass.TOTAL

def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Projected Actual Bill")
Expand All @@ -95,7 +93,7 @@ def native_value(self):
class BillToDateSensor(FplMoneyEntity):
"""projeted actual bill sensor"""

# _attr_state_class = STATE_CLASS_TOTAL
# _attr_state_class = SensorStateClass.TOTAL

def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Bill To Date")
Expand Down
8 changes: 4 additions & 4 deletions custom_components/fpl/sensor_test.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Test Sensors"""
from datetime import timedelta, datetime
from homeassistant.components.sensor import (
STATE_CLASS_TOTAL_INCREASING,
DEVICE_CLASS_ENERGY,
SensorDeviceClass,
SensorStateClass,
)
from homeassistant.core import callback
from homeassistant.const import STATE_UNKNOWN
Expand All @@ -15,8 +15,8 @@ class TestSensor(FplEnergyEntity):
def __init__(self, coordinator, config, account):
super().__init__(coordinator, config, account, "Test Sensor")

_attr_state_class = STATE_CLASS_TOTAL_INCREASING
_attr_device_class = DEVICE_CLASS_ENERGY
_attr_state_class = SensorStateClass.TOTAL_INCREASING
_attr_device_class = SensorDeviceClass.ENERGY

@property
def native_value(self):
Expand Down
Loading