diff --git a/homeassistant/components/goodwe/sensor.py b/homeassistant/components/goodwe/sensor.py index 9b9ff0db933..546cc0fdb39 100644 --- a/homeassistant/components/goodwe/sensor.py +++ b/homeassistant/components/goodwe/sensor.py @@ -17,13 +17,13 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - ELECTRIC_POTENTIAL_VOLT, - ENERGY_KILO_WATT_HOUR, - FREQUENCY_HERTZ, PERCENTAGE, - POWER_WATT, - TEMP_CELSIUS, UnitOfElectricCurrent, + UnitOfElectricPotential, + UnitOfEnergy, + UnitOfFrequency, + UnitOfPower, + UnitOfTemperature, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity import DeviceInfo, EntityCategory @@ -92,19 +92,19 @@ _DESCRIPTIONS: dict[str, GoodweSensorEntityDescription] = { key="V", device_class=SensorDeviceClass.VOLTAGE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=ELECTRIC_POTENTIAL_VOLT, + native_unit_of_measurement=UnitOfElectricPotential.VOLT, ), "W": GoodweSensorEntityDescription( key="W", device_class=SensorDeviceClass.POWER, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=POWER_WATT, + native_unit_of_measurement=UnitOfPower.WATT, ), "kWh": GoodweSensorEntityDescription( key="kWh", device_class=SensorDeviceClass.ENERGY, state_class=SensorStateClass.TOTAL_INCREASING, - native_unit_of_measurement=ENERGY_KILO_WATT_HOUR, + native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, value=lambda prev, val: prev if not val else val, available=lambda entity: entity.coordinator.data is not None, ), @@ -112,13 +112,13 @@ _DESCRIPTIONS: dict[str, GoodweSensorEntityDescription] = { key="C", device_class=SensorDeviceClass.TEMPERATURE, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=TEMP_CELSIUS, + native_unit_of_measurement=UnitOfTemperature.CELSIUS, ), "Hz": GoodweSensorEntityDescription( key="Hz", - device_class=SensorDeviceClass.VOLTAGE, + device_class=SensorDeviceClass.FREQUENCY, state_class=SensorStateClass.MEASUREMENT, - native_unit_of_measurement=FREQUENCY_HERTZ, + native_unit_of_measurement=UnitOfFrequency.HERTZ, ), "%": GoodweSensorEntityDescription( key="%",