mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 17:57:11 +00:00
Ensure Abode provides valid device classes (#82929)
This commit is contained in:
parent
368694d6bf
commit
205a2ee215
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user