diff --git a/homeassistant/components/abode/binary_sensor.py b/homeassistant/components/abode/binary_sensor.py index 4f7af8af640..08ed1925936 100644 --- a/homeassistant/components/abode/binary_sensor.py +++ b/homeassistant/components/abode/binary_sensor.py @@ -1,4 +1,7 @@ """Support for Abode Security System binary sensors.""" +from __future__ import annotations + +from contextlib import suppress from typing import cast from abodepy.devices.binary_sensor import AbodeBinarySensor as ABBinarySensor @@ -47,8 +50,10 @@ class AbodeBinarySensor(AbodeDevice, BinarySensorEntity): return cast(bool, self._device.is_on) @property - def device_class(self) -> str: + def device_class(self) -> BinarySensorDeviceClass | None: """Return the class of the binary sensor.""" if self._device.get_value("is_window") == "1": return BinarySensorDeviceClass.WINDOW - return cast(str, self._device.generic_type) + with suppress(ValueError): + return BinarySensorDeviceClass(cast(str, self._device.generic_type)) + return None