Skip to content

Commit 205a2ee

Browse files
authored
Ensure Abode provides valid device classes (#82929)
1 parent 368694d commit 205a2ee

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

homeassistant/components/abode/binary_sensor.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
"""Support for Abode Security System binary sensors."""
2+
from __future__ import annotations
3+
4+
from contextlib import suppress
25
from typing import cast
36

47
from abodepy.devices.binary_sensor import AbodeBinarySensor as ABBinarySensor
@@ -47,8 +50,10 @@ def is_on(self) -> bool:
4750
return cast(bool, self._device.is_on)
4851

4952
@property
50-
def device_class(self) -> str:
53+
def device_class(self) -> BinarySensorDeviceClass | None:
5154
"""Return the class of the binary sensor."""
5255
if self._device.get_value("is_window") == "1":
5356
return BinarySensorDeviceClass.WINDOW
54-
return cast(str, self._device.generic_type)
57+
with suppress(ValueError):
58+
return BinarySensorDeviceClass(cast(str, self._device.generic_type))
59+
return None

0 commit comments

Comments
 (0)