mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Homematic ip tilt covers (#11650)
* add pyhomematic support for ip and tiltable covers * use cached data in current_cover_tilt_position * check for existance not for None * reformatting * check node for LEVEL_2
This commit is contained in:
parent
b10fd172fd
commit
c48ef281ab
@ -5,9 +5,11 @@ For more details about this platform, please refer to the documentation at
|
|||||||
https://home-assistant.io/components/cover.homematic/
|
https://home-assistant.io/components/cover.homematic/
|
||||||
"""
|
"""
|
||||||
import logging
|
import logging
|
||||||
from homeassistant.const import STATE_UNKNOWN
|
|
||||||
from homeassistant.components.cover import CoverDevice, ATTR_POSITION
|
from homeassistant.components.cover import CoverDevice, ATTR_POSITION,\
|
||||||
|
ATTR_TILT_POSITION
|
||||||
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
|
from homeassistant.components.homematic import HMDevice, ATTR_DISCOVER_DEVICES
|
||||||
|
from homeassistant.const import STATE_UNKNOWN
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -69,3 +71,40 @@ class HMCover(HMDevice, CoverDevice):
|
|||||||
"""Generate a data dictoinary (self._data) from metadata."""
|
"""Generate a data dictoinary (self._data) from metadata."""
|
||||||
self._state = "LEVEL"
|
self._state = "LEVEL"
|
||||||
self._data.update({self._state: STATE_UNKNOWN})
|
self._data.update({self._state: STATE_UNKNOWN})
|
||||||
|
if "LEVEL_2" in self._hmdevice.WRITENODE:
|
||||||
|
self._data.update(
|
||||||
|
{'LEVEL_2': STATE_UNKNOWN})
|
||||||
|
|
||||||
|
@property
|
||||||
|
def current_cover_tilt_position(self):
|
||||||
|
"""Return current position of cover tilt.
|
||||||
|
|
||||||
|
None is unknown, 0 is closed, 100 is fully open.
|
||||||
|
"""
|
||||||
|
if 'LEVEL_2' not in self._data:
|
||||||
|
return None
|
||||||
|
|
||||||
|
return int(self._data.get('LEVEL_2', 0) * 100)
|
||||||
|
|
||||||
|
def set_cover_tilt_position(self, **kwargs):
|
||||||
|
"""Move the cover tilt to a specific position."""
|
||||||
|
if "LEVEL_2" in self._data and ATTR_TILT_POSITION in kwargs:
|
||||||
|
position = float(kwargs[ATTR_TILT_POSITION])
|
||||||
|
position = min(100, max(0, position))
|
||||||
|
level = position / 100.0
|
||||||
|
self._hmdevice.set_cover_tilt_position(level, self._channel)
|
||||||
|
|
||||||
|
def open_cover_tilt(self, **kwargs):
|
||||||
|
"""Open the cover tilt."""
|
||||||
|
if "LEVEL_2" in self._data:
|
||||||
|
self._hmdevice.open_slats()
|
||||||
|
|
||||||
|
def close_cover_tilt(self, **kwargs):
|
||||||
|
"""Close the cover tilt."""
|
||||||
|
if "LEVEL_2" in self._data:
|
||||||
|
self._hmdevice.close_slats()
|
||||||
|
|
||||||
|
def stop_cover_tilt(self, **kwargs):
|
||||||
|
"""Stop cover tilt."""
|
||||||
|
if "LEVEL_2" in self._data:
|
||||||
|
self.stop_cover(**kwargs)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user