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