Add some suggested units to unifiprotect sensors (#119790)

This commit is contained in:
J. Nick Koston 2024-06-16 15:04:28 -05:00 committed by GitHub
parent affbc30d0d
commit 85ca6f15be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 3 deletions

View File

@ -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,
),
)

View File

@ -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