Indentify IKEA and Phillips motion sensors correctly (#41111)

This commit is contained in:
Abílio Costa authored and GitHub committed 2020-10-03 19:52:21 -04:00
1 parent a73daa5f20
commit 4aacc87425
3 files changed
+24 -3

No files matched your search

@@ -143,6 +143,25 @@ class Opening(BinarySensor):
DEVICE_CLASS = DEVICE_CLASS_OPENING
@STRICT_MATCH(
channel_names=CHANNEL_ON_OFF,
manufacturers="IKEA of Sweden",
models=lambda model: isinstance(model, str)
and model is not None
and model.find("motion") != -1,
)
@STRICT_MATCH(
channel_names=CHANNEL_ON_OFF,
manufacturers="Philips",
models={"SML001", "SML002"},
)
class Motion(BinarySensor):
"""ZHA BinarySensor."""
SENSOR_ATTR = "on_off"
DEVICE_CLASS = DEVICE_CLASS_MOTION
@STRICT_MATCH(channel_names=CHANNEL_ZONE)
class IASZone(BinarySensor):
"""ZHA IAS BinarySensor."""
@@ -180,10 +180,12 @@ class MatchRule:
"""
weight = 0
if self.models:
weight += 401 - len(self.models)
weight += 401 - (1 if callable(self.models) else len(self.models))
if self.manufacturers:
weight += 301 - len(self.manufacturers)
weight += 301 - (
1 if callable(self.manufacturers) else len(self.manufacturers)
)
weight += 10 * len(self.channel_names)
weight += 5 * len(self.generic_ids)
+1 -1
View File
@@ -784,7 +784,7 @@ DEVICES = [
},
("binary_sensor", "00:11:22:33:44:55:66:77-1-6"): {
"channels": ["on_off"],
"entity_class": "Opening",
"entity_class": "Motion",
"entity_id": "binary_sensor.ikea_of_sweden_tradfri_motion_sensor_77665544_on_off",
},
},