Set goalzero total run time sensor device class to duration (#146897)

This commit is contained in:
Nathan Spencer 2025-06-16 06:35:56 -06:00 committed by GitHub
parent c335b5b37c
commit 25c408484c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -109,6 +109,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = (
SensorEntityDescription(
key="timestamp",
translation_key="timestamp",
device_class=SensorDeviceClass.DURATION,
native_unit_of_measurement=UnitOfTime.SECONDS,
entity_registry_enabled_default=False,
entity_category=EntityCategory.DIAGNOSTIC,

View File

@ -97,7 +97,7 @@ async def test_sensors(
assert state.attributes.get(ATTR_STATE_CLASS) is None
state = hass.states.get(f"sensor.{DEFAULT_NAME}_total_run_time")
assert state.state == "1720984"
assert state.attributes.get(ATTR_DEVICE_CLASS) is None
assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.DURATION
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == UnitOfTime.SECONDS
assert state.attributes.get(ATTR_STATE_CLASS) is None
state = hass.states.get(f"sensor.{DEFAULT_NAME}_wi_fi_ssid")