Use new enums in gogogate2 (#61515)
Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
parent
997809c6c4
commit
a691abaa50
2 changed files with 14 additions and 16 deletions
|
@ -9,10 +9,9 @@ from ismartgate.common import (
|
|||
)
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
DEVICE_CLASS_GARAGE,
|
||||
DEVICE_CLASS_GATE,
|
||||
SUPPORT_CLOSE,
|
||||
SUPPORT_OPEN,
|
||||
CoverDeviceClass,
|
||||
CoverEntity,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -57,7 +56,7 @@ class DeviceCover(GoGoGate2Entity, CoverEntity):
|
|||
super().__init__(config_entry, data_update_coordinator, door, unique_id)
|
||||
self._attr_supported_features = SUPPORT_OPEN | SUPPORT_CLOSE
|
||||
self._attr_device_class = (
|
||||
DEVICE_CLASS_GATE if self.door.gate else DEVICE_CLASS_GARAGE
|
||||
CoverDeviceClass.GATE if self.door.gate else CoverDeviceClass.GARAGE
|
||||
)
|
||||
|
||||
@property
|
||||
|
|
|
@ -5,16 +5,15 @@ from itertools import chain
|
|||
|
||||
from ismartgate.common import AbstractDoor, get_configured_doors
|
||||
|
||||
from homeassistant.components.sensor import STATE_CLASS_MEASUREMENT, SensorEntity
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import (
|
||||
DEVICE_CLASS_BATTERY,
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
ENTITY_CATEGORY_DIAGNOSTIC,
|
||||
PERCENTAGE,
|
||||
TEMP_CELSIUS,
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorStateClass,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import PERCENTAGE, TEMP_CELSIUS
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
|
||||
from .common import (
|
||||
|
@ -66,7 +65,7 @@ class DoorSensorEntity(GoGoGate2Entity, SensorEntity):
|
|||
class DoorSensorBattery(DoorSensorEntity):
|
||||
"""Battery sensor entity for gogogate2 door sensor."""
|
||||
|
||||
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC
|
||||
_attr_entity_category = EntityCategory.DIAGNOSTIC
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
|
@ -77,8 +76,8 @@ class DoorSensorBattery(DoorSensorEntity):
|
|||
"""Initialize the object."""
|
||||
unique_id = sensor_unique_id(config_entry, door, "battery")
|
||||
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_device_class = SensorDeviceClass.BATTERY
|
||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||
self._attr_native_unit_of_measurement = PERCENTAGE
|
||||
|
||||
@property
|
||||
|
@ -104,8 +103,8 @@ class DoorSensorTemperature(DoorSensorEntity):
|
|||
"""Initialize the object."""
|
||||
unique_id = sensor_unique_id(config_entry, door, "temperature")
|
||||
super().__init__(config_entry, data_update_coordinator, door, unique_id)
|
||||
self._attr_device_class = DEVICE_CLASS_TEMPERATURE
|
||||
self._attr_state_class = STATE_CLASS_MEASUREMENT
|
||||
self._attr_device_class = SensorDeviceClass.TEMPERATURE
|
||||
self._attr_state_class = SensorStateClass.MEASUREMENT
|
||||
self._attr_native_unit_of_measurement = TEMP_CELSIUS
|
||||
|
||||
@property
|
||||
|
|
Loading…
Add table
Reference in a new issue