diff --git a/homeassistant/components/unifiprotect/sensor.py b/homeassistant/components/unifiprotect/sensor.py index 78fc24026a3..e166d532dfb 100644 --- a/homeassistant/components/unifiprotect/sensor.py +++ b/homeassistant/components/unifiprotect/sensor.py @@ -181,6 +181,8 @@ CAMERA_SENSORS: tuple[ProtectSensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.MEASUREMENT, ufp_value="stats.storage.used", + suggested_unit_of_measurement=UnitOfInformation.MEGABYTES, + suggested_display_precision=2, ), ProtectSensorEntityDescription( key="write_rate", @@ -191,6 +193,8 @@ CAMERA_SENSORS: tuple[ProtectSensorEntityDescription, ...] = ( state_class=SensorStateClass.MEASUREMENT, ufp_value="stats.storage.rate_per_second", precision=2, + suggested_unit_of_measurement=UnitOfDataRate.MEGABYTES_PER_SECOND, + suggested_display_precision=2, ), ProtectSensorEntityDescription( key="voltage", @@ -280,6 +284,8 @@ CAMERA_DISABLED_SENSORS: tuple[ProtectSensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.TOTAL_INCREASING, ufp_value="stats.rx_bytes", + suggested_unit_of_measurement=UnitOfInformation.MEGABYTES, + suggested_display_precision=2, ), ProtectSensorEntityDescription( key="stats_tx", @@ -290,6 +296,8 @@ CAMERA_DISABLED_SENSORS: tuple[ProtectSensorEntityDescription, ...] = ( entity_category=EntityCategory.DIAGNOSTIC, state_class=SensorStateClass.TOTAL_INCREASING, ufp_value="stats.tx_bytes", + suggested_unit_of_measurement=UnitOfInformation.MEGABYTES, + suggested_display_precision=2, ), ) diff --git a/tests/components/unifiprotect/test_sensor.py b/tests/components/unifiprotect/test_sensor.py index a3155376a05..ac631ee41a6 100644 --- a/tests/components/unifiprotect/test_sensor.py +++ b/tests/components/unifiprotect/test_sensor.py @@ -327,8 +327,8 @@ async def test_sensor_setup_camera( expected_values = ( fixed_now.replace(microsecond=0).isoformat(), - "100", - "100.0", + "0.0001", + "0.0001", "20.0", ) for index, description in enumerate(CAMERA_SENSORS_WRITE): @@ -348,7 +348,7 @@ async def test_sensor_setup_camera( assert state.state == expected_values[index] assert state.attributes[ATTR_ATTRIBUTION] == DEFAULT_ATTRIBUTION - expected_values = ("100", "100") + expected_values = ("0.0001", "0.0001") for index, description in enumerate(CAMERA_DISABLED_SENSORS): unique_id, entity_id = ids_from_device_description( Platform.SENSOR, doorbell, description