diff --git a/homeassistant/components/accuweather/sensor.py b/homeassistant/components/accuweather/sensor.py index 9fd80362320..6991f5c872a 100644 --- a/homeassistant/components/accuweather/sensor.py +++ b/homeassistant/components/accuweather/sensor.py @@ -17,10 +17,10 @@ from homeassistant.const import ( PERCENTAGE, UV_INDEX, UnitOfLength, - UnitOfPrecipitationDepth, UnitOfSpeed, UnitOfTemperature, UnitOfTime, + UnitOfVolumetricFlux, ) from homeassistant.core import HomeAssistant, callback from homeassistant.helpers.entity_platform import AddEntitiesCallback @@ -290,11 +290,11 @@ SENSOR_TYPES: tuple[AccuWeatherSensorDescription, ...] = ( ), AccuWeatherSensorDescription( key="Precipitation", - device_class=SensorDeviceClass.PRECIPITATION, + device_class=SensorDeviceClass.PRECIPITATION_INTENSITY, name="Precipitation", state_class=SensorStateClass.MEASUREMENT, - metric_unit=UnitOfPrecipitationDepth.MILLIMETERS, - us_customary_unit=UnitOfPrecipitationDepth.INCHES, + metric_unit=UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR, + us_customary_unit=UnitOfVolumetricFlux.INCHES_PER_HOUR, value_fn=lambda data, unit: cast(float, data[unit][ATTR_VALUE]), attr_fn=lambda data: {"type": data["PrecipitationType"]}, ), @@ -452,7 +452,7 @@ def _get_sensor_data( return sensors[ATTR_FORECAST][forecast_day][kind] if kind == "Precipitation": - return sensors["PrecipitationSummary"][kind] + return sensors["PrecipitationSummary"]["PastHour"] return sensors[kind] diff --git a/tests/components/accuweather/test_sensor.py b/tests/components/accuweather/test_sensor.py index 26d9834e078..0182f7584b1 100644 --- a/tests/components/accuweather/test_sensor.py +++ b/tests/components/accuweather/test_sensor.py @@ -24,6 +24,7 @@ from homeassistant.const import ( UnitOfSpeed, UnitOfTemperature, UnitOfTime, + UnitOfVolumetricFlux, ) from homeassistant.helpers import entity_registry as er from homeassistant.setup import async_setup_component @@ -57,11 +58,17 @@ async def test_sensor_without_forecast(hass): assert state assert state.state == "0.0" assert state.attributes.get(ATTR_ATTRIBUTION) == ATTRIBUTION - assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfLength.MILLIMETERS + assert ( + state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) + == UnitOfVolumetricFlux.MILLIMETERS_PER_HOUR + ) assert state.attributes.get(ATTR_ICON) is None assert state.attributes.get("type") is None assert state.attributes.get(ATTR_STATE_CLASS) == SensorStateClass.MEASUREMENT - assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.PRECIPITATION + assert ( + state.attributes.get(ATTR_DEVICE_CLASS) + == SensorDeviceClass.PRECIPITATION_INTENSITY + ) entry = registry.async_get("sensor.home_precipitation") assert entry