diff --git a/homeassistant/components/gogogate2/sensor.py b/homeassistant/components/gogogate2/sensor.py index 7ad248b88d6..8788a69908e 100644 --- a/homeassistant/components/gogogate2/sensor.py +++ b/homeassistant/components/gogogate2/sensor.py @@ -5,7 +5,7 @@ from itertools import chain from ismartgate.common import AbstractDoor, get_configured_doors -from homeassistant.components.sensor import SensorEntity +from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( DEVICE_CLASS_BATTERY, @@ -77,6 +77,11 @@ class DoorSensorBattery(GoGoGate2Entity, SensorEntity): door = self._get_door() return door.voltage # This is a percentage, not an absolute voltage + @property + def state_class(self) -> str: + """Return the Measurement State Class.""" + return STATE_CLASS_MEASUREMENT + @property def extra_state_attributes(self): """Return the state attributes.""" @@ -104,6 +109,11 @@ class DoorSensorTemperature(GoGoGate2Entity, SensorEntity): """Return the name of the door.""" return f"{self._get_door().name} temperature" + @property + def state_class(self) -> str: + """Return the Measurement State Class.""" + return STATE_CLASS_MEASUREMENT + @property def device_class(self): """Return the class of this device, from component DEVICE_CLASSES.""" diff --git a/tests/components/gogogate2/test_sensor.py b/tests/components/gogogate2/test_sensor.py index 5adc4532750..1a59c5fd3c5 100644 --- a/tests/components/gogogate2/test_sensor.py +++ b/tests/components/gogogate2/test_sensor.py @@ -171,6 +171,7 @@ async def test_sensor_update(gogogate2api_mock, hass: HomeAssistant) -> None: "door_id": 1, "friendly_name": "Door1 battery", "sensor_id": "ABCD", + "state_class": "measurement", } temp_attributes = { "device_class": "temperature", @@ -178,6 +179,7 @@ async def test_sensor_update(gogogate2api_mock, hass: HomeAssistant) -> None: "friendly_name": "Door1 temperature", "sensor_id": "ABCD", "unit_of_measurement": "°C", + "state_class": "measurement", } api = MagicMock(GogoGate2Api) @@ -245,6 +247,7 @@ async def test_availability(ismartgateapi_mock, hass: HomeAssistant) -> None: "door_id": 1, "friendly_name": "Door1 battery", "sensor_id": "ABCD", + "state_class": "measurement", } temp_attributes = { "device_class": "temperature", @@ -252,6 +255,7 @@ async def test_availability(ismartgateapi_mock, hass: HomeAssistant) -> None: "friendly_name": "Door1 temperature", "sensor_id": "ABCD", "unit_of_measurement": "°C", + "state_class": "measurement", } sensor_response = _mocked_ismartgate_sensor_response(35, -4.0)