diff --git a/homeassistant/components/flipr/sensor.py b/homeassistant/components/flipr/sensor.py index 99b44cc95a0..57044289110 100644 --- a/homeassistant/components/flipr/sensor.py +++ b/homeassistant/components/flipr/sensor.py @@ -8,7 +8,7 @@ from homeassistant.components.sensor import ( SensorStateClass, ) from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ELECTRIC_POTENTIAL_MILLIVOLT, PERCENTAGE, TEMP_CELSIUS +from homeassistant.const import PERCENTAGE, UnitOfElectricPotential, UnitOfTemperature from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -19,7 +19,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="chlorine", name="Chlorine", - native_unit_of_measurement=ELECTRIC_POTENTIAL_MILLIVOLT, + native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT, icon="mdi:pool", state_class=SensorStateClass.MEASUREMENT, ), @@ -33,7 +33,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( key="temperature", name="Water Temp", device_class=SensorDeviceClass.TEMPERATURE, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( @@ -44,7 +44,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="red_ox", name="Red OX", - native_unit_of_measurement=ELECTRIC_POTENTIAL_MILLIVOLT, + native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT, icon="mdi:pool", state_class=SensorStateClass.MEASUREMENT, ), diff --git a/homeassistant/components/omnilogic/sensor.py b/homeassistant/components/omnilogic/sensor.py index d072cc3d9bd..23cff2382f6 100644 --- a/homeassistant/components/omnilogic/sensor.py +++ b/homeassistant/components/omnilogic/sensor.py @@ -5,11 +5,10 @@ from homeassistant.components.sensor import SensorDeviceClass, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, - ELECTRIC_POTENTIAL_MILLIVOLT, PERCENTAGE, - TEMP_CELSIUS, - TEMP_FAHRENHEIT, + UnitOfElectricPotential, UnitOfMass, + UnitOfTemperature, UnitOfVolume, ) from homeassistant.core import HomeAssistant @@ -108,12 +107,12 @@ class OmniLogicTemperatureSensor(OmnilogicSensor): sensor_data = self.coordinator.data[self._item_id][self._state_key] hayward_state = sensor_data - hayward_unit_of_measure = TEMP_FAHRENHEIT + hayward_unit_of_measure = UnitOfTemperature.FAHRENHEIT state = sensor_data if self._unit_type == "Metric": hayward_state = round((int(hayward_state) - 32) * 5 / 9, 1) - hayward_unit_of_measure = TEMP_CELSIUS + hayward_unit_of_measure = UnitOfTemperature.CELSIUS if int(sensor_data) == -1: hayward_state = None @@ -122,7 +121,7 @@ class OmniLogicTemperatureSensor(OmnilogicSensor): self._attrs["hayward_temperature"] = hayward_state self._attrs["hayward_unit_of_measure"] = hayward_unit_of_measure - self._unit = TEMP_FAHRENHEIT + self._unit = UnitOfTemperature.FAHRENHEIT return state @@ -259,7 +258,7 @@ SENSOR_TYPES: dict[tuple[int, str], list[dict[str, Any]]] = { "kind": "air_temperature", "device_class": SensorDeviceClass.TEMPERATURE, "icon": None, - "unit": TEMP_FAHRENHEIT, + "unit": UnitOfTemperature.FAHRENHEIT, "guard_condition": [{}], }, ], @@ -270,7 +269,7 @@ SENSOR_TYPES: dict[tuple[int, str], list[dict[str, Any]]] = { "kind": "water_temperature", "device_class": SensorDeviceClass.TEMPERATURE, "icon": None, - "unit": TEMP_FAHRENHEIT, + "unit": UnitOfTemperature.FAHRENHEIT, "guard_condition": [{}], }, ], @@ -351,7 +350,7 @@ SENSOR_TYPES: dict[tuple[int, str], list[dict[str, Any]]] = { "kind": "csad_orp", "device_class": None, "icon": "mdi:gauge", - "unit": ELECTRIC_POTENTIAL_MILLIVOLT, + "unit": UnitOfElectricPotential.MILLIVOLT, "guard_condition": [ {"orp": ""}, ], diff --git a/homeassistant/components/ondilo_ico/sensor.py b/homeassistant/components/ondilo_ico/sensor.py index b4c6e02879e..b6a3b25f3f2 100644 --- a/homeassistant/components/ondilo_ico/sensor.py +++ b/homeassistant/components/ondilo_ico/sensor.py @@ -15,9 +15,9 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONCENTRATION_PARTS_PER_MILLION, - ELECTRIC_POTENTIAL_MILLIVOLT, PERCENTAGE, - TEMP_CELSIUS, + UnitOfElectricPotential, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo @@ -34,24 +34,21 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="temperature", name="Temperature", - native_unit_of_measurement=TEMP_CELSIUS, - icon=None, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="orp", name="Oxydo Reduction Potential", - native_unit_of_measurement=ELECTRIC_POTENTIAL_MILLIVOLT, + native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT, icon="mdi:pool", - device_class=None, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="ph", name="pH", icon="mdi:pool", - device_class=None, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( @@ -59,14 +56,12 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( name="TDS", native_unit_of_measurement=CONCENTRATION_PARTS_PER_MILLION, icon="mdi:pool", - device_class=None, state_class=SensorStateClass.MEASUREMENT, ), SensorEntityDescription( key="battery", name="Battery", native_unit_of_measurement=PERCENTAGE, - icon=None, device_class=SensorDeviceClass.BATTERY, state_class=SensorStateClass.MEASUREMENT, ), @@ -74,7 +69,6 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( key="rssi", name="RSSI", native_unit_of_measurement=PERCENTAGE, - icon=None, device_class=SensorDeviceClass.SIGNAL_STRENGTH, state_class=SensorStateClass.MEASUREMENT, ), @@ -83,7 +77,6 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( name="Salt", native_unit_of_measurement="mg/L", icon="mdi:pool", - device_class=None, state_class=SensorStateClass.MEASUREMENT, ), ) diff --git a/homeassistant/components/poolsense/sensor.py b/homeassistant/components/poolsense/sensor.py index 250229867bf..f8f91620321 100644 --- a/homeassistant/components/poolsense/sensor.py +++ b/homeassistant/components/poolsense/sensor.py @@ -9,9 +9,9 @@ from homeassistant.components.sensor import ( from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( CONF_EMAIL, - ELECTRIC_POTENTIAL_MILLIVOLT, PERCENTAGE, - TEMP_CELSIUS, + UnitOfElectricPotential, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -22,7 +22,7 @@ from .const import DOMAIN SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="Chlorine", - native_unit_of_measurement=ELECTRIC_POTENTIAL_MILLIVOLT, + native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT, icon="mdi:pool", name="Chlorine", ), @@ -39,7 +39,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( ), SensorEntityDescription( key="Water Temp", - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, icon="mdi:coolant-temperature", name="Temperature", device_class=SensorDeviceClass.TEMPERATURE, @@ -52,13 +52,13 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( ), SensorEntityDescription( key="Chlorine High", - native_unit_of_measurement=ELECTRIC_POTENTIAL_MILLIVOLT, + native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT, icon="mdi:pool", name="Chlorine High", ), SensorEntityDescription( key="Chlorine Low", - native_unit_of_measurement=ELECTRIC_POTENTIAL_MILLIVOLT, + native_unit_of_measurement=UnitOfElectricPotential.MILLIVOLT, icon="mdi:pool", name="Chlorine Low", ),