Use new DeviceClass and EntityCategory enums in august (#61288)

Co-authored-by: epenet <epenet@users.noreply.github.com>
This commit is contained in:
epenet
2021-12-08 22:15:15 +01:00
committed by GitHub
parent b2ae018837
commit 7c09cff3ad
2 changed files with 13 additions and 20 deletions

View File

@@ -19,15 +19,12 @@ from yalexs.util import update_lock_detail_from_activity
from homeassistant.components.august import AugustData
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_CONNECTIVITY,
DEVICE_CLASS_DOOR,
DEVICE_CLASS_MOTION,
DEVICE_CLASS_OCCUPANCY,
BinarySensorDeviceClass,
BinarySensorEntity,
BinarySensorEntityDescription,
)
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
from homeassistant.core import callback
from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.event import async_call_later
from .const import ACTIVITY_UPDATE_INTERVAL, DATA_AUGUST, DOMAIN
@@ -115,22 +112,22 @@ SENSOR_TYPES_DOORBELL: tuple[AugustBinarySensorEntityDescription, ...] = (
AugustBinarySensorEntityDescription(
key="doorbell_ding",
name="Ding",
device_class=DEVICE_CLASS_OCCUPANCY,
device_class=BinarySensorDeviceClass.OCCUPANCY,
value_fn=_retrieve_ding_state,
is_time_based=True,
),
AugustBinarySensorEntityDescription(
key="doorbell_motion",
name="Motion",
device_class=DEVICE_CLASS_MOTION,
device_class=BinarySensorDeviceClass.MOTION,
value_fn=_retrieve_motion_state,
is_time_based=True,
),
AugustBinarySensorEntityDescription(
key="doorbell_online",
name="Online",
device_class=DEVICE_CLASS_CONNECTIVITY,
entity_category=ENTITY_CATEGORY_DIAGNOSTIC,
device_class=BinarySensorDeviceClass.CONNECTIVITY,
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=_retrieve_online_state,
is_time_based=False,
),
@@ -169,7 +166,7 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
class AugustDoorBinarySensor(AugustEntityMixin, BinarySensorEntity):
"""Representation of an August Door binary sensor."""
_attr_device_class = DEVICE_CLASS_DOOR
_attr_device_class = BinarySensorDeviceClass.DOOR
def __init__(self, data, device, description: BinarySensorEntityDescription):
"""Initialize the sensor."""