Use UnitOfElectricPotential in integrations (#84044)

This commit is contained in:
epenet 2022-12-15 13:59:21 +01:00 committed by GitHub
parent d72c28a135
commit 0184aadb09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
43 changed files with 141 additions and 143 deletions

View File

@ -9,11 +9,11 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -60,7 +60,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="volt", key="volt",
name="Voltage", name="Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -22,12 +22,12 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEGREE, DEGREE,
ELECTRIC_POTENTIAL_VOLT,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TIME_SECONDS, TIME_SECONDS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfEnergy, UnitOfEnergy,
UnitOfLength, UnitOfLength,
UnitOfMass, UnitOfMass,
@ -82,7 +82,7 @@ SENSOR_DESCRIPTIONS = {
): SensorEntityDescription( ): SensorEntityDescription(
key=f"{BTHomeSensorDeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}", key=f"{BTHomeSensorDeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
( (

View File

@ -12,10 +12,10 @@ from homeassistant.components.sensor import (
) )
from homeassistant.const import ( from homeassistant.const import (
CURRENCY_EURO, CURRENCY_EURO,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
VOLUME_CUBIC_METERS, VOLUME_CUBIC_METERS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.util import dt as dt_util from homeassistant.util import dt as dt_util
@ -149,7 +149,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Current voltage L1", name="Current voltage L1",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
@ -157,7 +157,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Current voltage L2", name="Current voltage L2",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(
@ -165,7 +165,7 @@ SENSORS: tuple[DSMRReaderSensorEntityDescription, ...] = (
name="Current voltage L3", name="Current voltage L3",
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
DSMRReaderSensorEntityDescription( DSMRReaderSensorEntityDescription(

View File

@ -18,10 +18,10 @@ from homeassistant.components.sensor import (
from homeassistant.const import ( from homeassistant.const import (
CONF_NAME, CONF_NAME,
DEGREE, DEGREE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
) )
@ -259,7 +259,7 @@ SENSOR_UNIT_MAPPING = {
"kWh": ENERGY_KILO_WATT_HOUR, "kWh": ENERGY_KILO_WATT_HOUR,
"W": UnitOfPower.WATT, "W": UnitOfPower.WATT,
"A": UnitOfElectricCurrent.AMPERE, "A": UnitOfElectricCurrent.AMPERE,
"V": ELECTRIC_POTENTIAL_VOLT, "V": UnitOfElectricPotential.VOLT,
"°": DEGREE, "°": DEGREE,
"Hz": UnitOfFrequency.HERTZ, "Hz": UnitOfFrequency.HERTZ,
} }

View File

@ -16,7 +16,7 @@ import voluptuous as vol
from homeassistant.components.sensor import SensorEntity from homeassistant.components.sensor import SensorEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ELECTRIC_POTENTIAL_VOLT from homeassistant.const import UnitOfElectricPotential
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import entity_platform from homeassistant.helpers import entity_platform
@ -278,7 +278,7 @@ class ElkZone(ElkSensor):
if self._element.definition == ZoneType.TEMPERATURE: if self._element.definition == ZoneType.TEMPERATURE:
return self._temperature_unit return self._temperature_unit
if self._element.definition == ZoneType.ANALOG_ZONE: if self._element.definition == ZoneType.ANALOG_ZONE:
return ELECTRIC_POTENTIAL_VOLT return UnitOfElectricPotential.VOLT
return None return None
def _element_changed(self, _: Element, changeset: Any) -> None: def _element_changed(self, _: Element, changeset: Any) -> None:

View File

@ -17,11 +17,11 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -140,7 +140,7 @@ SENSOR_TYPES: Final[tuple[FritzSensorEntityDescription, ...]] = (
FritzSensorEntityDescription( FritzSensorEntityDescription(
key="voltage", key="voltage",
name="Voltage", name="Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return] suitable=lambda device: device.has_powermeter, # type: ignore[no-any-return]

View File

@ -11,13 +11,13 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
POWER_VOLT_AMPERE_REACTIVE, POWER_VOLT_AMPERE_REACTIVE,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfApparentPower, UnitOfApparentPower,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
) )
@ -139,7 +139,7 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_ac", key="voltage_ac",
name="Voltage AC", name="Voltage AC",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -147,7 +147,7 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_dc", key="voltage_dc",
name="Voltage DC", name="Voltage DC",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon="mdi:current-dc", icon="mdi:current-dc",
@ -155,7 +155,7 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_dc_2", key="voltage_dc_2",
name="Voltage DC 2", name="Voltage DC 2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon="mdi:current-dc", icon="mdi:current-dc",
@ -427,7 +427,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_ac_phase_1", key="voltage_ac_phase_1",
name="Voltage AC phase 1", name="Voltage AC phase 1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -435,7 +435,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_ac_phase_2", key="voltage_ac_phase_2",
name="Voltage AC phase 2", name="Voltage AC phase 2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -443,7 +443,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_ac_phase_3", key="voltage_ac_phase_3",
name="Voltage AC phase 3", name="Voltage AC phase 3",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -451,7 +451,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_ac_phase_to_phase_12", key="voltage_ac_phase_to_phase_12",
name="Voltage AC phase 1-2", name="Voltage AC phase 1-2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -459,7 +459,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_ac_phase_to_phase_23", key="voltage_ac_phase_to_phase_23",
name="Voltage AC phase 2-3", name="Voltage AC phase 2-3",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -467,7 +467,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_ac_phase_to_phase_31", key="voltage_ac_phase_to_phase_31",
name="Voltage AC phase 3-1", name="Voltage AC phase 3-1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
@ -611,7 +611,7 @@ STORAGE_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_dc", key="voltage_dc",
name="Voltage DC", name="Voltage DC",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon="mdi:current-dc", icon="mdi:current-dc",
@ -619,7 +619,7 @@ STORAGE_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_dc_maximum_cell", key="voltage_dc_maximum_cell",
name="Voltage DC maximum cell", name="Voltage DC maximum cell",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon="mdi:current-dc", icon="mdi:current-dc",
@ -628,7 +628,7 @@ STORAGE_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
SensorEntityDescription( SensorEntityDescription(
key="voltage_dc_minimum_cell", key="voltage_dc_minimum_cell",
name="Voltage DC minimum cell", name="Voltage DC minimum cell",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
icon="mdi:current-dc", icon="mdi:current-dc",

View File

@ -11,7 +11,6 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS, SIGNAL_STRENGTH_DECIBELS,
@ -19,6 +18,7 @@ from homeassistant.const import (
TIME_MINUTES, TIME_MINUTES,
TIME_SECONDS, TIME_SECONDS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -79,7 +79,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
key="volts", key="volts",
name="Volts", name="Volts",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
), ),
SensorEntityDescription( SensorEntityDescription(

View File

@ -10,10 +10,10 @@ from homeassistant.const import (
CONF_NAME, CONF_NAME,
CONF_SENSORS, CONF_SENSORS,
CONF_TEMPERATURE_UNIT, CONF_TEMPERATURE_UNIT,
ELECTRIC_POTENTIAL_VOLT,
TIME_HOURS, TIME_HOURS,
TIME_MINUTES, TIME_MINUTES,
TIME_SECONDS, TIME_SECONDS,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -275,7 +275,7 @@ class TemperatureSensor(GEMSensor):
class VoltageSensor(GEMSensor): class VoltageSensor(GEMSensor):
"""Entity showing voltage.""" """Entity showing voltage."""
_attr_native_unit_of_measurement = ELECTRIC_POTENTIAL_VOLT _attr_native_unit_of_measurement = UnitOfElectricPotential.VOLT
_attr_device_class = SensorDeviceClass.VOLTAGE _attr_device_class = SensorDeviceClass.VOLTAGE
def __init__( def __init__(

View File

@ -3,10 +3,10 @@ from __future__ import annotations
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
) )
@ -35,7 +35,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_voltage_input_1", key="inverter_voltage_input_1",
name="Input 1 voltage", name="Input 1 voltage",
api_key="vpv1", api_key="vpv1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=2, precision=2,
), ),
@ -59,7 +59,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_voltage_input_2", key="inverter_voltage_input_2",
name="Input 2 voltage", name="Input 2 voltage",
api_key="vpv2", api_key="vpv2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),
@ -83,7 +83,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_voltage_input_3", key="inverter_voltage_input_3",
name="Input 3 voltage", name="Input 3 voltage",
api_key="vpv3", api_key="vpv3",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),
@ -115,7 +115,7 @@ INVERTER_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="inverter_reactive_voltage", key="inverter_reactive_voltage",
name="Reactive voltage", name="Reactive voltage",
api_key="vacr", api_key="vacr",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),

View File

@ -3,9 +3,9 @@ from __future__ import annotations
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
@ -76,21 +76,21 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="mix_battery_voltage", key="mix_battery_voltage",
name="Battery voltage", name="Battery voltage",
api_key="vbat", api_key="vbat",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_pv1_voltage", key="mix_pv1_voltage",
name="PV1 voltage", name="PV1 voltage",
api_key="vpv1", api_key="vpv1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
), ),
GrowattSensorEntityDescription( GrowattSensorEntityDescription(
key="mix_pv2_voltage", key="mix_pv2_voltage",
name="PV2 voltage", name="PV2 voltage",
api_key="vpv2", api_key="vpv2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
), ),
# Values from 'mix_totals' API call # Values from 'mix_totals' API call
@ -185,7 +185,7 @@ MIX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="mix_grid_voltage", key="mix_grid_voltage",
name="Grid voltage", name="Grid voltage",
api_key="vAc1", api_key="vAc1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
), ),
# Values from 'mix_detail' API call # Values from 'mix_detail' API call

View File

@ -3,10 +3,10 @@ from __future__ import annotations
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
) )
@ -133,7 +133,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_grid_voltage", key="storage_grid_voltage",
name="AC input voltage", name="AC input voltage",
api_key="vGrid", api_key="vGrid",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=2, precision=2,
), ),
@ -141,7 +141,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_pv_charging_voltage", key="storage_pv_charging_voltage",
name="PV charging voltage", name="PV charging voltage",
api_key="vpv", api_key="vpv",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=2, precision=2,
), ),
@ -157,7 +157,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_output_voltage", key="storage_output_voltage",
name="Output voltage", name="Output voltage",
api_key="outPutVolt", api_key="outPutVolt",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=2, precision=2,
), ),
@ -205,7 +205,7 @@ STORAGE_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="storage_battery_voltage", key="storage_battery_voltage",
name="Battery voltage", name="Battery voltage",
api_key="vBat", api_key="vBat",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=2, precision=2,
), ),

