mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Use new enums in iotawatt (#61802)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
ef2a28cce2
commit
ffccc5bfa5
@ -8,17 +8,12 @@ import logging
|
|||||||
from iotawattpy.sensor import Sensor
|
from iotawattpy.sensor import Sensor
|
||||||
|
|
||||||
from homeassistant.components.sensor import (
|
from homeassistant.components.sensor import (
|
||||||
STATE_CLASS_MEASUREMENT,
|
SensorDeviceClass,
|
||||||
STATE_CLASS_TOTAL,
|
|
||||||
SensorEntity,
|
SensorEntity,
|
||||||
SensorEntityDescription,
|
SensorEntityDescription,
|
||||||
|
SensorStateClass,
|
||||||
)
|
)
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
DEVICE_CLASS_CURRENT,
|
|
||||||
DEVICE_CLASS_ENERGY,
|
|
||||||
DEVICE_CLASS_POWER,
|
|
||||||
DEVICE_CLASS_POWER_FACTOR,
|
|
||||||
DEVICE_CLASS_VOLTAGE,
|
|
||||||
ELECTRIC_CURRENT_AMPERE,
|
ELECTRIC_CURRENT_AMPERE,
|
||||||
ELECTRIC_POTENTIAL_VOLT,
|
ELECTRIC_POTENTIAL_VOLT,
|
||||||
ENERGY_WATT_HOUR,
|
ENERGY_WATT_HOUR,
|
||||||
@ -55,63 +50,63 @@ ENTITY_DESCRIPTION_KEY_MAP: dict[str, IotaWattSensorEntityDescription] = {
|
|||||||
"Amps": IotaWattSensorEntityDescription(
|
"Amps": IotaWattSensorEntityDescription(
|
||||||
"Amps",
|
"Amps",
|
||||||
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
native_unit_of_measurement=ELECTRIC_CURRENT_AMPERE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=DEVICE_CLASS_CURRENT,
|
device_class=SensorDeviceClass.CURRENT,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
"Hz": IotaWattSensorEntityDescription(
|
"Hz": IotaWattSensorEntityDescription(
|
||||||
"Hz",
|
"Hz",
|
||||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
icon="mdi:flash",
|
icon="mdi:flash",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
"PF": IotaWattSensorEntityDescription(
|
"PF": IotaWattSensorEntityDescription(
|
||||||
"PF",
|
"PF",
|
||||||
native_unit_of_measurement=PERCENTAGE,
|
native_unit_of_measurement=PERCENTAGE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=DEVICE_CLASS_POWER_FACTOR,
|
device_class=SensorDeviceClass.POWER_FACTOR,
|
||||||
value=lambda value: value * 100,
|
value=lambda value: value * 100,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
"Watts": IotaWattSensorEntityDescription(
|
"Watts": IotaWattSensorEntityDescription(
|
||||||
"Watts",
|
"Watts",
|
||||||
native_unit_of_measurement=POWER_WATT,
|
native_unit_of_measurement=POWER_WATT,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=DEVICE_CLASS_POWER,
|
device_class=SensorDeviceClass.POWER,
|
||||||
),
|
),
|
||||||
"WattHours": IotaWattSensorEntityDescription(
|
"WattHours": IotaWattSensorEntityDescription(
|
||||||
"WattHours",
|
"WattHours",
|
||||||
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
native_unit_of_measurement=ENERGY_WATT_HOUR,
|
||||||
state_class=STATE_CLASS_TOTAL,
|
state_class=SensorStateClass.TOTAL,
|
||||||
device_class=DEVICE_CLASS_ENERGY,
|
device_class=SensorDeviceClass.ENERGY,
|
||||||
),
|
),
|
||||||
"VA": IotaWattSensorEntityDescription(
|
"VA": IotaWattSensorEntityDescription(
|
||||||
"VA",
|
"VA",
|
||||||
native_unit_of_measurement=POWER_VOLT_AMPERE,
|
native_unit_of_measurement=POWER_VOLT_AMPERE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
icon="mdi:flash",
|
icon="mdi:flash",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
"VAR": IotaWattSensorEntityDescription(
|
"VAR": IotaWattSensorEntityDescription(
|
||||||
"VAR",
|
"VAR",
|
||||||
native_unit_of_measurement=VOLT_AMPERE_REACTIVE,
|
native_unit_of_measurement=VOLT_AMPERE_REACTIVE,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
icon="mdi:flash",
|
icon="mdi:flash",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
"VARh": IotaWattSensorEntityDescription(
|
"VARh": IotaWattSensorEntityDescription(
|
||||||
"VARh",
|
"VARh",
|
||||||
native_unit_of_measurement=VOLT_AMPERE_REACTIVE_HOURS,
|
native_unit_of_measurement=VOLT_AMPERE_REACTIVE_HOURS,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
icon="mdi:flash",
|
icon="mdi:flash",
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
"Volts": IotaWattSensorEntityDescription(
|
"Volts": IotaWattSensorEntityDescription(
|
||||||
"Volts",
|
"Volts",
|
||||||
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT,
|
||||||
state_class=STATE_CLASS_MEASUREMENT,
|
state_class=SensorStateClass.MEASUREMENT,
|
||||||
device_class=DEVICE_CLASS_VOLTAGE,
|
device_class=SensorDeviceClass.VOLTAGE,
|
||||||
entity_registry_enabled_default=False,
|
entity_registry_enabled_default=False,
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user