Use UnitOfPower in integrations [s-z] (#83826)
This commit is contained in:
parent
eb6310f7bb
commit
52d4a358a0
22 changed files with 69 additions and 70 deletions
|
@ -22,9 +22,9 @@ from homeassistant.const import (
|
|||
ENERGY_KILO_WATT_HOUR,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
|
@ -97,7 +97,7 @@ SENSORS: Final = {
|
|||
("light", "power"): BlockSensorDescription(
|
||||
key="light|power",
|
||||
name="Power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
value=lambda value: round(value, 1),
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -106,7 +106,7 @@ SENSORS: Final = {
|
|||
("device", "power"): BlockSensorDescription(
|
||||
key="device|power",
|
||||
name="Power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
value=lambda value: round(value, 1),
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -114,7 +114,7 @@ SENSORS: Final = {
|
|||
("emeter", "power"): BlockSensorDescription(
|
||||
key="emeter|power",
|
||||
name="Power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
value=lambda value: round(value, 1),
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -147,7 +147,7 @@ SENSORS: Final = {
|
|||
("relay", "power"): BlockSensorDescription(
|
||||
key="relay|power",
|
||||
name="Power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
value=lambda value: round(value, 1),
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -155,7 +155,7 @@ SENSORS: Final = {
|
|||
("roller", "rollerPower"): BlockSensorDescription(
|
||||
key="roller|rollerPower",
|
||||
name="Power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
value=lambda value: round(value, 1),
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -317,7 +317,7 @@ RPC_SENSORS: Final = {
|
|||
key="switch",
|
||||
sub_key="apower",
|
||||
name="Power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
value=lambda status, _: round(float(status), 1),
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -73,7 +73,7 @@ class SMAsensor(CoordinatorEntity, SensorEntity):
|
|||
if self.native_unit_of_measurement == ENERGY_KILO_WATT_HOUR:
|
||||
self._attr_state_class = SensorStateClass.TOTAL_INCREASING
|
||||
self._attr_device_class = SensorDeviceClass.ENERGY
|
||||
if self.native_unit_of_measurement == POWER_WATT:
|
||||
if self.native_unit_of_measurement == UnitOfPower.WATT:
|
||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||
self._attr_device_class = SensorDeviceClass.POWER
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ from homeassistant.const import (
|
|||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENERGY_WATT_HOUR,
|
||||
POWER_WATT,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
|
@ -53,7 +53,7 @@ TREND_SENSORS: tuple[SmappeePollingSensorEntityDescription, ...] = (
|
|||
SmappeePollingSensorEntityDescription(
|
||||
key="total_power",
|
||||
name="Total consumption - Active power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
sensor_id="total_power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -62,7 +62,7 @@ TREND_SENSORS: tuple[SmappeePollingSensorEntityDescription, ...] = (
|
|||
SmappeePollingSensorEntityDescription(
|
||||
key="alwayson",
|
||||
name="Always on - Active power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
sensor_id="alwayson",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -104,7 +104,7 @@ REACTIVE_SENSORS: tuple[SmappeeSensorEntityDescription, ...] = (
|
|||
SmappeeSensorEntityDescription(
|
||||
key="total_reactive_power",
|
||||
name="Total consumption - Reactive power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
sensor_id="total_reactive_power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -114,7 +114,7 @@ SOLAR_SENSORS: tuple[SmappeePollingSensorEntityDescription, ...] = (
|
|||
SmappeePollingSensorEntityDescription(
|
||||
key="solar_power",
|
||||
name="Total production - Active power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
sensor_id="solar_power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
@ -254,7 +254,7 @@ async def async_setup_entry(
|
|||
description=SmappeeSensorEntityDescription(
|
||||
key="load",
|
||||
name=measurement.name,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
sensor_id=measurement_id,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
|
|
|
@ -3,7 +3,7 @@ from datetime import timedelta
|
|||
import logging
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
|
||||
from homeassistant.const import ENERGY_WATT_HOUR, PERCENTAGE, POWER_WATT
|
||||
from homeassistant.const import ENERGY_WATT_HOUR, PERCENTAGE, UnitOfPower
|
||||
|
||||
from .models import SolarEdgeSensorEntityDescription
|
||||
|
||||
|
@ -70,7 +70,7 @@ SENSOR_TYPES = [
|
|||
name="Current Power",
|
||||
icon="mdi:solar-power",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
),
|
||||
SolarEdgeSensorEntityDescription(
|
||||
|
|
|
@ -21,8 +21,8 @@ from homeassistant.const import (
|
|||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
|
@ -70,7 +70,7 @@ SENSOR_DESCRIPTIONS: dict[tuple[Units, bool], SensorEntityDescription] = {
|
|||
(Units.W, False): SensorEntityDescription(
|
||||
key=f"{Units.W}_{False}",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
(Units.PERCENT, False): SensorEntityDescription(
|
||||
|
|
|
@ -7,7 +7,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import DeviceInfo
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -76,7 +76,7 @@ class SpiderPowerPlugPower(SensorEntity):
|
|||
|
||||
_attr_device_class = SensorDeviceClass.POWER
|
||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||
_attr_native_unit_of_measurement = POWER_WATT
|
||||
_attr_native_unit_of_measurement = UnitOfPower.WATT
|
||||
|
||||
def __init__(self, api, power_plug) -> None:
|
||||
"""Initialize the Spider Power Plug."""
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import POWER_WATT, UnitOfElectricCurrent
|
||||
from homeassistant.const import UnitOfElectricCurrent, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import device_registry
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -38,7 +38,7 @@ class AttributeDescription:
|
|||
POWER_SENSORS = {
|
||||
"power_consumption": AttributeDescription(
|
||||
name="Power Consumption",
|
||||
unit=POWER_WATT,
|
||||
unit=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
|
|
|
@ -21,9 +21,9 @@ from homeassistant.const import (
|
|||
FREQUENCY_HERTZ,
|
||||
FREQUENCY_MEGAHERTZ,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
REVOLUTIONS_PER_MINUTE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -455,7 +455,7 @@ async def async_setup_entry(
|
|||
entity_registry_enabled_default=False,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
value=lambda data, k=gpu["key"]: getattr(data.gpu, f"{k}_power"),
|
||||
),
|
||||
entry.data[CONF_PORT],
|
||||
|
|
|
@ -27,7 +27,6 @@ from homeassistant.const import (
|
|||
LIGHT_LUX,
|
||||
MASS_KILOGRAMS,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
PRESSURE_HPA,
|
||||
SIGNAL_STRENGTH_DECIBELS,
|
||||
SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
|
@ -38,6 +37,7 @@ from homeassistant.const import (
|
|||
TEMP_FAHRENHEIT,
|
||||
TEMP_KELVIN,
|
||||
UnitOfApparentPower,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -221,7 +221,7 @@ SENSOR_UNIT_MAP = {
|
|||
hc.LIGHT_LUX: LIGHT_LUX,
|
||||
hc.MASS_KILOGRAMS: MASS_KILOGRAMS,
|
||||
hc.PERCENTAGE: PERCENTAGE,
|
||||
hc.POWER_WATT: POWER_WATT,
|
||||
hc.POWER_WATT: UnitOfPower.WATT,
|
||||
hc.PRESSURE_HPA: PRESSURE_HPA,
|
||||
hc.SIGNAL_STRENGTH_DECIBELS: SIGNAL_STRENGTH_DECIBELS,
|
||||
hc.SIGNAL_STRENGTH_DECIBELS_MILLIWATT: SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
|
||||
|
|
|
@ -31,8 +31,8 @@ from homeassistant.const import (
|
|||
ENERGY_KILO_WATT_HOUR,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
SIGNAL_STRENGTH_DECIBELS,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.exceptions import PlatformNotReady
|
||||
|
@ -61,33 +61,33 @@ RT_SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||
key="averagePower",
|
||||
name="average power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="power",
|
||||
name="power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="powerProduction",
|
||||
name="power production",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="minPower",
|
||||
name="min power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="maxPower",
|
||||
name="max power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
),
|
||||
SensorEntityDescription(
|
||||
key="accumulatedConsumption",
|
||||
|
|
|
@ -13,8 +13,8 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfPower,
|
||||
UnitOfVolume,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -212,7 +212,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Average Power Usage",
|
||||
section="power_usage",
|
||||
measurement="average",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
entity_registry_enabled_default=False,
|
||||
cls=ToonElectricityMeterDeviceSensor,
|
||||
|
@ -272,7 +272,7 @@ SENSOR_ENTITIES: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Current Power Usage",
|
||||
section="power_usage",
|
||||
measurement="current",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
cls=ToonElectricityMeterDeviceSensor,
|
||||
|
@ -372,7 +372,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Current Solar Power Production",
|
||||
section="power_usage",
|
||||
measurement="current_solar",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
cls=ToonSolarDeviceSensor,
|
||||
|
@ -382,7 +382,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Max Solar Power Production Today",
|
||||
section="power_usage",
|
||||
measurement="day_max_solar",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
cls=ToonSolarDeviceSensor,
|
||||
),
|
||||
|
@ -391,7 +391,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Solar Power Production to Grid",
|
||||
section="power_usage",
|
||||
measurement="current_produced",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
cls=ToonSolarDeviceSensor,
|
||||
|
@ -431,7 +431,7 @@ SENSOR_ENTITIES_SOLAR: tuple[ToonSensorEntityDescription, ...] = (
|
|||
name="Average Solar Power Production to Grid",
|
||||
section="power_usage",
|
||||
measurement="average_produced",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
entity_registry_enabled_default=False,
|
||||
cls=ToonSolarDeviceSensor,
|
||||
|
|
|
@ -18,7 +18,7 @@ from homeassistant.const import (
|
|||
ELECTRIC_CURRENT_AMPERE,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
POWER_WATT,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -46,7 +46,7 @@ class TPLinkSensorEntityDescription(SensorEntityDescription):
|
|||
ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = (
|
||||
TPLinkSensorEntityDescription(
|
||||
key=ATTR_CURRENT_POWER_W,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
name="Current Consumption",
|
||||
|
|
|
@ -22,8 +22,6 @@ from homeassistant.const import (
|
|||
ENERGY_WATT_HOUR,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
POWER_KILO_WATT,
|
||||
POWER_WATT,
|
||||
PRESSURE_BAR,
|
||||
PRESSURE_HPA,
|
||||
PRESSURE_INHG,
|
||||
|
@ -37,6 +35,7 @@ from homeassistant.const import (
|
|||
VOLUME_CUBIC_FEET,
|
||||
VOLUME_CUBIC_METERS,
|
||||
Platform,
|
||||
UnitOfPower,
|
||||
)
|
||||
|
||||
DOMAIN = "tuya"
|
||||
|
@ -505,12 +504,12 @@ UNITS = (
|
|||
conversion_fn=lambda x: x * 1000,
|
||||
),
|
||||
UnitOfMeasurement(
|
||||
unit=POWER_WATT,
|
||||
unit=UnitOfPower.WATT,
|
||||
aliases={"watt"},
|
||||
device_classes={SensorDeviceClass.POWER},
|
||||
),
|
||||
UnitOfMeasurement(
|
||||
unit=POWER_KILO_WATT,
|
||||
unit=UnitOfPower.KILO_WATT,
|
||||
aliases={"kilowatt"},
|
||||
device_classes={SensorDeviceClass.POWER},
|
||||
),
|
||||
|
|
|
@ -16,9 +16,9 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
PERCENTAGE,
|
||||
POWER_KILO_WATT,
|
||||
TIME_MINUTES,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -675,7 +675,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
|
|||
name="Phase A power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_KILO_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
||||
subkey="power",
|
||||
),
|
||||
TuyaSensorEntityDescription(
|
||||
|
@ -699,7 +699,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
|
|||
name="Phase B power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_KILO_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
||||
subkey="power",
|
||||
),
|
||||
TuyaSensorEntityDescription(
|
||||
|
@ -723,7 +723,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
|
|||
name="Phase C power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_KILO_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
||||
subkey="power",
|
||||
),
|
||||
TuyaSensorEntityDescription(
|
||||
|
@ -757,7 +757,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
|
|||
name="Phase A power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_KILO_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
||||
subkey="power",
|
||||
),
|
||||
TuyaSensorEntityDescription(
|
||||
|
@ -781,7 +781,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
|
|||
name="Phase B power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_KILO_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
||||
subkey="power",
|
||||
),
|
||||
TuyaSensorEntityDescription(
|
||||
|
@ -805,7 +805,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
|
|||
name="Phase C power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_KILO_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
||||
subkey="power",
|
||||
),
|
||||
TuyaSensorEntityDescription(
|
||||
|
|
|
@ -15,10 +15,10 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
Platform,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -90,7 +90,7 @@ class VeraSensor(VeraDevice[veraApi.VeraSensor], SensorEntity):
|
|||
if self.vera_device.category == veraApi.CATEGORY_HUMIDITY_SENSOR:
|
||||
return PERCENTAGE
|
||||
if self.vera_device.category == veraApi.CATEGORY_POWER_METER:
|
||||
return POWER_WATT
|
||||
return UnitOfPower.WATT
|
||||
return None
|
||||
|
||||
def update(self) -> None:
|
||||
|
|
|
@ -21,7 +21,7 @@ from homeassistant.const import (
|
|||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -105,7 +105,7 @@ SENSORS: tuple[VeSyncSensorEntityDescription, ...] = (
|
|||
key="power",
|
||||
name="current power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
value_fn=lambda device: device.details["power"],
|
||||
update_fn=update_energy,
|
||||
|
|
|
@ -17,7 +17,7 @@ from homeassistant.const import (
|
|||
ENERGY_KILO_WATT_HOUR,
|
||||
LENGTH_KILOMETERS,
|
||||
PERCENTAGE,
|
||||
POWER_KILO_WATT,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -62,7 +62,7 @@ SENSOR_TYPES: dict[str, WallboxSensorEntityDescription] = {
|
|||
key=CHARGER_CHARGING_POWER_KEY,
|
||||
name="Charging Power",
|
||||
precision=2,
|
||||
native_unit_of_measurement=POWER_KILO_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.KILO_WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
|
|
|
@ -13,7 +13,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, POWER_WATT
|
||||
from homeassistant.const import ENERGY_KILO_WATT_HOUR, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -37,7 +37,7 @@ ATTRIBUTE_SENSORS = (
|
|||
name="Current Power",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
key="current_power_watts",
|
||||
unique_id_suffix="currentpower",
|
||||
state_conversion=lambda state: round(cast(float, state), 2),
|
||||
|
|
|
@ -8,7 +8,7 @@ from homeassistant.components.sensor import (
|
|||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import POWER_WATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT
|
||||
from homeassistant.const import SIGNAL_STRENGTH_DECIBELS_MILLIWATT, UnitOfPower
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -36,7 +36,7 @@ POWER_SENSORS: tuple[SensorEntityDescription, ...] = (
|
|||
name="Current power",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
),
|
||||
)
|
||||
|
||||
|
|
|
@ -14,9 +14,9 @@ from homeassistant.const import (
|
|||
ATTR_BATTERY_LEVEL,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
PRESSURE_HPA,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -65,7 +65,7 @@ SENSOR_TYPES: dict[str, SensorEntityDescription] = {
|
|||
),
|
||||
"load_power": SensorEntityDescription(
|
||||
key="load_power",
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
|
|
|
@ -12,7 +12,7 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
CONF_DEVICE,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
POWER_WATT,
|
||||
UnitOfPower,
|
||||
UnitOfVolume,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -117,7 +117,7 @@ class GasSensor(YoulessBaseSensor):
|
|||
class CurrentPowerSensor(YoulessBaseSensor):
|
||||
"""The current power usage sensor."""
|
||||
|
||||
_attr_native_unit_of_measurement = POWER_WATT
|
||||
_attr_native_unit_of_measurement = UnitOfPower.WATT
|
||||
_attr_device_class = SensorDeviceClass.POWER
|
||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||
|
||||
|
@ -220,7 +220,7 @@ class ExtraMeterSensor(YoulessBaseSensor):
|
|||
class ExtraMeterPowerSensor(YoulessBaseSensor):
|
||||
"""The Youless extra meter power value sensor (s0)."""
|
||||
|
||||
_attr_native_unit_of_measurement = POWER_WATT
|
||||
_attr_native_unit_of_measurement = UnitOfPower.WATT
|
||||
_attr_device_class = SensorDeviceClass.POWER
|
||||
_attr_state_class = SensorStateClass.MEASUREMENT
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ from homeassistant.const import (
|
|||
ENERGY_KILO_WATT_HOUR,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
POWER_WATT,
|
||||
PRESSURE_KPA,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
|
@ -97,7 +97,7 @@ SENSORS_MAP: dict[str, ZWaveMeSensorEntityDescription] = {
|
|||
"meterElectric_watt": ZWaveMeSensorEntityDescription(
|
||||
key="meterElectric_watt",
|
||||
device_class=SensorDeviceClass.POWER,
|
||||
native_unit_of_measurement=POWER_WATT,
|
||||
native_unit_of_measurement=UnitOfPower.WATT,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
"temperature": ZWaveMeSensorEntityDescription(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue