parent
164f09c1f0
commit
f25d3cf9b3
|
@ -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."""
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue