Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"pydeconz.DeconzSession.request",
new=CoroutineMock(
return_value={
"config": {"bridgeid": "012345"},
"groups": {
"g1": {
"id": "gid",
"scenes": [{"id": "sc1", "name": "scene1"}],
"state": {},
"action": {},
"lights": [],
}
},
"lights": {"l1": {"state": {}}},
"sensors": {
"s1": {"type": GenericStatus.ZHATYPE[0], "state": {}, "config": {}}
},
}
),
):
await session.initialize()
assert "g1" in session.groups
assert session.groups["g1"].id == "gid"
assert "sc1" in session.groups["g1"].scenes
assert session.groups["g1"].deconz_id == "/groups/g1"
assert session.groups["g1"].scenes["sc1"].id == "sc1"
assert "l1" in session.lights
assert session.lights["l1"].deconz_id == "/lights/l1"
assert "s1" in session.sensors
assert session.sensors["s1"].deconz_id == "/sensors/s1"
assert session.sensors["s1"].type == GenericStatus.ZHATYPE[0]
"s1": {"type": GenericStatus.ZHATYPE[0], "state": {}, "config": {}}
},
}
),
):
await session.initialize()
assert "g1" in session.groups
assert session.groups["g1"].id == "gid"
assert "sc1" in session.groups["g1"].scenes
assert session.groups["g1"].deconz_id == "/groups/g1"
assert session.groups["g1"].scenes["sc1"].id == "sc1"
assert "l1" in session.lights
assert session.lights["l1"].deconz_id == "/lights/l1"
assert "s1" in session.sensors
assert session.sensors["s1"].deconz_id == "/sensors/s1"
assert session.sensors["s1"].type == GenericStatus.ZHATYPE[0]
@property
def water(self):
"""Water detected."""
return self.raw["state"].get("water")
SENSOR_CLASSES = (
Alarm,
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."""