mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Support fibaro garage door devices (#72299)
* Add proper support for garage door controller in fibaro cover entity * Add proper support for garage door controller in fibaro cover entity
This commit is contained in:
parent
6368df5e37
commit
1113d9bea9
@ -6,6 +6,7 @@ from homeassistant.components.cover import (
|
|||||||
ATTR_TILT_POSITION,
|
ATTR_TILT_POSITION,
|
||||||
ENTITY_ID_FORMAT,
|
ENTITY_ID_FORMAT,
|
||||||
CoverEntity,
|
CoverEntity,
|
||||||
|
CoverEntityFeature,
|
||||||
)
|
)
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import Platform
|
from homeassistant.const import Platform
|
||||||
@ -41,6 +42,11 @@ class FibaroCover(FibaroDevice, CoverEntity):
|
|||||||
super().__init__(fibaro_device)
|
super().__init__(fibaro_device)
|
||||||
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
self.entity_id = ENTITY_ID_FORMAT.format(self.ha_id)
|
||||||
|
|
||||||
|
if self._is_open_close_only():
|
||||||
|
self._attr_supported_features = (
|
||||||
|
CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE
|
||||||
|
)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def bound(position):
|
def bound(position):
|
||||||
"""Normalize the position."""
|
"""Normalize the position."""
|
||||||
@ -53,6 +59,14 @@ class FibaroCover(FibaroDevice, CoverEntity):
|
|||||||
return 100
|
return 100
|
||||||
return position
|
return position
|
||||||
|
|
||||||
|
def _is_open_close_only(self) -> bool:
|
||||||
|
"""Return if only open / close is supported."""
|
||||||
|
# Normally positionable devices report the position over value,
|
||||||
|
# so if it is missing we have a device which supports open / close only
|
||||||
|
if "value" not in self.fibaro_device.properties:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_cover_position(self):
|
def current_cover_position(self):
|
||||||
"""Return current position of cover. 0 is closed, 100 is open."""
|
"""Return current position of cover. 0 is closed, 100 is open."""
|
||||||
@ -74,6 +88,9 @@ class FibaroCover(FibaroDevice, CoverEntity):
|
|||||||
@property
|
@property
|
||||||
def is_closed(self):
|
def is_closed(self):
|
||||||
"""Return if the cover is closed."""
|
"""Return if the cover is closed."""
|
||||||
|
if self._is_open_close_only():
|
||||||
|
return self.fibaro_device.properties.state.lower() == "closed"
|
||||||
|
|
||||||
if self.current_cover_position is None:
|
if self.current_cover_position is None:
|
||||||
return None
|
return None
|
||||||
return self.current_cover_position == 0
|
return self.current_cover_position == 0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user