mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 19:27:45 +00:00
Gogogate2 add statistics (#58178)
Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
parent
164f09c1f0
commit
f25d3cf9b3
@ -5,7 +5,7 @@ from itertools import chain
|
|||||||
|
|
||||||
from ismartgate.common import AbstractDoor, get_configured_doors
|
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.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
DEVICE_CLASS_BATTERY,
|
DEVICE_CLASS_BATTERY,
|
||||||
@ -77,6 +77,11 @@ class DoorSensorBattery(GoGoGate2Entity, SensorEntity):
|
|||||||
door = self._get_door()
|
door = self._get_door()
|
||||||
return door.voltage # This is a percentage, not an absolute voltage
|
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
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self):
|
||||||
"""Return the state attributes."""
|
"""Return the state attributes."""
|
||||||
@ -104,6 +109,11 @@ class DoorSensorTemperature(GoGoGate2Entity, SensorEntity):
|
|||||||
"""Return the name of the door."""
|
"""Return the name of the door."""
|
||||||
return f"{self._get_door().name} temperature"
|
return f"{self._get_door().name} temperature"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def state_class(self) -> str:
|
||||||
|
"""Return the Measurement State Class."""
|
||||||
|
return STATE_CLASS_MEASUREMENT
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self):
|
def device_class(self):
|
||||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
"""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,
|
"door_id": 1,
|
||||||
"friendly_name": "Door1 battery",
|
"friendly_name": "Door1 battery",
|
||||||
"sensor_id": "ABCD",
|
"sensor_id": "ABCD",
|
||||||
|
"state_class": "measurement",
|
||||||
}
|
}
|
||||||
temp_attributes = {
|
temp_attributes = {
|
||||||
"device_class": "temperature",
|
"device_class": "temperature",
|
||||||
@ -178,6 +179,7 @@ async def test_sensor_update(gogogate2api_mock, hass: HomeAssistant) -> None:
|
|||||||
"friendly_name": "Door1 temperature",
|
"friendly_name": "Door1 temperature",
|
||||||
"sensor_id": "ABCD",
|
"sensor_id": "ABCD",
|
||||||
"unit_of_measurement": "°C",
|
"unit_of_measurement": "°C",
|
||||||
|
"state_class": "measurement",
|
||||||
}
|
}
|
||||||
|
|
||||||
api = MagicMock(GogoGate2Api)
|
api = MagicMock(GogoGate2Api)
|
||||||
@ -245,6 +247,7 @@ async def test_availability(ismartgateapi_mock, hass: HomeAssistant) -> None:
|
|||||||
"door_id": 1,
|
"door_id": 1,
|
||||||
"friendly_name": "Door1 battery",
|
"friendly_name": "Door1 battery",
|
||||||
"sensor_id": "ABCD",
|
"sensor_id": "ABCD",
|
||||||
|
"state_class": "measurement",
|
||||||
}
|
}
|
||||||
temp_attributes = {
|
temp_attributes = {
|
||||||
"device_class": "temperature",
|
"device_class": "temperature",
|
||||||
@ -252,6 +255,7 @@ async def test_availability(ismartgateapi_mock, hass: HomeAssistant) -> None:
|
|||||||
"friendly_name": "Door1 temperature",
|
"friendly_name": "Door1 temperature",
|
||||||
"sensor_id": "ABCD",
|
"sensor_id": "ABCD",
|
||||||
"unit_of_measurement": "°C",
|
"unit_of_measurement": "°C",
|
||||||
|
"state_class": "measurement",
|
||||||
}
|
}
|
||||||
|
|
||||||
sensor_response = _mocked_ismartgate_sensor_response(35, -4.0)
|
sensor_response = _mocked_ismartgate_sensor_response(35, -4.0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user