Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Battery,
CarbonMonoxide,
Consumption,
Daylight,
Fire,
GenericFlag,
GenericStatus,
Humidity,
LightLevel,
OpenClose,
Power,
Presence,
Pressure,
Switch,
Temperature,
Thermostat,
Vibration,
Water,
)
def create_sensor(sensor_id, raw, request):
"""Simplify creating sensor by not needing to know type."""
for sensor_class in SENSOR_CLASSES:
if raw["type"] in sensor_class.ZHATYPE:
return sensor_class(sensor_id, raw, request)
_LOGGER.info("Unsupported sensor type %s (%s)", raw["type"], raw["name"])
return DeconzSensor(sensor_id, raw, request)
def async_add_climate(sensors, new=True):
"""Add climate devices from deCONZ."""
entities = []
for sensor in sensors:
if new and sensor.type in Thermostat.ZHATYPE:
entities.append(DeconzThermostat(sensor, gateway))
async_add_entities(entities, True)
If new is false it means an existing sensor has got a battery state reported.
"""
entities = []
for sensor in sensors:
if new and sensor.type in Switch.ZHATYPE:
if gateway.option_allow_clip_sensor or not sensor.type.startswith(
"CLIP"
):
new_event = DeconzEvent(sensor, gateway)
hass.async_create_task(new_event.async_update_device_registry())
gateway.events.append(new_event)
elif new and not sensor.BINARY and sensor.type not in Thermostat.ZHATYPE:
new_sensor = DeconzSensor(sensor, gateway)
entity_handler.add_entity(new_sensor)
entities.append(new_sensor)
if sensor.battery is not None:
new_battery = DeconzBattery(sensor, gateway)
if new_battery.unique_id not in batteries:
batteries.add(new_battery.unique_id)
entities.append(new_battery)
battery_handler.remove_tracker(sensor)
else:
battery_handler.create_tracker(sensor)
async_add_entities(entities, True)