mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
HomematicIP add cover FROLL and BROLL devices (#19794)
* Add cover FROLL and BROLL devices * Fix import * Fix async calls * Update cover functions and async fixes * Update test * Cleanup code * Update header * Merge imports * Update * Remove init * Update coveragerc file * Update coveragerc
This commit is contained in:
parent
a8ef7a2774
commit
89ba374d51
@ -169,7 +169,8 @@ omit =
|
||||
homeassistant/components/homematic/__init__.py
|
||||
homeassistant/components/*/homematic.py
|
||||
|
||||
homeassistant/components/homematicip_cloud.py
|
||||
homeassistant/components/homematicip_cloud/hap.py
|
||||
homeassistant/components/homematicip_cloud/device.py
|
||||
homeassistant/components/*/homematicip_cloud.py
|
||||
|
||||
homeassistant/components/homeworks.py
|
||||
|
70
homeassistant/components/cover/homematicip_cloud.py
Normal file
70
homeassistant/components/cover/homematicip_cloud.py
Normal file
@ -0,0 +1,70 @@
|
||||
"""
|
||||
Support for HomematicIP Cloud cover devices.
|
||||
|
||||
For more details about this platform, please refer to the documentation at
|
||||
https://home-assistant.io/components/cover.homematicip_cloud/
|
||||
"""
|
||||
import logging
|
||||
|
||||
from homeassistant.components.cover import (
|
||||
ATTR_POSITION, CoverDevice)
|
||||
from homeassistant.components.homematicip_cloud import (
|
||||
HMIPC_HAPID, HomematicipGenericDevice, DOMAIN as HMIPC_DOMAIN)
|
||||
|
||||
DEPENDENCIES = ['homematicip_cloud']
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def async_setup_platform(
|
||||
hass, config, async_add_entities, discovery_info=None):
|
||||
"""Set up the HomematicIP Cloud cover devices."""
|
||||
pass
|
||||
|
||||
|
||||
async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
"""Set up the HomematicIP cover from a config entry."""
|
||||
from homematicip.aio.device import AsyncFullFlushShutter
|
||||
|
||||
home = hass.data[HMIPC_DOMAIN][config_entry.data[HMIPC_HAPID]].home
|
||||
devices = []
|
||||
for device in home.devices:
|
||||
if isinstance(device, AsyncFullFlushShutter):
|
||||
devices.append(HomematicipCoverShutter(home, device))
|
||||
|
||||
if devices:
|
||||
async_add_entities(devices)
|
||||
|
||||
|
||||
class HomematicipCoverShutter(HomematicipGenericDevice, CoverDevice):
|
||||
"""Representation of a HomematicIP Cloud cover device."""
|
||||
|
||||
@property
|
||||
def current_cover_position(self):
|
||||
"""Return current position of cover."""
|
||||
return int(self._device.shutterLevel * 100)
|
||||
|
||||
async def async_set_cover_position(self, **kwargs):
|
||||
"""Move the cover to a specific position."""
|
||||
position = kwargs[ATTR_POSITION]
|
||||
level = position / 100.0
|
||||
await self._device.set_shutter_level(level)
|
||||
|
||||
@property
|
||||
def is_closed(self):
|
||||
"""Return if the cover is closed."""
|
||||
if self._device.shutterLevel is not None:
|
||||
return self._device.shutterLevel == 0
|
||||
return None
|
||||
|
||||
async def async_open_cover(self, **kwargs):
|
||||
"""Open the cover."""
|
||||
await self._device.set_shutter_level(1)
|
||||
|
||||
async def async_close_cover(self, **kwargs):
|
||||
"""Close the cover."""
|
||||
await self._device.set_shutter_level(0)
|
||||
|
||||
async def async_stop_cover(self, **kwargs):
|
||||
"""Stop the device if in motion."""
|
||||
await self._device.set_shutter_stop()
|
@ -9,6 +9,7 @@ COMPONENTS = [
|
||||
'alarm_control_panel',
|
||||
'binary_sensor',
|
||||
'climate',
|
||||
'cover',
|
||||
'light',
|
||||
'sensor',
|
||||
'switch',
|
||||
|
@ -65,7 +65,7 @@ async def test_hap_setup_works(aioclient_mock):
|
||||
assert await hap.async_setup() is True
|
||||
|
||||
assert hap.home is home
|
||||
assert len(hass.config_entries.async_forward_entry_setup.mock_calls) == 6
|
||||
assert len(hass.config_entries.async_forward_entry_setup.mock_calls) == 7
|
||||
assert hass.config_entries.async_forward_entry_setup.mock_calls[0][1] == \
|
||||
(entry, 'alarm_control_panel')
|
||||
assert hass.config_entries.async_forward_entry_setup.mock_calls[1][1] == \
|
||||
@ -107,10 +107,10 @@ async def test_hap_reset_unloads_entry_if_setup():
|
||||
|
||||
assert hap.home is home
|
||||
assert len(hass.services.async_register.mock_calls) == 0
|
||||
assert len(hass.config_entries.async_forward_entry_setup.mock_calls) == 6
|
||||
assert len(hass.config_entries.async_forward_entry_setup.mock_calls) == 7
|
||||
|
||||
hass.config_entries.async_forward_entry_unload.return_value = \
|
||||
mock_coro(True)
|
||||
await hap.async_reset()
|
||||
|
||||
assert len(hass.config_entries.async_forward_entry_unload.mock_calls) == 6
|
||||
assert len(hass.config_entries.async_forward_entry_unload.mock_calls) == 7
|
||||
|
Loading…
x
Reference in New Issue
Block a user