mirror of
https://github.com/home-assistant/core.git
synced 2025-07-31 19:25:12 +02:00
Ensure Abode provides valid device classes (#82929)
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user