Avoid creating door sensor when it does no exist on older yalexs_ble locks (#76710)

This commit is contained in:
J. Nick Koston 2022-08-13 12:47:35 -10:00 committed by GitHub
parent bac44cf473
commit b4a840c00d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,7 +23,9 @@ async def async_setup_entry(
) -> None:
"""Set up YALE XS binary sensors."""
data: YaleXSBLEData = hass.data[DOMAIN][entry.entry_id]
async_add_entities([YaleXSBLEDoorSensor(data)])
lock = data.lock
if lock.lock_info and lock.lock_info.door_sense:
async_add_entities([YaleXSBLEDoorSensor(data)])
class YaleXSBLEDoorSensor(YALEXSBLEEntity, BinarySensorEntity):