View File

@ -3,10 +3,10 @@ from __future__ import annotations
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
) )
@ -54,7 +54,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="tlx_voltage_input_1", key="tlx_voltage_input_1",
name="Input 1 voltage", name="Input 1 voltage",
api_key="vpv1", api_key="vpv1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),
@ -96,7 +96,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="tlx_voltage_input_2", key="tlx_voltage_input_2",
name="Input 2 voltage", name="Input 2 voltage",
api_key="vpv2", api_key="vpv2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),
@ -128,7 +128,7 @@ TLX_SENSOR_TYPES: tuple[GrowattSensorEntityDescription, ...] = (
key="tlx_reactive_voltage", key="tlx_reactive_voltage",
name="Reactive voltage", name="Reactive voltage",
api_key="vacrs", api_key="vacrs",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
precision=1, precision=1,
), ),

View File

@ -10,7 +10,7 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ELECTRIC_POTENTIAL_VOLT, TEMP_FAHRENHEIT, TIME_MINUTES from homeassistant.const import TEMP_FAHRENHEIT, TIME_MINUTES, UnitOfElectricPotential
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -48,7 +48,7 @@ PAIRED_SENSOR_DESCRIPTIONS = (
name="Battery", name="Battery",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
), ),
SensorEntityDescription( SensorEntityDescription(
key=SENSOR_KIND_TEMPERATURE, key=SENSOR_KIND_TEMPERATURE,

View File

@ -24,7 +24,6 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
@ -32,6 +31,7 @@ from homeassistant.const import (
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
Platform, Platform,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
UnitOfSoundPressure, UnitOfSoundPressure,
) )
@ -188,7 +188,7 @@ SIMPLE_SENSOR: dict[str, HomeKitSensorEntityDescription] = {
name="Volts", name="Volts",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
), ),
CharacteristicsTypes.VENDOR_EVE_ENERGY_AMPERE: HomeKitSensorEntityDescription( CharacteristicsTypes.VENDOR_EVE_ENERGY_AMPERE: HomeKitSensorEntityDescription(
key=CharacteristicsTypes.VENDOR_EVE_ENERGY_AMPERE, key=CharacteristicsTypes.VENDOR_EVE_ENERGY_AMPERE,

View File

@ -15,7 +15,6 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEGREE, DEGREE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
LIGHT_LUX, LIGHT_LUX,
@ -23,6 +22,7 @@ from homeassistant.const import (
PRESSURE_HPA, PRESSURE_HPA,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
UnitOfPrecipitationDepth, UnitOfPrecipitationDepth,
@ -148,7 +148,7 @@ SENSOR_DESCRIPTIONS: dict[str, SensorEntityDescription] = {
), ),
"VOLTAGE": SensorEntityDescription( "VOLTAGE": SensorEntityDescription(
key="VOLTAGE", key="VOLTAGE",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -15,11 +15,11 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
UnitOfApparentPower, UnitOfApparentPower,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
) )
@ -109,7 +109,7 @@ ENTITY_DESCRIPTION_KEY_MAP: dict[str, IotaWattSensorEntityDescription] = {
), ),
"Volts": IotaWattSensorEntityDescription( "Volts": IotaWattSensorEntityDescription(
"Volts", "Volts",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,

View File

@ -9,11 +9,11 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
TEMP_CELSIUS, TEMP_CELSIUS,
TIME_SECONDS, TIME_SECONDS,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -37,7 +37,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="voltage", key="voltage",
name="Voltage", name="Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
), ),
SensorEntityDescription( SensorEntityDescription(

View File

@ -15,10 +15,10 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -142,7 +142,7 @@ SENSOR_PROCESS_DATA = [
module_id="devices:local:pv1", module_id="devices:local:pv1",
key="U", key="U",
name="DC1 Voltage", name="DC1 Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
formatter="format_round", formatter="format_round",
@ -169,7 +169,7 @@ SENSOR_PROCESS_DATA = [
module_id="devices:local:pv2", module_id="devices:local:pv2",
key="U", key="U",
name="DC2 Voltage", name="DC2 Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
formatter="format_round", formatter="format_round",
@ -196,7 +196,7 @@ SENSOR_PROCESS_DATA = [
module_id="devices:local:pv3", module_id="devices:local:pv3",
key="U", key="U",
name="DC3 Voltage", name="DC3 Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
formatter="format_round", formatter="format_round",

View File

@ -20,10 +20,10 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -53,7 +53,7 @@ SENSOR_DESCRIPTIONS = {
(DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription( (DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription(
key=f"{DeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}", key=f"{DeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
( (

View File

@ -11,13 +11,13 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
PRESSURE_PSI, PRESSURE_PSI,
TEMP_CELSIUS, TEMP_CELSIUS,
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
) )
@ -60,7 +60,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
), ),
SensorEntityDescription( SensorEntityDescription(
key="BatteryVoltage", key="BatteryVoltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
@ -97,7 +97,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
), ),
SensorEntityDescription( SensorEntityDescription(
key="GeneratorVoltageAverageLineToLine", key="GeneratorVoltageAverageLineToLine",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
@ -138,14 +138,14 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
), ),
SensorEntityDescription( SensorEntityDescription(
key="Source1VoltageAverageLineToLine", key="Source1VoltageAverageLineToLine",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),
SensorEntityDescription( SensorEntityDescription(
key="Source2VoltageAverageLineToLine", key="Source2VoltageAverageLineToLine",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,

View File

@ -17,12 +17,12 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
PRESSURE_CBAR, PRESSURE_CBAR,
PRESSURE_MBAR, PRESSURE_MBAR,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -171,7 +171,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
name="Voltage VAD", name="Voltage VAD",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -180,7 +180,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
name="Voltage VDD", name="Voltage VDD",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -189,7 +189,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
name="vis", name="vis",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -222,7 +222,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
name="Voltage", name="Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
@ -231,7 +231,7 @@ DEVICE_SENSORS: dict[str, tuple[OneWireSensorEntityDescription, ...]] = {
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
name="vis", name="vis",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
read_mode=READ_MODE_FLOAT, read_mode=READ_MODE_FLOAT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -14,9 +14,9 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONF_HOST, CONF_HOST,
CURRENCY_EURO, CURRENCY_EURO,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
UnitOfVolume, UnitOfVolume,
) )
@ -98,21 +98,21 @@ SENSORS_PHASES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription( SensorEntityDescription(
key="voltage_phase_l1", key="voltage_phase_l1",
name="Voltage Phase L1", name="Voltage Phase L1",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="voltage_phase_l2", key="voltage_phase_l2",
name="Voltage Phase L2", name="Voltage Phase L2",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="voltage_phase_l3", key="voltage_phase_l3",
name="Voltage Phase L3", name="Voltage Phase L3",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),

View File

@ -14,10 +14,10 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
) )
@ -98,7 +98,7 @@ POWERWALL_INSTANT_SENSORS = (
name="Average Voltage Now", name="Average Voltage Now",
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
value_fn=_get_meter_average_voltage, value_fn=_get_meter_average_voltage,
), ),

View File

@ -14,10 +14,10 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -94,7 +94,7 @@ SENSORS: tuple[PVOutputSensorEntityDescription, ...] = (
PVOutputSensorEntityDescription( PVOutputSensorEntityDescription(
key="voltage", key="voltage",
name="Voltage", name="Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda status: status.voltage, value_fn=lambda status: status.voltage,

View File

@ -19,10 +19,10 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
ELECTRIC_POTENTIAL_VOLT,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -90,7 +90,7 @@ MOTION_SENSOR_TYPES: tuple[SensiboMotionSensorEntityDescription, ...] = (
key="battery_voltage", key="battery_voltage",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
name="Battery voltage", name="Battery voltage",
icon="mdi:battery", icon="mdi:battery",

View File

@ -23,10 +23,10 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -76,7 +76,7 @@ SENSOR_DESCRIPTIONS = {
): SensorEntityDescription( ): SensorEntityDescription(
key=f"{SensorProSensorDeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}", key=f"{SensorProSensorDeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
} }

View File

@ -18,12 +18,12 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEGREE, DEGREE,
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -122,7 +122,7 @@ SENSORS: Final = {
("device", "voltage"): BlockSensorDescription( ("device", "voltage"): BlockSensorDescription(
key="device|voltage", key="device|voltage",
name="Voltage", name="Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
value=lambda value: round(value, 1), value=lambda value: round(value, 1),
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -131,7 +131,7 @@ SENSORS: Final = {
("emeter", "voltage"): BlockSensorDescription( ("emeter", "voltage"): BlockSensorDescription(
key="emeter|voltage", key="emeter|voltage",
name="Voltage", name="Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
value=lambda value: round(value, 1), value=lambda value: round(value, 1),
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -276,7 +276,7 @@ SENSORS: Final = {
("adc", "adc"): BlockSensorDescription( ("adc", "adc"): BlockSensorDescription(
key="adc|adc", key="adc|adc",
name="ADC", name="ADC",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
value=lambda value: round(value, 2), value=lambda value: round(value, 2),
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -326,7 +326,7 @@ RPC_SENSORS: Final = {
key="switch", key="switch",
sub_key="voltage", sub_key="voltage",
name="Voltage", name="Voltage",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
value=lambda status, _: round(float(status), 1), value=lambda status, _: round(float(status), 1),
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -409,7 +409,7 @@ RPC_SENSORS: Final = {
key="voltmeter", key="voltmeter",
sub_key="voltage", sub_key="voltage",
name="Voltmeter", name="Voltmeter",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
value=lambda status, _: round(float(status), 2), value=lambda status, _: round(float(status), 2),
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,

View File

@ -11,9 +11,9 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -141,7 +141,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = (
SmappeeVoltageSensorEntityDescription( SmappeeVoltageSensorEntityDescription(
key="phase_voltages_a", key="phase_voltages_a",
name="Phase voltages - A", name="Phase voltages - A",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
sensor_id="phase_voltage_a", sensor_id="phase_voltage_a",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -150,7 +150,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = (
SmappeeVoltageSensorEntityDescription( SmappeeVoltageSensorEntityDescription(
key="phase_voltages_b", key="phase_voltages_b",
name="Phase voltages - B", name="Phase voltages - B",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
sensor_id="phase_voltage_b", sensor_id="phase_voltage_b",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -159,7 +159,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = (
SmappeeVoltageSensorEntityDescription( SmappeeVoltageSensorEntityDescription(
key="phase_voltages_c", key="phase_voltages_c",
name="Phase voltages - C", name="Phase voltages - C",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
sensor_id="phase_voltage_c", sensor_id="phase_voltage_c",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -168,7 +168,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = (
SmappeeVoltageSensorEntityDescription( SmappeeVoltageSensorEntityDescription(
key="line_voltages_a", key="line_voltages_a",
name="Line voltages - A", name="Line voltages - A",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
sensor_id="line_voltage_a", sensor_id="line_voltage_a",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -177,7 +177,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = (
SmappeeVoltageSensorEntityDescription( SmappeeVoltageSensorEntityDescription(
key="line_voltages_b", key="line_voltages_b",
name="Line voltages - B", name="Line voltages - B",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
sensor_id="line_voltage_b", sensor_id="line_voltage_b",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
@ -186,7 +186,7 @@ VOLTAGE_SENSORS: tuple[SmappeeVoltageSensorEntityDescription, ...] = (
SmappeeVoltageSensorEntityDescription( SmappeeVoltageSensorEntityDescription(
key="line_voltages_c", key="line_voltages_c",
name="Line voltages - C", name="Line voltages - C",
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
sensor_id="line_voltage_c", sensor_id="line_voltage_c",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,

View File

@ -17,10 +17,10 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfPower, UnitOfPower,
) )
@ -58,7 +58,7 @@ SENSOR_DESCRIPTIONS: dict[tuple[Units, bool], SensorEntityDescription] = {
(Units.V, False): SensorEntityDescription( (Units.V, False): SensorEntityDescription(
key=f"{Units.V}_{False}", key=f"{Units.V}_{False}",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
(Units.A, False): SensorEntityDescription( (Units.A, False): SensorEntityDescription(

View File

@ -15,10 +15,10 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONF_PORT, CONF_PORT,
ELECTRIC_POTENTIAL_VOLT,
PERCENTAGE, PERCENTAGE,
REVOLUTIONS_PER_MINUTE, REVOLUTIONS_PER_MINUTE,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfInformation, UnitOfInformation,
UnitOfPower, UnitOfPower,
@ -156,7 +156,7 @@ BASE_SENSOR_TYPES: tuple[SystemBridgeSensorEntityDescription, ...] = (
entity_registry_enabled_default=False, entity_registry_enabled_default=False,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
value=lambda data: data.cpu.voltage, value=lambda data: data.cpu.voltage,
), ),
SystemBridgeSensorEntityDescription( SystemBridgeSensorEntityDescription(

View File

@ -20,7 +20,6 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_BILLION, CONCENTRATION_PARTS_PER_BILLION,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
@ -34,6 +33,7 @@ from homeassistant.const import (
TEMP_FAHRENHEIT, TEMP_FAHRENHEIT,
TEMP_KELVIN, TEMP_KELVIN,
UnitOfApparentPower, UnitOfApparentPower,
UnitOfElectricPotential,
UnitOfFrequency, UnitOfFrequency,
UnitOfLength, UnitOfLength,
UnitOfMass, UnitOfMass,
@ -231,7 +231,7 @@ SENSOR_UNIT_MAP = {
hc.TEMP_CELSIUS: TEMP_CELSIUS, hc.TEMP_CELSIUS: TEMP_CELSIUS,
hc.TEMP_FAHRENHEIT: TEMP_FAHRENHEIT, hc.TEMP_FAHRENHEIT: TEMP_FAHRENHEIT,
hc.TEMP_KELVIN: TEMP_KELVIN, hc.TEMP_KELVIN: TEMP_KELVIN,
hc.VOLT: ELECTRIC_POTENTIAL_VOLT, hc.VOLT: UnitOfElectricPotential.VOLT,
} }

View File

@ -23,10 +23,10 @@ from homeassistant.components.sensor import (
SensorStateClass, SensorStateClass,
) )
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -76,7 +76,7 @@ SENSOR_DESCRIPTIONS = {
): SensorEntityDescription( ): SensorEntityDescription(
key=f"{ThermoBeaconSensorDeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}", key=f"{ThermoBeaconSensorDeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
} }

View File

@ -27,11 +27,11 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
EVENT_HOMEASSISTANT_STOP, EVENT_HOMEASSISTANT_STOP,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS, SIGNAL_STRENGTH_DECIBELS,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import Event, HomeAssistant, callback from homeassistant.core import Event, HomeAssistant, callback
@ -141,21 +141,21 @@ RT_SENSORS: tuple[SensorEntityDescription, ...] = (
key="voltagePhase1", key="voltagePhase1",
name="voltage phase1", name="voltage phase1",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="voltagePhase2", key="voltagePhase2",
name="voltage phase2", name="voltage phase2",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(
key="voltagePhase3", key="voltagePhase3",
name="voltage phase3", name="voltage phase3",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
SensorEntityDescription( SensorEntityDescription(

View File

@ -16,8 +16,8 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ATTR_VOLTAGE, ATTR_VOLTAGE,
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -72,7 +72,7 @@ ENERGY_SENSORS: tuple[TPLinkSensorEntityDescription, ...] = (
), ),
TPLinkSensorEntityDescription( TPLinkSensorEntityDescription(
key=ATTR_VOLTAGE, key=ATTR_VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
name="Voltage", name="Voltage",

View File

@ -16,8 +16,6 @@ from homeassistant.const import (
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_CURRENT_MILLIAMPERE, ELECTRIC_CURRENT_MILLIAMPERE,
ELECTRIC_POTENTIAL_MILLIVOLT,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
ENERGY_WATT_HOUR, ENERGY_WATT_HOUR,
LIGHT_LUX, LIGHT_LUX,
@ -35,6 +33,7 @@ from homeassistant.const import (
VOLUME_CUBIC_FEET, VOLUME_CUBIC_FEET,
VOLUME_CUBIC_METERS, VOLUME_CUBIC_METERS,
Platform, Platform,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
@ -561,15 +560,15 @@ UNITS = (
device_classes={SensorDeviceClass.TEMPERATURE}, device_classes={SensorDeviceClass.TEMPERATURE},
), ),
UnitOfMeasurement( UnitOfMeasurement(
unit=ELECTRIC_POTENTIAL_VOLT, unit=UnitOfElectricPotential.VOLT,
aliases={"volt"}, aliases={"volt"},
device_classes={SensorDeviceClass.VOLTAGE}, device_classes={SensorDeviceClass.VOLTAGE},
), ),
UnitOfMeasurement( UnitOfMeasurement(
unit=ELECTRIC_POTENTIAL_MILLIVOLT, unit=UnitOfElectricPotential.MILLIVOLT,
aliases={"mv", "millivolt"}, aliases={"mv", "millivolt"},
device_classes={SensorDeviceClass.VOLTAGE}, device_classes={SensorDeviceClass.VOLTAGE},
conversion_unit=ELECTRIC_POTENTIAL_VOLT, conversion_unit=UnitOfElectricPotential.VOLT,
conversion_fn=lambda x: x / 1000, conversion_fn=lambda x: x / 1000,
), ),
) )

View File

@ -14,10 +14,10 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
PERCENTAGE, PERCENTAGE,
TIME_MINUTES, TIME_MINUTES,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -683,7 +683,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
name="Phase A voltage", name="Phase A voltage",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
subkey="voltage", subkey="voltage",
), ),
TuyaSensorEntityDescription( TuyaSensorEntityDescription(
@ -707,7 +707,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
name="Phase B voltage", name="Phase B voltage",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
subkey="voltage", subkey="voltage",
), ),
TuyaSensorEntityDescription( TuyaSensorEntityDescription(
@ -731,7 +731,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
name="Phase C voltage", name="Phase C voltage",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
subkey="voltage", subkey="voltage",
), ),
), ),
@ -765,7 +765,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
name="Phase A voltage", name="Phase A voltage",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
subkey="voltage", subkey="voltage",
), ),
TuyaSensorEntityDescription( TuyaSensorEntityDescription(
@ -789,7 +789,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
name="Phase B voltage", name="Phase B voltage",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
subkey="voltage", subkey="voltage",
), ),
TuyaSensorEntityDescription( TuyaSensorEntityDescription(
@ -813,7 +813,7 @@ SENSORS: dict[str, tuple[TuyaSensorEntityDescription, ...]] = {
name="Phase C voltage", name="Phase C voltage",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
subkey="voltage", subkey="voltage",
), ),
), ),

View File

@ -26,13 +26,13 @@ from homeassistant.components.sensor import (
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_POTENTIAL_VOLT,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
TIME_SECONDS, TIME_SECONDS,
UnitOfDataRate, UnitOfDataRate,
UnitOfElectricPotential,
UnitOfInformation, UnitOfInformation,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -192,7 +192,7 @@ CAMERA_SENSORS: tuple[ProtectSensorEntityDescription, ...] = (
key="voltage", key="voltage",
name="Voltage", name="Voltage",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
ufp_value="voltage", ufp_value="voltage",

View File

@ -18,9 +18,9 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
PERCENTAGE, PERCENTAGE,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -155,7 +155,7 @@ SENSORS: tuple[VeSyncSensorEntityDescription, ...] = (
key="voltage", key="voltage",
name="current voltage", name="current voltage",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
value_fn=lambda device: device.details["voltage"], value_fn=lambda device: device.details["voltage"],
update_fn=update_energy, update_fn=update_energy,

View File

@ -12,9 +12,9 @@ from homeassistant.const import (
ATTR_VOLTAGE, ATTR_VOLTAGE,
CONF_PASSWORD, CONF_PASSWORD,
CONF_USERNAME, CONF_USERNAME,
ELECTRIC_POTENTIAL_VOLT,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
UnitOfElectricPotential,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
import homeassistant.helpers.config_validation as cv import homeassistant.helpers.config_validation as cv
@ -213,7 +213,7 @@ class WirelessTagBaseSensor(Entity):
"""Return the state attributes.""" """Return the state attributes."""
return { return {
ATTR_BATTERY_LEVEL: int(self._tag.battery_remaining * 100), ATTR_BATTERY_LEVEL: int(self._tag.battery_remaining * 100),
ATTR_VOLTAGE: f"{self._tag.battery_volts:.2f}{ELECTRIC_POTENTIAL_VOLT}", ATTR_VOLTAGE: f"{self._tag.battery_volts:.2f}{UnitOfElectricPotential.VOLT}",
ATTR_TAG_SIGNAL_STRENGTH: f"{self._tag.signal_strength}{SIGNAL_STRENGTH_DECIBELS_MILLIWATT}", ATTR_TAG_SIGNAL_STRENGTH: f"{self._tag.signal_strength}{SIGNAL_STRENGTH_DECIBELS_MILLIWATT}",
ATTR_TAG_OUT_OF_RANGE: not self._tag.is_in_range, ATTR_TAG_OUT_OF_RANGE: not self._tag.is_in_range,
ATTR_TAG_POWER_CONSUMPTION: f"{self._tag.power_consumption:.2f}{PERCENTAGE}", ATTR_TAG_POWER_CONSUMPTION: f"{self._tag.power_consumption:.2f}{PERCENTAGE}",

View File

@ -21,12 +21,12 @@ from homeassistant.components.sensor import (
from homeassistant.const import ( from homeassistant.const import (
CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER, CONCENTRATION_MILLIGRAMS_PER_CUBIC_METER,
CONDUCTIVITY, CONDUCTIVITY,
ELECTRIC_POTENTIAL_VOLT,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
PRESSURE_MBAR, PRESSURE_MBAR,
SIGNAL_STRENGTH_DECIBELS_MILLIWATT, SIGNAL_STRENGTH_DECIBELS_MILLIWATT,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
) )
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
@ -102,7 +102,7 @@ SENSOR_DESCRIPTIONS = {
(DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription( (DeviceClass.VOLTAGE, Units.ELECTRIC_POTENTIAL_VOLT): SensorEntityDescription(
key=f"{DeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}", key=f"{DeviceClass.VOLTAGE}_{Units.ELECTRIC_POTENTIAL_VOLT}",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
entity_category=EntityCategory.DIAGNOSTIC, entity_category=EntityCategory.DIAGNOSTIC,
), ),

View File

@ -92,8 +92,6 @@ from homeassistant.const import (
CONCENTRATION_MICROGRAMS_PER_CUBIC_METER, CONCENTRATION_MICROGRAMS_PER_CUBIC_METER,
CONCENTRATION_PARTS_PER_MILLION, CONCENTRATION_PARTS_PER_MILLION,
DEGREE, DEGREE,
ELECTRIC_POTENTIAL_MILLIVOLT,
ELECTRIC_POTENTIAL_VOLT,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
SIGNAL_STRENGTH_DECIBELS, SIGNAL_STRENGTH_DECIBELS,
@ -102,6 +100,7 @@ from homeassistant.const import (
VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE, VOLUME_FLOW_RATE_CUBIC_FEET_PER_MINUTE,
VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR, VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
UnitOfElectricCurrent, UnitOfElectricCurrent,
UnitOfElectricPotential,
UnitOfEnergy, UnitOfEnergy,
UnitOfFrequency, UnitOfFrequency,
UnitOfIrradiance, UnitOfIrradiance,
@ -164,7 +163,7 @@ METER_UNIT_MAP: dict[str, set[MeterScaleType]] = {
UnitOfVolume.CUBIC_METERS: METER_UNIT_CUBIC_METER, UnitOfVolume.CUBIC_METERS: METER_UNIT_CUBIC_METER,
UnitOfVolume.GALLONS: UNIT_US_GALLON, UnitOfVolume.GALLONS: UNIT_US_GALLON,
UnitOfEnergy.KILO_WATT_HOUR: UNIT_KILOWATT_HOUR, UnitOfEnergy.KILO_WATT_HOUR: UNIT_KILOWATT_HOUR,
ELECTRIC_POTENTIAL_VOLT: METER_UNIT_VOLT, UnitOfElectricPotential.VOLT: METER_UNIT_VOLT,
UnitOfPower.WATT: METER_UNIT_WATT, UnitOfPower.WATT: METER_UNIT_WATT,
} }
@ -195,7 +194,7 @@ MULTILEVEL_SENSOR_UNIT_MAP: dict[str, set[MultilevelSensorScaleType]] = {
UnitOfLength.METERS: UNIT_METER, UnitOfLength.METERS: UNIT_METER,
UnitOfElectricCurrent.MILLIAMPERE: UNIT_MILLIAMPERE, UnitOfElectricCurrent.MILLIAMPERE: UNIT_MILLIAMPERE,
UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR: UNIT_MILLIMETER_HOUR, UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR: UNIT_MILLIMETER_HOUR,
ELECTRIC_POTENTIAL_MILLIVOLT: UNIT_MILLIVOLT, UnitOfElectricPotential.MILLIVOLT: UNIT_MILLIVOLT,
UnitOfSpeed.MILES_PER_HOUR: UNIT_MPH, UnitOfSpeed.MILES_PER_HOUR: UNIT_MPH,
UnitOfSpeed.METERS_PER_SECOND: UNIT_M_S, UnitOfSpeed.METERS_PER_SECOND: UNIT_M_S,
CONCENTRATION_PARTS_PER_MILLION: UNIT_PARTS_MILLION, CONCENTRATION_PARTS_PER_MILLION: UNIT_PARTS_MILLION,
@ -205,7 +204,7 @@ MULTILEVEL_SENSOR_UNIT_MAP: dict[str, set[MultilevelSensorScaleType]] = {
SIGNAL_STRENGTH_DECIBELS_MILLIWATT: UNIT_POWER_LEVEL, SIGNAL_STRENGTH_DECIBELS_MILLIWATT: UNIT_POWER_LEVEL,
TIME_SECONDS: UNIT_SECOND, TIME_SECONDS: UNIT_SECOND,
UnitOfPressure.MMHG: UNIT_SYSTOLIC, UnitOfPressure.MMHG: UNIT_SYSTOLIC,
ELECTRIC_POTENTIAL_VOLT: SENSOR_UNIT_VOLT, UnitOfElectricPotential.VOLT: SENSOR_UNIT_VOLT,
UnitOfPower.WATT: SENSOR_UNIT_WATT, UnitOfPower.WATT: SENSOR_UNIT_WATT,
UnitOfIrradiance.WATTS_PER_SQUARE_METER: UNIT_WATT_PER_SQUARE_METER, UnitOfIrradiance.WATTS_PER_SQUARE_METER: UNIT_WATT_PER_SQUARE_METER,
} }

View File

@ -15,12 +15,12 @@ from homeassistant.components.sensor import (
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ( from homeassistant.const import (
ELECTRIC_CURRENT_AMPERE, ELECTRIC_CURRENT_AMPERE,
ELECTRIC_POTENTIAL_VOLT,
ENERGY_KILO_WATT_HOUR, ENERGY_KILO_WATT_HOUR,
LIGHT_LUX, LIGHT_LUX,
PERCENTAGE, PERCENTAGE,
PRESSURE_KPA, PRESSURE_KPA,
TEMP_CELSIUS, TEMP_CELSIUS,
UnitOfElectricPotential,
UnitOfPower, UnitOfPower,
) )
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -91,7 +91,7 @@ SENSORS_MAP: dict[str, ZWaveMeSensorEntityDescription] = {
"meterElectric_voltage": ZWaveMeSensorEntityDescription( "meterElectric_voltage": ZWaveMeSensorEntityDescription(
key="meterElectric_voltage", key="meterElectric_voltage",
device_class=SensorDeviceClass.VOLTAGE, device_class=SensorDeviceClass.VOLTAGE,
native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, native_unit_of_measurement=UnitOfElectricPotential.VOLT,
state_class=SensorStateClass.MEASUREMENT, state_class=SensorStateClass.MEASUREMENT,
), ),
"meterElectric_watt": ZWaveMeSensorEntityDescription( "meterElectric_watt": ZWaveMeSensorEntityDescription(