mirror of
https://github.com/home-assistant/core.git
synced 2025-11-14 21:40:16 +00:00
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:
@@ -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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user