Add door sensors to Yale Access Bluetooth (#76571)

pull/76595/head
J. Nick Koston 2022-08-10 15:34:48 -10:00 committed by GitHub
parent 6e65cb4928
commit 828ea99c61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 1 deletions

View File

@ -1484,6 +1484,7 @@ omit =
homeassistant/components/xmpp/notify.py
homeassistant/components/xs1/*
homeassistant/components/yalexs_ble/__init__.py
homeassistant/components/yalexs_ble/binary_sensor.py
homeassistant/components/yalexs_ble/entity.py
homeassistant/components/yalexs_ble/lock.py
homeassistant/components/yalexs_ble/util.py

View File

@ -16,7 +16,7 @@ from .const import CONF_KEY, CONF_LOCAL_NAME, CONF_SLOT, DEVICE_TIMEOUT, DOMAIN
from .models import YaleXSBLEData
from .util import async_find_existing_service_info, bluetooth_callback_matcher
PLATFORMS: list[Platform] = [Platform.LOCK]
PLATFORMS: list[Platform] = [Platform.BINARY_SENSOR, Platform.LOCK]
async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:

View File

@ -0,0 +1,41 @@
"""Support for yalexs ble binary sensors."""
from __future__ import annotations
from yalexs_ble import ConnectionInfo, DoorStatus, LockInfo, LockState
from homeassistant import config_entries
from homeassistant.components.binary_sensor import (
BinarySensorDeviceClass,
BinarySensorEntity,
)
from homeassistant.core import HomeAssistant, callback
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .const import DOMAIN
from .entity import YALEXSBLEEntity
from .models import YaleXSBLEData
async def async_setup_entry(
hass: HomeAssistant,
entry: config_entries.ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up YALE XS binary sensors."""
data: YaleXSBLEData = hass.data[DOMAIN][entry.entry_id]
async_add_entities([YaleXSBLEDoorSensor(data)])
class YaleXSBLEDoorSensor(YALEXSBLEEntity, BinarySensorEntity):
"""Yale XS BLE binary sensor."""
_attr_device_class = BinarySensorDeviceClass.DOOR
_attr_has_entity_name = True
@callback
def _async_update_state(
self, new_state: LockState, lock_info: LockInfo, connection_info: ConnectionInfo
) -> None:
"""Update the state."""
self._attr_is_on = new_state.door == DoorStatus.OPENED
super()._async_update_state(new_state, lock_info, connection_info)