File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
homeassistant/components/abode Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change 1
1
"""Support for Abode Security System binary sensors."""
2
+ from __future__ import annotations
3
+
4
+ from contextlib import suppress
2
5
from typing import cast
3
6
4
7
from abodepy .devices .binary_sensor import AbodeBinarySensor as ABBinarySensor
@@ -47,8 +50,10 @@ def is_on(self) -> bool:
47
50
return cast (bool , self ._device .is_on )
48
51
49
52
@property
50
- def device_class (self ) -> str :
53
+ def device_class (self ) -> BinarySensorDeviceClass | None :
51
54
"""Return the class of the binary sensor."""
52
55
if self ._device .get_value ("is_window" ) == "1" :
53
56
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
You can’t perform that action at this time.
0 commit comments