Use isinstance to verify class in deCONZ integration (#56794)

* Don't enable any variants of the daylight sensor entities by default

* Use isinstance rather than doing ZHATYPE compare

* Accidentally removed an import
This commit is contained in:
Robert Svensson
2021-09-29 21:19:21 +02:00
committed by GitHub
parent 0463007050
commit f224ab6d67
13 changed files with 95 additions and 86 deletions

View File

@@ -1,5 +1,15 @@
"""Support for deCONZ binary sensors."""
from pydeconz.sensor import CarbonMonoxide, Fire, OpenClose, Presence, Vibration, Water
from pydeconz.sensor import (
Alarm,
CarbonMonoxide,
Fire,
GenericFlag,
GenericStatus,
OpenClose,
Presence,
Vibration,
Water,
)
from homeassistant.components.binary_sensor import (
DEVICE_CLASS_GAS,
@@ -21,6 +31,18 @@ from .const import ATTR_DARK, ATTR_ON, NEW_SENSOR
from .deconz_device import DeconzDevice
from .gateway import get_gateway_from_config_entry
DECONZ_BINARY_SENSORS = (
Alarm,
CarbonMonoxide,
Fire,
GenericFlag,
GenericStatus,
OpenClose,
Presence,
Vibration,
Water,
)
ATTR_ORIENTATION = "orientation"
ATTR_TILTANGLE = "tiltangle"
ATTR_VIBRATIONSTRENGTH = "vibrationstrength"
@@ -65,13 +87,12 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
for sensor in sensors:
if not gateway.option_allow_clip_sensor and sensor.type.startswith("CLIP"):
continue
if (
sensor.BINARY
isinstance(sensor, DECONZ_BINARY_SENSORS)
and sensor.unique_id not in gateway.entities[DOMAIN]
and (
gateway.option_allow_clip_sensor
or not sensor.type.startswith("CLIP")
)
):
entities.append(DeconzBinarySensor(sensor, gateway))