Skip to content

Commit 6a15eb4

Browse files
frenckmarcelveldt
authored andcommitted
Simplify use of binary sensor device classes in MySensors (#82946)
1 parent 0c17776 commit 6a15eb4

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

homeassistant/components/mysensors/binary_sensor.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from __future__ import annotations
33

44
from homeassistant.components.binary_sensor import (
5-
DEVICE_CLASSES,
65
BinarySensorDeviceClass,
76
BinarySensorEntity,
87
)
@@ -17,9 +16,9 @@
1716
from .helpers import on_unload
1817

1918
SENSORS = {
20-
"S_DOOR": "door",
19+
"S_DOOR": BinarySensorDeviceClass.DOOR,
2120
"S_MOTION": BinarySensorDeviceClass.MOTION,
22-
"S_SMOKE": "smoke",
21+
"S_SMOKE": BinarySensorDeviceClass.SMOKE,
2322
"S_SPRINKLER": BinarySensorDeviceClass.SAFETY,
2423
"S_WATER_LEAK": BinarySensorDeviceClass.SAFETY,
2524
"S_SOUND": BinarySensorDeviceClass.SOUND,
@@ -66,10 +65,7 @@ def is_on(self) -> bool:
6665
return self._values.get(self.value_type) == STATE_ON
6766

6867
@property
69-
def device_class(self) -> str | None:
68+
def device_class(self) -> BinarySensorDeviceClass | None:
7069
"""Return the class of this sensor, from DEVICE_CLASSES."""
7170
pres = self.gateway.const.Presentation
72-
device_class = SENSORS.get(pres(self.child_type).name)
73-
if device_class in DEVICE_CLASSES:
74-
return device_class
75-
return None
71+
return SENSORS.get(pres(self.child_type).name)

0 commit comments

Comments
 (0)