Skip to content

Commit

Permalink
Merge branch 'master' into adding_power_control
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSoethout authored Mar 20, 2024
2 parents 3482ba8 + 7f66ef6 commit 884f521
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
38 changes: 20 additions & 18 deletions custom_components/sems/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
DataUpdateCoordinator,
UpdateFailed,
)
from homeassistant.components.sensor import STATE_CLASS_TOTAL_INCREASING, SensorEntity
from homeassistant.components.sensor import (
SensorEntity,
SensorDeviceClass,
SensorStateClass,
)
from homeassistant.const import (
DEVICE_CLASS_POWER,
POWER_WATT,
CONF_SCAN_INTERVAL,
DEVICE_CLASS_ENERGY,
ENERGY_KILO_WATT_HOUR,
UnitOfPower,
UnitOfEnergy,
)
from .const import DOMAIN, CONF_STATION_ID, DEFAULT_SCAN_INTERVAL

Expand Down Expand Up @@ -157,11 +159,11 @@ def __init__(self, coordinator, sn):

@property
def device_class(self):
return DEVICE_CLASS_POWER
return SensorDeviceClass.POWER_FACTOR

@property
def unit_of_measurement(self):
return POWER_WATT
return UnitOfPower.WATT

@property
def name(self) -> str:
Expand Down Expand Up @@ -253,11 +255,11 @@ def __init__(self, coordinator, sn):

@property
def device_class(self):
return DEVICE_CLASS_ENERGY
return SensorDeviceClass.ENERGY

@property
def unit_of_measurement(self):
return ENERGY_KILO_WATT_HOUR
return UnitOfEnergy.KILO_WATT_HOUR

@property
def name(self) -> str:
Expand Down Expand Up @@ -303,7 +305,7 @@ def device_info(self):
@property
def state_class(self):
"""used by Metered entities / Long Term Statistics"""
return STATE_CLASS_TOTAL_INCREASING
return SensorStateClass.TOTAL_INCREASING

async def async_added_to_hass(self):
"""When entity is added to hass."""
Expand All @@ -330,11 +332,11 @@ def __init__(self, coordinator, sn):

@property
def device_class(self):
return DEVICE_CLASS_ENERGY
return SensorDeviceClass.ENERGY

@property
def unit_of_measurement(self):
return ENERGY_KILO_WATT_HOUR
return UnitOfEnergy.KILO_WATT_HOUR

@property
def name(self) -> str:
Expand Down Expand Up @@ -374,7 +376,7 @@ def device_info(self):
@property
def state_class(self):
"""used by Metered entities / Long Term Statistics"""
return STATE_CLASS_TOTAL_INCREASING
return SensorStateClass.TOTAL_INCREASING

async def async_added_to_hass(self):
"""When entity is added to hass."""
Expand All @@ -401,11 +403,11 @@ def __init__(self, coordinator, sn):

@property
def device_class(self):
return DEVICE_CLASS_ENERGY
return SensorDeviceClass.ENERGY

@property
def unit_of_measurement(self):
return ENERGY_KILO_WATT_HOUR
return UnitOfEnergy.KILO_WATT_HOUR

@property
def name(self) -> str:
Expand Down Expand Up @@ -444,7 +446,7 @@ def device_info(self):
@property
def state_class(self):
"""used by Metered entities / Long Term Statistics"""
return STATE_CLASS_TOTAL_INCREASING
return SensorStateClass.TOTAL_INCREASING

async def async_added_to_hass(self):
"""When entity is added to hass."""
Expand Down Expand Up @@ -477,11 +479,11 @@ def __init__(self, coordinator, sn):

@property
def device_class(self):
return DEVICE_CLASS_POWER
return SensorDeviceClass.POWER_FACTOR

@property
def unit_of_measurement(self):
return POWER_WATT
return UnitOfPower.WATT

@property
def name(self) -> str:
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"render_readme": true,
"content_in_root": false,
"iot_class": "Cloud Poll",
"homeassistant": "2021.9.3"
"homeassistant": "2021.12.1"
}

0 comments on commit 884f521

Please sign in to comment.