From 048553cd02a45956c3b7608cb405314517553fa1 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Tue, 6 Dec 2022 12:14:15 +0100 Subject: [PATCH] Fix Goalzero time to empty sensor device class (#83389) * Fix Goalzero time to empty sensor device class * Fix tests --- homeassistant/components/goalzero/sensor.py | 2 +- tests/components/goalzero/test_sensor.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/goalzero/sensor.py b/homeassistant/components/goalzero/sensor.py index 345c3b41f7d..2538639883c 100644 --- a/homeassistant/components/goalzero/sensor.py +++ b/homeassistant/components/goalzero/sensor.py @@ -91,7 +91,7 @@ SENSOR_TYPES: tuple[SensorEntityDescription, ...] = ( SensorEntityDescription( key="timeToEmptyFull", name="Time to empty/full", - device_class=TIME_MINUTES, + device_class=SensorDeviceClass.DURATION, native_unit_of_measurement=TIME_MINUTES, ), SensorEntityDescription( diff --git a/tests/components/goalzero/test_sensor.py b/tests/components/goalzero/test_sensor.py index e61015a4925..402c03f2e51 100644 --- a/tests/components/goalzero/test_sensor.py +++ b/tests/components/goalzero/test_sensor.py @@ -77,7 +77,7 @@ async def test_sensors( assert state.attributes.get(ATTR_STATE_CLASS) is None state = hass.states.get(f"sensor.{DEFAULT_NAME}_time_to_empty_full") assert state.state == "-1" - assert state.attributes.get(ATTR_DEVICE_CLASS) == TIME_MINUTES + assert state.attributes.get(ATTR_DEVICE_CLASS) == SensorDeviceClass.DURATION assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) == TIME_MINUTES assert state.attributes.get(ATTR_STATE_CLASS) is None state = hass.states.get(f"sensor.{DEFAULT_NAME}_temperature")