Use UnitOfFrequency in integrations (#83915)
This commit is contained in:
parent
0f5c678708
commit
946d5535b4
9 changed files with 20 additions and 21 deletions
|
@ -15,9 +15,9 @@ from homeassistant.components.sensor import (
|
|||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -125,7 +125,7 @@ SENSOR_TYPES: tuple[DaikinSensorEntityDescription, ...] = (
|
|||
icon="mdi:fan",
|
||||
device_class=SensorDeviceClass.FREQUENCY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
entity_registry_enabled_default=False,
|
||||
value_func=lambda device: device.compressor_frequency,
|
||||
),
|
||||
|
|
|
@ -11,7 +11,7 @@ from homeassistant.components.device_tracker import (
|
|||
SourceType,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import FREQUENCY_GIGAHERTZ, STATE_UNKNOWN
|
||||
from homeassistant.const import STATE_UNKNOWN, UnitOfFrequency
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import entity_registry
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
@ -119,7 +119,7 @@ class DevoloScannerEntity(CoordinatorEntity, ScannerEntity):
|
|||
if station:
|
||||
attrs["wifi"] = WIFI_APTYPE.get(station["vap_type"], STATE_UNKNOWN)
|
||||
attrs["band"] = (
|
||||
f"{WIFI_BANDS.get(station['band'])} {FREQUENCY_GIGAHERTZ}"
|
||||
f"{WIFI_BANDS.get(station['band'])} {UnitOfFrequency.GIGAHERTZ}"
|
||||
if WIFI_BANDS.get(station["band"])
|
||||
else STATE_UNKNOWN
|
||||
)
|
||||
|
|
|
@ -21,8 +21,8 @@ from homeassistant.const import (
|
|||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
ENERGY_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -261,7 +261,7 @@ SENSOR_UNIT_MAPPING = {
|
|||
"A": UnitOfElectricCurrent.AMPERE,
|
||||
"V": ELECTRIC_POTENTIAL_VOLT,
|
||||
"°": DEGREE,
|
||||
"Hz": FREQUENCY_HERTZ,
|
||||
"Hz": UnitOfFrequency.HERTZ,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -13,12 +13,12 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
PERCENTAGE,
|
||||
POWER_VOLT_AMPERE_REACTIVE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfApparentPower,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -101,7 +101,7 @@ INVERTER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
|
|||
SensorEntityDescription(
|
||||
key="frequency_ac",
|
||||
name="Frequency AC",
|
||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
device_class=SensorDeviceClass.FREQUENCY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_registry_enabled_default=False,
|
||||
|
@ -285,7 +285,7 @@ METER_ENTITY_DESCRIPTIONS: list[SensorEntityDescription] = [
|
|||
SensorEntityDescription(
|
||||
key="frequency_phase_average",
|
||||
name="Frequency phase average",
|
||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
device_class=SensorDeviceClass.FREQUENCY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
|
|
|
@ -13,12 +13,12 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
PERCENTAGE,
|
||||
PRESSURE_PSI,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -104,7 +104,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
|
|||
),
|
||||
SensorEntityDescription(
|
||||
key="GeneratorFrequency",
|
||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
device_class=SensorDeviceClass.FREQUENCY,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
|
|
|
@ -16,9 +16,9 @@ from homeassistant.config_entries import ConfigEntry
|
|||
from homeassistant.const import (
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
PERCENTAGE,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -80,7 +80,7 @@ POWERWALL_INSTANT_SENSORS = (
|
|||
name="Frequency Now",
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
device_class=SensorDeviceClass.FREQUENCY,
|
||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
entity_registry_enabled_default=False,
|
||||
value_fn=_get_meter_frequency,
|
||||
),
|
||||
|
|
|
@ -19,9 +19,9 @@ from homeassistant.const import (
|
|||
ELECTRIC_CURRENT_AMPERE,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -82,7 +82,7 @@ SENSOR_DESCRIPTIONS: dict[tuple[Units, bool], SensorEntityDescription] = {
|
|||
(Units.HZ, False): SensorEntityDescription(
|
||||
key=f"{Units.HZ}_{False}",
|
||||
device_class=SensorDeviceClass.FREQUENCY,
|
||||
native_unit_of_measurement=FREQUENCY_HERTZ,
|
||||
native_unit_of_measurement=UnitOfFrequency.HERTZ,
|
||||
state_class=SensorStateClass.MEASUREMENT,
|
||||
),
|
||||
(Units.NONE, False): SensorEntityDescription(
|
||||
|
|
|
@ -22,7 +22,6 @@ from homeassistant.const import (
|
|||
ELECTRIC_CURRENT_AMPERE,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
ENERGY_KILO_WATT_HOUR,
|
||||
FREQUENCY_HERTZ,
|
||||
LENGTH_CENTIMETERS,
|
||||
LIGHT_LUX,
|
||||
MASS_KILOGRAMS,
|
||||
|
@ -37,6 +36,7 @@ from homeassistant.const import (
|
|||
TEMP_FAHRENHEIT,
|
||||
TEMP_KELVIN,
|
||||
UnitOfApparentPower,
|
||||
UnitOfFrequency,
|
||||
UnitOfPower,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
@ -216,7 +216,7 @@ SENSOR_UNIT_MAP = {
|
|||
hc.ELECTRICAL_CURRENT_AMPERE: ELECTRIC_CURRENT_AMPERE,
|
||||
hc.ELECTRICAL_VOLT_AMPERE: UnitOfApparentPower.VOLT_AMPERE,
|
||||
hc.ENERGY_KILO_WATT_HOUR: ENERGY_KILO_WATT_HOUR,
|
||||
hc.FREQUENCY_HERTZ: FREQUENCY_HERTZ,
|
||||
hc.FREQUENCY_HERTZ: UnitOfFrequency.HERTZ,
|
||||
hc.LENGTH_CENTIMETERS: LENGTH_CENTIMETERS,
|
||||
hc.LIGHT_LUX: LIGHT_LUX,
|
||||
hc.MASS_KILOGRAMS: MASS_KILOGRAMS,
|
||||
|
|
|
@ -94,8 +94,6 @@ from homeassistant.const import (
|
|||
DEGREE,
|
||||
ELECTRIC_POTENTIAL_MILLIVOLT,
|
||||
ELECTRIC_POTENTIAL_VOLT,
|
||||
FREQUENCY_HERTZ,
|
||||
FREQUENCY_KILOHERTZ,
|
||||
LIGHT_LUX,
|
||||
PERCENTAGE,
|
||||
SIGNAL_STRENGTH_DECIBELS,
|
||||
|
@ -105,6 +103,7 @@ from homeassistant.const import (
|
|||
VOLUME_FLOW_RATE_CUBIC_METERS_PER_HOUR,
|
||||
UnitOfElectricCurrent,
|
||||
UnitOfEnergy,
|
||||
UnitOfFrequency,
|
||||
UnitOfIrradiance,
|
||||
UnitOfLength,
|
||||
UnitOfMass,
|
||||
|
@ -186,11 +185,11 @@ MULTILEVEL_SENSOR_UNIT_MAP: dict[str, set[MultilevelSensorScaleType]] = {
|
|||
UnitOfTemperature.FAHRENHEIT: UNIT_FAHRENHEIT,
|
||||
UnitOfLength.FEET: UNIT_FEET,
|
||||
UnitOfVolume.GALLONS: UNIT_GALLONS,
|
||||
FREQUENCY_HERTZ: UNIT_HERTZ,
|
||||
UnitOfFrequency.HERTZ: UNIT_HERTZ,
|
||||
UnitOfPressure.INHG: UNIT_INCHES_OF_MERCURY,
|
||||
UnitOfVolumetricFlux.INCHES_PER_HOUR: UNIT_INCHES_PER_HOUR,
|
||||
UnitOfMass.KILOGRAMS: UNIT_KILOGRAM,
|
||||
FREQUENCY_KILOHERTZ: UNIT_KILOHERTZ,
|
||||
UnitOfFrequency.KILOHERTZ: UNIT_KILOHERTZ,
|
||||
UnitOfVolume.LITERS: UNIT_LITER,
|
||||
LIGHT_LUX: UNIT_LUX,
|
||||
UnitOfLength.METERS: UNIT_METER,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue