diff --git a/homeassistant/components/weatherflow_cloud/sensor.py b/homeassistant/components/weatherflow_cloud/sensor.py index 5bad1eacdddf..fb48a87d590b 100644 --- a/homeassistant/components/weatherflow_cloud/sensor.py +++ b/homeassistant/components/weatherflow_cloud/sensor.py @@ -23,6 +23,7 @@ from homeassistant.components.sensor import ( from homeassistant.const import ( EntityCategory, UnitOfLength, + UnitOfPrecipitationDepth, UnitOfPressure, UnitOfSpeed, UnitOfTemperature, @@ -237,42 +238,47 @@ WF_SENSORS: tuple[WeatherFlowCloudSensorEntityDescription, ...] = ( WeatherFlowCloudSensorEntityDescription( key="precip_accum_last_1hr", translation_key="precip_accum_last_1hr", + device_class=SensorDeviceClass.PRECIPITATION, state_class=SensorStateClass.MEASUREMENT, suggested_display_precision=1, value_fn=lambda data: data.precip_accum_last_1hr, - native_unit_of_measurement=UnitOfLength.MILLIMETERS, + native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS, ), WeatherFlowCloudSensorEntityDescription( key="precip_accum_local_day", translation_key="precip_accum_local_day", + device_class=SensorDeviceClass.PRECIPITATION, state_class=SensorStateClass.MEASUREMENT, suggested_display_precision=1, value_fn=lambda data: data.precip_accum_local_day, - native_unit_of_measurement=UnitOfLength.MILLIMETERS, + native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS, ), WeatherFlowCloudSensorEntityDescription( key="precip_accum_local_day_final", translation_key="precip_accum_local_day_final", + device_class=SensorDeviceClass.PRECIPITATION, state_class=SensorStateClass.MEASUREMENT, suggested_display_precision=1, value_fn=lambda data: data.precip_accum_local_day_final, - native_unit_of_measurement=UnitOfLength.MILLIMETERS, + native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS, ), WeatherFlowCloudSensorEntityDescription( key="precip_accum_local_yesterday", translation_key="precip_accum_local_yesterday", + device_class=SensorDeviceClass.PRECIPITATION, state_class=SensorStateClass.MEASUREMENT, suggested_display_precision=1, value_fn=lambda data: data.precip_accum_local_yesterday, - native_unit_of_measurement=UnitOfLength.MILLIMETERS, + native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS, ), WeatherFlowCloudSensorEntityDescription( key="precip_accum_local_yesterday_final", translation_key="precip_accum_local_yesterday_final", + device_class=SensorDeviceClass.PRECIPITATION, state_class=SensorStateClass.MEASUREMENT, suggested_display_precision=1, value_fn=lambda data: data.precip_accum_local_yesterday_final, - native_unit_of_measurement=UnitOfLength.MILLIMETERS, + native_unit_of_measurement=UnitOfPrecipitationDepth.MILLIMETERS, ), WeatherFlowCloudSensorEntityDescription( key="precip_analysis_type_yesterday", diff --git a/tests/components/weatherflow_cloud/snapshots/test_sensor.ambr b/tests/components/weatherflow_cloud/snapshots/test_sensor.ambr index 47944adb3f72..4a430edb5abb 100644 --- a/tests/components/weatherflow_cloud/snapshots/test_sensor.ambr +++ b/tests/components/weatherflow_cloud/snapshots/test_sensor.ambr @@ -595,7 +595,7 @@ 'suggested_display_precision': 1, }), }), - 'original_device_class': None, + 'original_device_class': , 'original_icon': None, 'original_name': 'Nearcast precipitation today', 'platform': 'weatherflow_cloud', @@ -604,16 +604,17 @@ 'supported_features': 0, 'translation_key': 'precip_accum_local_day_final', 'unique_id': '24432_precip_accum_local_day_final', - 'unit_of_measurement': , + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.my_home_station_nearcast_precipitation_today-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'attribution': 'Weather data delivered by WeatherFlow/Tempest API', + 'device_class': 'precipitation', 'friendly_name': 'My Home Station Nearcast precipitation today', 'state_class': , - 'unit_of_measurement': , + 'unit_of_measurement': , }), 'context': , 'entity_id': 'sensor.my_home_station_nearcast_precipitation_today', @@ -653,7 +654,7 @@ 'suggested_display_precision': 1, }), }), - 'original_device_class': None, + 'original_device_class': , 'original_icon': None, 'original_name': 'Nearcast precipitation yesterday', 'platform': 'weatherflow_cloud', @@ -662,16 +663,17 @@ 'supported_features': 0, 'translation_key': 'precip_accum_local_yesterday_final', 'unique_id': '24432_precip_accum_local_yesterday_final', - 'unit_of_measurement': , + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.my_home_station_nearcast_precipitation_yesterday-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'attribution': 'Weather data delivered by WeatherFlow/Tempest API', + 'device_class': 'precipitation', 'friendly_name': 'My Home Station Nearcast precipitation yesterday', 'state_class': , - 'unit_of_measurement': , + 'unit_of_measurement': , }), 'context': , 'entity_id': 'sensor.my_home_station_nearcast_precipitation_yesterday', @@ -827,7 +829,7 @@ 'suggested_display_precision': 1, }), }), - 'original_device_class': None, + 'original_device_class': , 'original_icon': None, 'original_name': 'Precipitation today', 'platform': 'weatherflow_cloud', @@ -836,16 +838,17 @@ 'supported_features': 0, 'translation_key': 'precip_accum_local_day', 'unique_id': '24432_precip_accum_local_day', - 'unit_of_measurement': , + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.my_home_station_precipitation_today-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'attribution': 'Weather data delivered by WeatherFlow/Tempest API', + 'device_class': 'precipitation', 'friendly_name': 'My Home Station Precipitation today', 'state_class': , - 'unit_of_measurement': , + 'unit_of_measurement': , }), 'context': , 'entity_id': 'sensor.my_home_station_precipitation_today', @@ -955,7 +958,7 @@ 'suggested_display_precision': 1, }), }), - 'original_device_class': None, + 'original_device_class': , 'original_icon': None, 'original_name': 'Precipitation yesterday', 'platform': 'weatherflow_cloud', @@ -964,16 +967,17 @@ 'supported_features': 0, 'translation_key': 'precip_accum_local_yesterday', 'unique_id': '24432_precip_accum_local_yesterday', - 'unit_of_measurement': , + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.my_home_station_precipitation_yesterday-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'attribution': 'Weather data delivered by WeatherFlow/Tempest API', + 'device_class': 'precipitation', 'friendly_name': 'My Home Station Precipitation yesterday', 'state_class': , - 'unit_of_measurement': , + 'unit_of_measurement': , }), 'context': , 'entity_id': 'sensor.my_home_station_precipitation_yesterday', @@ -1137,7 +1141,7 @@ 'suggested_display_precision': 1, }), }), - 'original_device_class': None, + 'original_device_class': , 'original_icon': None, 'original_name': 'Rain last hour', 'platform': 'weatherflow_cloud', @@ -1146,16 +1150,17 @@ 'supported_features': 0, 'translation_key': 'precip_accum_last_1hr', 'unique_id': '24432_precip_accum_last_1hr', - 'unit_of_measurement': , + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.my_home_station_rain_last_hour-state] StateSnapshot({ 'attributes': ReadOnlyDict({ 'attribution': 'Weather data delivered by WeatherFlow/Tempest API', + 'device_class': 'precipitation', 'friendly_name': 'My Home Station Rain last hour', 'state_class': , - 'unit_of_measurement': , + 'unit_of_measurement': , }), 'context': , 'entity_id': 'sensor.my_home_station_rain_last_hour',