Gogogate2 Battery Sensor Should Use % Unit For Compatibility (#59434)

This commit is contained in:
Nicolas Mowen 2021-11-10 10:58:54 -07:00 committed by GitHub
parent ab1e14204f
commit 20f0a6730b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View file

@ -11,6 +11,7 @@ from homeassistant.const import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_TEMPERATURE,
ENTITY_CATEGORY_DIAGNOSTIC,
PERCENTAGE,
TEMP_CELSIUS,
)
from homeassistant.core import HomeAssistant
@ -78,6 +79,7 @@ class DoorSensorBattery(DoorSensorEntity):
super().__init__(config_entry, data_update_coordinator, door, unique_id)
self._attr_device_class = DEVICE_CLASS_BATTERY
self._attr_state_class = STATE_CLASS_MEASUREMENT
self._attr_native_unit_of_measurement = PERCENTAGE
@property
def name(self):

View file

@ -172,6 +172,7 @@ async def test_sensor_update(gogogate2api_mock, hass: HomeAssistant) -> None:
"friendly_name": "Door1 battery",
"sensor_id": "ABCD",
"state_class": "measurement",
"unit_of_measurement": "%",
}
temp_attributes = {
"device_class": "temperature",
@ -248,6 +249,7 @@ async def test_availability(ismartgateapi_mock, hass: HomeAssistant) -> None:
"friendly_name": "Door1 battery",
"sensor_id": "ABCD",
"state_class": "measurement",
"unit_of_measurement": "%",
}
temp_attributes = {
"device_class": "temperature",