mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 15:17:35 +00:00
Use CoverDeviceClass in ESPHome (#83395)
This commit is contained in:
parent
985c1b31e1
commit
04793978d3
@ -1,6 +1,7 @@
|
|||||||
"""Support for ESPHome covers."""
|
"""Support for ESPHome covers."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from contextlib import suppress
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aioesphomeapi import CoverInfo, CoverOperation, CoverState
|
from aioesphomeapi import CoverInfo, CoverOperation, CoverState
|
||||||
@ -8,7 +9,7 @@ from aioesphomeapi import CoverInfo, CoverOperation, CoverState
|
|||||||
from homeassistant.components.cover import (
|
from homeassistant.components.cover import (
|
||||||
ATTR_POSITION,
|
ATTR_POSITION,
|
||||||
ATTR_TILT_POSITION,
|
ATTR_TILT_POSITION,
|
||||||
DEVICE_CLASSES,
|
CoverDeviceClass,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
CoverEntityFeature,
|
CoverEntityFeature,
|
||||||
)
|
)
|
||||||
@ -54,11 +55,11 @@ class EsphomeCover(EsphomeEntity[CoverInfo, CoverState], CoverEntity):
|
|||||||
return flags
|
return flags
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def device_class(self) -> str | None:
|
def device_class(self) -> CoverDeviceClass | None:
|
||||||
"""Return the class of this device, from component DEVICE_CLASSES."""
|
"""Return the class of this device, from component DEVICE_CLASSES."""
|
||||||
if self._static_info.device_class not in DEVICE_CLASSES:
|
with suppress(ValueError):
|
||||||
return None
|
return CoverDeviceClass(self._static_info.device_class)
|
||||||
return self._static_info.device_class
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def assumed_state(self) -> bool:
|
def assumed_state(self) -> bool:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user