Adjust CoverEntity function type hints in components (#73912)

Adjust CoverEntity functions in components
This commit is contained in:
epenet 2022-06-24 06:40:26 +02:00 committed by GitHub
parent 307666da7f
commit a92ab7a669
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 254 additions and 202 deletions

View File

@ -1,6 +1,8 @@
"""Support for Acmeda Roller Blinds.""" """Support for Acmeda Roller Blinds."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
CoverEntity, CoverEntity,
@ -92,31 +94,31 @@ class AcmedaCover(AcmedaBase, CoverEntity):
"""Return if the cover is closed.""" """Return if the cover is closed."""
return self.roller.closed_percent == 100 return self.roller.closed_percent == 100
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the roller.""" """Close the roller."""
await self.roller.move_down() await self.roller.move_down()
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the roller.""" """Open the roller."""
await self.roller.move_up() await self.roller.move_up()
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the roller.""" """Stop the roller."""
await self.roller.move_stop() await self.roller.move_stop()
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the roller shutter to a specific position.""" """Move the roller shutter to a specific position."""
await self.roller.move_to(100 - kwargs[ATTR_POSITION]) await self.roller.move_to(100 - kwargs[ATTR_POSITION])
async def async_close_cover_tilt(self, **kwargs): async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the roller.""" """Close the roller."""
await self.roller.move_down() await self.roller.move_down()
async def async_open_cover_tilt(self, **kwargs): async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the roller.""" """Open the roller."""
await self.roller.move_up() await self.roller.move_up()
async def async_stop_cover_tilt(self, **kwargs): async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the roller.""" """Stop the roller."""
await self.roller.move_stop() await self.roller.move_stop()

View File

@ -1,6 +1,8 @@
"""Support for ADS covers.""" """Support for ADS covers."""
from __future__ import annotations from __future__ import annotations
from typing import Any
import pyads import pyads
import voluptuous as vol import voluptuous as vol
@ -122,7 +124,7 @@ class AdsCover(AdsEntity, CoverEntity):
if ads_var_pos_set is not None: if ads_var_pos_set is not None:
self._attr_supported_features |= CoverEntityFeature.SET_POSITION self._attr_supported_features |= CoverEntityFeature.SET_POSITION
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Register device notification.""" """Register device notification."""
if self._ads_var is not None: if self._ads_var is not None:
await self.async_initialize_device(self._ads_var, pyads.PLCTYPE_BOOL) await self.async_initialize_device(self._ads_var, pyads.PLCTYPE_BOOL)
@ -146,12 +148,12 @@ class AdsCover(AdsEntity, CoverEntity):
"""Return current position of cover.""" """Return current position of cover."""
return self._state_dict[STATE_KEY_POSITION] return self._state_dict[STATE_KEY_POSITION]
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs: Any) -> None:
"""Fire the stop action.""" """Fire the stop action."""
if self._ads_var_stop: if self._ads_var_stop:
self._ads_hub.write_by_name(self._ads_var_stop, True, pyads.PLCTYPE_BOOL) self._ads_hub.write_by_name(self._ads_var_stop, True, pyads.PLCTYPE_BOOL)
def set_cover_position(self, **kwargs): def set_cover_position(self, **kwargs: Any) -> None:
"""Set cover position.""" """Set cover position."""
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]
if self._ads_var_pos_set is not None: if self._ads_var_pos_set is not None:
@ -159,14 +161,14 @@ class AdsCover(AdsEntity, CoverEntity):
self._ads_var_pos_set, position, pyads.PLCTYPE_BYTE self._ads_var_pos_set, position, pyads.PLCTYPE_BYTE
) )
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Move the cover up.""" """Move the cover up."""
if self._ads_var_open is not None: if self._ads_var_open is not None:
self._ads_hub.write_by_name(self._ads_var_open, True, pyads.PLCTYPE_BOOL) self._ads_hub.write_by_name(self._ads_var_open, True, pyads.PLCTYPE_BOOL)
elif self._ads_var_pos_set is not None: elif self._ads_var_pos_set is not None:
self.set_cover_position(position=100) self.set_cover_position(position=100)
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Move the cover down.""" """Move the cover down."""
if self._ads_var_close is not None: if self._ads_var_close is not None:
self._ads_hub.write_by_name(self._ads_var_close, True, pyads.PLCTYPE_BOOL) self._ads_hub.write_by_name(self._ads_var_close, True, pyads.PLCTYPE_BOOL)

View File

@ -1,4 +1,6 @@
"""Cover platform for Advantage Air integration.""" """Cover platform for Advantage Air integration."""
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
CoverDeviceClass, CoverDeviceClass,
@ -67,7 +69,7 @@ class AdvantageAirZoneVent(AdvantageAirEntity, CoverEntity):
return self._zone["value"] return self._zone["value"]
return 0 return 0
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Fully open zone vent.""" """Fully open zone vent."""
await self.async_change( await self.async_change(
{ {
@ -79,7 +81,7 @@ class AdvantageAirZoneVent(AdvantageAirEntity, CoverEntity):
} }
) )
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Fully close zone vent.""" """Fully close zone vent."""
await self.async_change( await self.async_change(
{ {
@ -89,7 +91,7 @@ class AdvantageAirZoneVent(AdvantageAirEntity, CoverEntity):
} }
) )
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Change vent position.""" """Change vent position."""
position = round(kwargs[ATTR_POSITION] / 5) * 5 position = round(kwargs[ATTR_POSITION] / 5) * 5
if position == 0: if position == 0:

View File

@ -1,4 +1,6 @@
"""BleBox cover entity.""" """BleBox cover entity."""
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
CoverEntity, CoverEntity,
@ -62,21 +64,21 @@ class BleBoxCoverEntity(BleBoxEntity, CoverEntity):
"""Return whether cover is closed.""" """Return whether cover is closed."""
return self._is_state(STATE_CLOSED) return self._is_state(STATE_CLOSED)
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover position.""" """Open the cover position."""
await self._feature.async_open() await self._feature.async_open()
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover position.""" """Close the cover position."""
await self._feature.async_close() await self._feature.async_close()
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Set the cover position.""" """Set the cover position."""
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]
await self._feature.async_set_position(100 - position) await self._feature.async_set_position(100 - position)
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
await self._feature.async_stop() await self._feature.async_stop()

View File

@ -1,4 +1,6 @@
"""Platform for cover integration.""" """Platform for cover integration."""
from typing import Any
from boschshcpy import SHCSession, SHCShutterControl from boschshcpy import SHCSession, SHCShutterControl
from homeassistant.components.cover import ( from homeassistant.components.cover import (
@ -54,7 +56,7 @@ class ShutterControlCover(SHCEntity, CoverEntity):
"""Return the current cover position.""" """Return the current cover position."""
return round(self._device.level * 100.0) return round(self._device.level * 100.0)
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
self._device.stop() self._device.stop()
@ -79,15 +81,15 @@ class ShutterControlCover(SHCEntity, CoverEntity):
== SHCShutterControl.ShutterControlService.State.CLOSING == SHCShutterControl.ShutterControlService.State.CLOSING
) )
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
self._device.level = 1.0 self._device.level = 1.0
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Close cover.""" """Close cover."""
self._device.level = 0.0 self._device.level = 0.0
def set_cover_position(self, **kwargs): def set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]
self._device.level = position / 100.0 self._device.level = position / 100.0

View File

@ -153,14 +153,14 @@ class CommandCover(CoverEntity):
payload = self._value_template.render_with_possible_json_value(payload) payload = self._value_template.render_with_possible_json_value(payload)
self._state = int(payload) self._state = int(payload)
def open_cover(self, **kwargs) -> None: def open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
self._move_cover(self._command_open) self._move_cover(self._command_open)
def close_cover(self, **kwargs) -> None: def close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
self._move_cover(self._command_close) self._move_cover(self._command_close)
def stop_cover(self, **kwargs) -> None: def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
self._move_cover(self._command_stop) self._move_cover(self._command_stop)

View File

@ -1,6 +1,8 @@
"""Demo platform for the cover component.""" """Demo platform for the cover component."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
ATTR_TILT_POSITION, ATTR_TILT_POSITION,
@ -159,7 +161,7 @@ class DemoCover(CoverEntity):
return self._supported_features return self._supported_features
return super().supported_features return super().supported_features
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
if self._position == 0: if self._position == 0:
return return
@ -173,7 +175,7 @@ class DemoCover(CoverEntity):
self._requested_closing = True self._requested_closing = True
self.async_write_ha_state() self.async_write_ha_state()
async def async_close_cover_tilt(self, **kwargs): async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the cover tilt.""" """Close the cover tilt."""
if self._tilt_position in (0, None): if self._tilt_position in (0, None):
return return
@ -181,7 +183,7 @@ class DemoCover(CoverEntity):
self._listen_cover_tilt() self._listen_cover_tilt()
self._requested_closing_tilt = True self._requested_closing_tilt = True
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
if self._position == 100: if self._position == 100:
return return
@ -195,7 +197,7 @@ class DemoCover(CoverEntity):
self._requested_closing = False self._requested_closing = False
self.async_write_ha_state() self.async_write_ha_state()
async def async_open_cover_tilt(self, **kwargs): async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the cover tilt.""" """Open the cover tilt."""
if self._tilt_position in (100, None): if self._tilt_position in (100, None):
return return
@ -223,7 +225,7 @@ class DemoCover(CoverEntity):
self._listen_cover_tilt() self._listen_cover_tilt()
self._requested_closing_tilt = tilt_position < self._tilt_position self._requested_closing_tilt = tilt_position < self._tilt_position
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
self._is_closing = False self._is_closing = False
self._is_opening = False self._is_opening = False
@ -234,7 +236,7 @@ class DemoCover(CoverEntity):
self._unsub_listener_cover = None self._unsub_listener_cover = None
self._set_position = None self._set_position = None
async def async_stop_cover_tilt(self, **kwargs): async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the cover tilt.""" """Stop the cover tilt."""
if self._tilt_position is None: if self._tilt_position is None:
return return

View File

@ -1,5 +1,7 @@
"""Support for the Dynalite channels as covers.""" """Support for the Dynalite channels as covers."""
from typing import Any
from homeassistant.components.cover import DEVICE_CLASSES, CoverDeviceClass, CoverEntity from homeassistant.components.cover import DEVICE_CLASSES, CoverDeviceClass, CoverEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback from homeassistant.core import HomeAssistant, callback
@ -60,19 +62,19 @@ class DynaliteCover(DynaliteBase, CoverEntity):
"""Return true if cover is closed.""" """Return true if cover is closed."""
return self._device.is_closed return self._device.is_closed
async def async_open_cover(self, **kwargs) -> None: async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
await self._device.async_open_cover(**kwargs) await self._device.async_open_cover(**kwargs)
async def async_close_cover(self, **kwargs) -> None: async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
await self._device.async_close_cover(**kwargs) await self._device.async_close_cover(**kwargs)
async def async_set_cover_position(self, **kwargs) -> None: async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Set the cover position.""" """Set the cover position."""
await self._device.async_set_cover_position(**kwargs) await self._device.async_set_cover_position(**kwargs)
async def async_stop_cover(self, **kwargs) -> None: async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
await self._device.async_stop_cover(**kwargs) await self._device.async_stop_cover(**kwargs)
@ -85,18 +87,18 @@ class DynaliteCoverWithTilt(DynaliteCover):
"""Return the current tilt position.""" """Return the current tilt position."""
return self._device.current_cover_tilt_position return self._device.current_cover_tilt_position
async def async_open_cover_tilt(self, **kwargs) -> None: async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Open cover tilt.""" """Open cover tilt."""
await self._device.async_open_cover_tilt(**kwargs) await self._device.async_open_cover_tilt(**kwargs)
async def async_close_cover_tilt(self, **kwargs) -> None: async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Close cover tilt.""" """Close cover tilt."""
await self._device.async_close_cover_tilt(**kwargs) await self._device.async_close_cover_tilt(**kwargs)
async def async_set_cover_tilt_position(self, **kwargs) -> None: async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Set the cover tilt position.""" """Set the cover tilt position."""
await self._device.async_set_cover_tilt_position(**kwargs) await self._device.async_set_cover_tilt_position(**kwargs)
async def async_stop_cover_tilt(self, **kwargs) -> None: async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the cover tilt.""" """Stop the cover tilt."""
await self._device.async_stop_cover_tilt(**kwargs) await self._device.async_stop_cover_tilt(**kwargs)

View File

@ -1,6 +1,8 @@
"""Support for Fibaro cover - curtains, rollershutters etc.""" """Support for Fibaro cover - curtains, rollershutters etc."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
ATTR_TILT_POSITION, ATTR_TILT_POSITION,
@ -79,11 +81,11 @@ class FibaroCover(FibaroDevice, CoverEntity):
"""Return the current tilt position for venetian blinds.""" """Return the current tilt position for venetian blinds."""
return self.bound(self.level2) return self.bound(self.level2)
def set_cover_position(self, **kwargs): def set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
self.set_level(kwargs.get(ATTR_POSITION)) self.set_level(kwargs.get(ATTR_POSITION))
def set_cover_tilt_position(self, **kwargs): def set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
self.set_level2(kwargs.get(ATTR_TILT_POSITION)) self.set_level2(kwargs.get(ATTR_TILT_POSITION))
@ -97,22 +99,22 @@ class FibaroCover(FibaroDevice, CoverEntity):
return None return None
return self.current_cover_position == 0 return self.current_cover_position == 0
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
self.action("open") self.action("open")
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
self.action("close") self.action("close")
def open_cover_tilt(self, **kwargs): def open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the cover tilt.""" """Open the cover tilt."""
self.set_level2(100) self.set_level2(100)
def close_cover_tilt(self, **kwargs): def close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
self.set_level2(0) self.set_level2(0)
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
self.action("stop") self.action("stop")

View File

@ -1,5 +1,6 @@
"""Support for Freedompro cover.""" """Support for Freedompro cover."""
import json import json
from typing import Any
from pyfreedompro import put_state from pyfreedompro import put_state
@ -96,11 +97,11 @@ class Device(CoordinatorEntity, CoverEntity):
await super().async_added_to_hass() await super().async_added_to_hass()
self._handle_coordinator_update() self._handle_coordinator_update()
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
await self.async_set_cover_position(position=100) await self.async_set_cover_position(position=100)
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
await self.async_set_cover_position(position=0) await self.async_set_cover_position(position=0)

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
import requests import requests
import voluptuous as vol import voluptuous as vol
@ -207,21 +208,21 @@ class GaradgetCover(CoverEntity):
"""Check the state of the service during an operation.""" """Check the state of the service during an operation."""
self.schedule_update_ha_state(True) self.schedule_update_ha_state(True)
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
if self._state not in ["close", "closing"]: if self._state not in ["close", "closing"]:
ret = self._put_command("setState", "close") ret = self._put_command("setState", "close")
self._start_watcher("close") self._start_watcher("close")
return ret.get("return_value") == 1 return ret.get("return_value") == 1
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
if self._state not in ["open", "opening"]: if self._state not in ["open", "opening"]:
ret = self._put_command("setState", "open") ret = self._put_command("setState", "open")
self._start_watcher("open") self._start_watcher("open")
return ret.get("return_value") == 1 return ret.get("return_value") == 1
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs: Any) -> None:
"""Stop the door where it is.""" """Stop the door where it is."""
if self._state not in ["stopped"]: if self._state not in ["stopped"]:
ret = self._put_command("setState", "stop") ret = self._put_command("setState", "stop")

View File

@ -1,6 +1,8 @@
"""Support for Gogogate2 garage Doors.""" """Support for Gogogate2 garage Doors."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from ismartgate.common import ( from ismartgate.common import (
AbstractDoor, AbstractDoor,
DoorStatus, DoorStatus,
@ -84,12 +86,12 @@ class DeviceCover(GoGoGate2Entity, CoverEntity):
"""Return if the cover is opening or not.""" """Return if the cover is opening or not."""
return self.door_status == TransitionDoorStatus.OPENING return self.door_status == TransitionDoorStatus.OPENING
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the door.""" """Open the door."""
await self._api.async_open_door(self._door_id) await self._api.async_open_door(self._door_id)
await self.coordinator.async_refresh() await self.coordinator.async_refresh()
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the door.""" """Close the door."""
await self._api.async_close_door(self._door_id) await self._api.async_close_door(self._door_id)
await self.coordinator.async_refresh() await self.coordinator.async_refresh()

View File

@ -1,6 +1,8 @@
"""Support for HomeMatic covers.""" """Support for HomeMatic covers."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
ATTR_TILT_POSITION, ATTR_TILT_POSITION,
@ -49,7 +51,7 @@ class HMCover(HMDevice, CoverEntity):
""" """
return int(self._hm_get_state() * 100) return int(self._hm_get_state() * 100)
def set_cover_position(self, **kwargs): def set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
if ATTR_POSITION in kwargs: if ATTR_POSITION in kwargs:
position = float(kwargs[ATTR_POSITION]) position = float(kwargs[ATTR_POSITION])
@ -64,15 +66,15 @@ class HMCover(HMDevice, CoverEntity):
return self.current_cover_position == 0 return self.current_cover_position == 0
return None return None
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
self._hmdevice.move_up(self._channel) self._hmdevice.move_up(self._channel)
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
self._hmdevice.move_down(self._channel) self._hmdevice.move_down(self._channel)
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs: Any) -> None:
"""Stop the device if in motion.""" """Stop the device if in motion."""
self._hmdevice.stop(self._channel) self._hmdevice.stop(self._channel)
@ -93,7 +95,7 @@ class HMCover(HMDevice, CoverEntity):
return None return None
return int(position * 100) return int(position * 100)
def set_cover_tilt_position(self, **kwargs): def set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover tilt to a specific position.""" """Move the cover tilt to a specific position."""
if "LEVEL_2" in self._data and ATTR_TILT_POSITION in kwargs: if "LEVEL_2" in self._data and ATTR_TILT_POSITION in kwargs:
position = float(kwargs[ATTR_TILT_POSITION]) position = float(kwargs[ATTR_TILT_POSITION])
@ -101,17 +103,17 @@ class HMCover(HMDevice, CoverEntity):
level = position / 100.0 level = position / 100.0
self._hmdevice.set_cover_tilt_position(level, self._channel) self._hmdevice.set_cover_tilt_position(level, self._channel)
def open_cover_tilt(self, **kwargs): def open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the cover tilt.""" """Open the cover tilt."""
if "LEVEL_2" in self._data: if "LEVEL_2" in self._data:
self._hmdevice.open_slats() self._hmdevice.open_slats()
def close_cover_tilt(self, **kwargs): def close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the cover tilt.""" """Close the cover tilt."""
if "LEVEL_2" in self._data: if "LEVEL_2" in self._data:
self._hmdevice.close_slats() self._hmdevice.close_slats()
def stop_cover_tilt(self, **kwargs): def stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop cover tilt.""" """Stop cover tilt."""
if "LEVEL_2" in self._data: if "LEVEL_2" in self._data:
self.stop_cover(**kwargs) self.stop_cover(**kwargs)

View File

@ -1,6 +1,8 @@
"""Support for HomematicIP Cloud cover devices.""" """Support for HomematicIP Cloud cover devices."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homematicip.aio.device import ( from homematicip.aio.device import (
AsyncBlindModule, AsyncBlindModule,
AsyncDinRailBlind4, AsyncDinRailBlind4,
@ -86,14 +88,14 @@ class HomematicipBlindModule(HomematicipGenericEntity, CoverEntity):
return int((1 - self._device.secondaryShadingLevel) * 100) return int((1 - self._device.secondaryShadingLevel) * 100)
return None return None
async def async_set_cover_position(self, **kwargs) -> None: async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]
# HmIP cover is closed:1 -> open:0 # HmIP cover is closed:1 -> open:0
level = 1 - position / 100.0 level = 1 - position / 100.0
await self._device.set_primary_shading_level(primaryShadingLevel=level) await self._device.set_primary_shading_level(primaryShadingLevel=level)
async def async_set_cover_tilt_position(self, **kwargs) -> None: async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific tilt position.""" """Move the cover to a specific tilt position."""
position = kwargs[ATTR_TILT_POSITION] position = kwargs[ATTR_TILT_POSITION]
# HmIP slats is closed:1 -> open:0 # HmIP slats is closed:1 -> open:0
@ -110,37 +112,37 @@ class HomematicipBlindModule(HomematicipGenericEntity, CoverEntity):
return self._device.primaryShadingLevel == HMIP_COVER_CLOSED return self._device.primaryShadingLevel == HMIP_COVER_CLOSED
return None return None
async def async_open_cover(self, **kwargs) -> None: async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
await self._device.set_primary_shading_level( await self._device.set_primary_shading_level(
primaryShadingLevel=HMIP_COVER_OPEN primaryShadingLevel=HMIP_COVER_OPEN
) )
async def async_close_cover(self, **kwargs) -> None: async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
await self._device.set_primary_shading_level( await self._device.set_primary_shading_level(
primaryShadingLevel=HMIP_COVER_CLOSED primaryShadingLevel=HMIP_COVER_CLOSED
) )
async def async_stop_cover(self, **kwargs) -> None: async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the device if in motion.""" """Stop the device if in motion."""
await self._device.stop() await self._device.stop()
async def async_open_cover_tilt(self, **kwargs) -> None: async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the slats.""" """Open the slats."""
await self._device.set_secondary_shading_level( await self._device.set_secondary_shading_level(
primaryShadingLevel=self._device.primaryShadingLevel, primaryShadingLevel=self._device.primaryShadingLevel,
secondaryShadingLevel=HMIP_SLATS_OPEN, secondaryShadingLevel=HMIP_SLATS_OPEN,
) )
async def async_close_cover_tilt(self, **kwargs) -> None: async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the slats.""" """Close the slats."""
await self._device.set_secondary_shading_level( await self._device.set_secondary_shading_level(
primaryShadingLevel=self._device.primaryShadingLevel, primaryShadingLevel=self._device.primaryShadingLevel,
secondaryShadingLevel=HMIP_SLATS_CLOSED, secondaryShadingLevel=HMIP_SLATS_CLOSED,
) )
async def async_stop_cover_tilt(self, **kwargs) -> None: async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the device if in motion.""" """Stop the device if in motion."""
await self._device.stop() await self._device.stop()
@ -174,7 +176,7 @@ class HomematicipMultiCoverShutter(HomematicipGenericEntity, CoverEntity):
) )
return None return None
async def async_set_cover_position(self, **kwargs) -> None: async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]
# HmIP cover is closed:1 -> open:0 # HmIP cover is closed:1 -> open:0
@ -191,15 +193,15 @@ class HomematicipMultiCoverShutter(HomematicipGenericEntity, CoverEntity):
) )
return None return None
async def async_open_cover(self, **kwargs) -> None: async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
await self._device.set_shutter_level(HMIP_COVER_OPEN, self._channel) await self._device.set_shutter_level(HMIP_COVER_OPEN, self._channel)
async def async_close_cover(self, **kwargs) -> None: async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
await self._device.set_shutter_level(HMIP_COVER_CLOSED, self._channel) await self._device.set_shutter_level(HMIP_COVER_CLOSED, self._channel)
async def async_stop_cover(self, **kwargs) -> None: async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the device if in motion.""" """Stop the device if in motion."""
await self._device.set_shutter_stop(self._channel) await self._device.set_shutter_stop(self._channel)
@ -236,26 +238,26 @@ class HomematicipMultiCoverSlats(HomematicipMultiCoverShutter, CoverEntity):
) )
return None return None
async def async_set_cover_tilt_position(self, **kwargs) -> None: async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific tilt position.""" """Move the cover to a specific tilt position."""
position = kwargs[ATTR_TILT_POSITION] position = kwargs[ATTR_TILT_POSITION]
# HmIP slats is closed:1 -> open:0 # HmIP slats is closed:1 -> open:0
level = 1 - position / 100.0 level = 1 - position / 100.0
await self._device.set_slats_level(slatsLevel=level, channelIndex=self._channel) await self._device.set_slats_level(slatsLevel=level, channelIndex=self._channel)
async def async_open_cover_tilt(self, **kwargs) -> None: async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the slats.""" """Open the slats."""
await self._device.set_slats_level( await self._device.set_slats_level(
slatsLevel=HMIP_SLATS_OPEN, channelIndex=self._channel slatsLevel=HMIP_SLATS_OPEN, channelIndex=self._channel
) )
async def async_close_cover_tilt(self, **kwargs) -> None: async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the slats.""" """Close the slats."""
await self._device.set_slats_level( await self._device.set_slats_level(
slatsLevel=HMIP_SLATS_CLOSED, channelIndex=self._channel slatsLevel=HMIP_SLATS_CLOSED, channelIndex=self._channel
) )
async def async_stop_cover_tilt(self, **kwargs) -> None: async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the device if in motion.""" """Stop the device if in motion."""
await self._device.set_shutter_stop(self._channel) await self._device.set_shutter_stop(self._channel)
@ -292,15 +294,15 @@ class HomematicipGarageDoorModule(HomematicipGenericEntity, CoverEntity):
"""Return if the cover is closed.""" """Return if the cover is closed."""
return self._device.doorState == DoorState.CLOSED return self._device.doorState == DoorState.CLOSED
async def async_open_cover(self, **kwargs) -> None: async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
await self._device.send_door_command(DoorCommand.OPEN) await self._device.send_door_command(DoorCommand.OPEN)
async def async_close_cover(self, **kwargs) -> None: async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
await self._device.send_door_command(DoorCommand.CLOSE) await self._device.send_door_command(DoorCommand.CLOSE)
async def async_stop_cover(self, **kwargs) -> None: async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
await self._device.send_door_command(DoorCommand.STOP) await self._device.send_door_command(DoorCommand.STOP)
@ -339,40 +341,40 @@ class HomematicipCoverShutterGroup(HomematicipGenericEntity, CoverEntity):
return self._device.shutterLevel == HMIP_COVER_CLOSED return self._device.shutterLevel == HMIP_COVER_CLOSED
return None return None
async def async_set_cover_position(self, **kwargs) -> None: async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]
# HmIP cover is closed:1 -> open:0 # HmIP cover is closed:1 -> open:0
level = 1 - position / 100.0 level = 1 - position / 100.0
await self._device.set_shutter_level(level) await self._device.set_shutter_level(level)
async def async_set_cover_tilt_position(self, **kwargs) -> None: async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific tilt position.""" """Move the cover to a specific tilt position."""
position = kwargs[ATTR_TILT_POSITION] position = kwargs[ATTR_TILT_POSITION]
# HmIP slats is closed:1 -> open:0 # HmIP slats is closed:1 -> open:0
level = 1 - position / 100.0 level = 1 - position / 100.0
await self._device.set_slats_level(level) await self._device.set_slats_level(level)
async def async_open_cover(self, **kwargs) -> None: async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
await self._device.set_shutter_level(HMIP_COVER_OPEN) await self._device.set_shutter_level(HMIP_COVER_OPEN)
async def async_close_cover(self, **kwargs) -> None: async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
await self._device.set_shutter_level(HMIP_COVER_CLOSED) await self._device.set_shutter_level(HMIP_COVER_CLOSED)
async def async_stop_cover(self, **kwargs) -> None: async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the group if in motion.""" """Stop the group if in motion."""
await self._device.set_shutter_stop() await self._device.set_shutter_stop()
async def async_open_cover_tilt(self, **kwargs) -> None: async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the slats.""" """Open the slats."""
await self._device.set_slats_level(HMIP_SLATS_OPEN) await self._device.set_slats_level(HMIP_SLATS_OPEN)
async def async_close_cover_tilt(self, **kwargs) -> None: async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the slats.""" """Close the slats."""
await self._device.set_slats_level(HMIP_SLATS_CLOSED) await self._device.set_slats_level(HMIP_SLATS_CLOSED)
async def async_stop_cover_tilt(self, **kwargs) -> None: async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the group if in motion.""" """Stop the group if in motion."""
await self._device.set_shutter_stop() await self._device.set_shutter_stop()

View File

@ -1,5 +1,6 @@
"""Support for Insteon covers via PowerLinc Modem.""" """Support for Insteon covers via PowerLinc Modem."""
import math import math
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
@ -59,15 +60,15 @@ class InsteonCoverEntity(InsteonEntity, CoverEntity):
"""Return the boolean response if the node is on.""" """Return the boolean response if the node is on."""
return bool(self.current_cover_position) return bool(self.current_cover_position)
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open cover.""" """Open cover."""
await self._insteon_device.async_open() await self._insteon_device.async_open()
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close cover.""" """Close cover."""
await self._insteon_device.async_close() await self._insteon_device.async_close()
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Set the cover position.""" """Set the cover position."""
position = int(kwargs[ATTR_POSITION] * 255 / 100) position = int(kwargs[ATTR_POSITION] * 255 / 100)
if position == 0: if position == 0:

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
@ -51,15 +52,15 @@ class LutronCover(LutronDevice, CoverEntity):
"""Return the current position of cover.""" """Return the current position of cover."""
return self._lutron_device.last_level() return self._lutron_device.last_level()
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
self._lutron_device.level = 0 self._lutron_device.level = 0
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
self._lutron_device.level = 100 self._lutron_device.level = 100
def set_cover_position(self, **kwargs): def set_cover_position(self, **kwargs: Any) -> None:
"""Move the shade to a specific position.""" """Move the shade to a specific position."""
if ATTR_POSITION in kwargs: if ATTR_POSITION in kwargs:
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]

View File

@ -1,5 +1,7 @@
"""Support for Lutron Caseta shades.""" """Support for Lutron Caseta shades."""
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
DOMAIN, DOMAIN,
@ -57,23 +59,23 @@ class LutronCasetaCover(LutronCasetaDeviceUpdatableEntity, CoverEntity):
"""Return the current position of cover.""" """Return the current position of cover."""
return self._device["current_state"] return self._device["current_state"]
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Top the cover.""" """Top the cover."""
await self._smartbridge.stop_cover(self.device_id) await self._smartbridge.stop_cover(self.device_id)
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
await self._smartbridge.lower_cover(self.device_id) await self._smartbridge.lower_cover(self.device_id)
self.async_update() self.async_update()
self.async_write_ha_state() self.async_write_ha_state()
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
await self._smartbridge.raise_cover(self.device_id) await self._smartbridge.raise_cover(self.device_id)
self.async_update() self.async_update()
self.async_write_ha_state() self.async_write_ha_state()
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the shade to a specific position.""" """Move the shade to a specific position."""
if ATTR_POSITION in kwargs: if ATTR_POSITION in kwargs:
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]

View File

@ -1,5 +1,6 @@
"""Support for Motion Blinds using their WLAN API.""" """Support for Motion Blinds using their WLAN API."""
import logging import logging
from typing import Any
from motionblinds import DEVICE_TYPES_WIFI, BlindType from motionblinds import DEVICE_TYPES_WIFI, BlindType
import voluptuous as vol import voluptuous as vol
@ -243,7 +244,7 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity):
return None return None
return self._blind.position == 100 return self._blind.position == 100
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Subscribe to multicast pushes and register signal handler.""" """Subscribe to multicast pushes and register signal handler."""
self._blind.Register_callback(self.unique_id, self.schedule_update_ha_state) self._blind.Register_callback(self.unique_id, self.schedule_update_ha_state)
await super().async_added_to_hass() await super().async_added_to_hass()
@ -288,19 +289,19 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity):
self.hass, UPDATE_INTERVAL_MOVING, self.async_scheduled_update_request self.hass, UPDATE_INTERVAL_MOVING, self.async_scheduled_update_request
) )
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
async with self._api_lock: async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Open) await self.hass.async_add_executor_job(self._blind.Open)
await self.async_request_position_till_stop() await self.async_request_position_till_stop()
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close cover.""" """Close cover."""
async with self._api_lock: async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Close) await self.hass.async_add_executor_job(self._blind.Close)
await self.async_request_position_till_stop() await self.async_request_position_till_stop()
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]
async with self._api_lock: async with self._api_lock:
@ -327,7 +328,7 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity):
) )
await self.async_request_position_till_stop() await self.async_request_position_till_stop()
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
async with self._api_lock: async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Stop) await self.hass.async_add_executor_job(self._blind.Stop)
@ -349,23 +350,23 @@ class MotionTiltDevice(MotionPositionDevice):
return None return None
return self._blind.angle * 100 / 180 return self._blind.angle * 100 / 180
async def async_open_cover_tilt(self, **kwargs): async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the cover tilt.""" """Open the cover tilt."""
async with self._api_lock: async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Set_angle, 180) await self.hass.async_add_executor_job(self._blind.Set_angle, 180)
async def async_close_cover_tilt(self, **kwargs): async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the cover tilt.""" """Close the cover tilt."""
async with self._api_lock: async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Set_angle, 0) await self.hass.async_add_executor_job(self._blind.Set_angle, 0)
async def async_set_cover_tilt_position(self, **kwargs): async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover tilt to a specific position.""" """Move the cover tilt to a specific position."""
angle = kwargs[ATTR_TILT_POSITION] * 180 / 100 angle = kwargs[ATTR_TILT_POSITION] * 180 / 100
async with self._api_lock: async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Set_angle, angle) await self.hass.async_add_executor_job(self._blind.Set_angle, angle)
async def async_stop_cover_tilt(self, **kwargs): async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
async with self._api_lock: async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Stop) await self.hass.async_add_executor_job(self._blind.Stop)
@ -463,19 +464,19 @@ class MotionTDBUDevice(MotionPositionDevice):
attributes[ATTR_WIDTH] = self._blind.width attributes[ATTR_WIDTH] = self._blind.width
return attributes return attributes
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
async with self._api_lock: async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Open, self._motor_key) await self.hass.async_add_executor_job(self._blind.Open, self._motor_key)
await self.async_request_position_till_stop() await self.async_request_position_till_stop()
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close cover.""" """Close cover."""
async with self._api_lock: async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Close, self._motor_key) await self.hass.async_add_executor_job(self._blind.Close, self._motor_key)
await self.async_request_position_till_stop() await self.async_request_position_till_stop()
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific scaled position.""" """Move the cover to a specific scaled position."""
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]
async with self._api_lock: async with self._api_lock:
@ -496,7 +497,7 @@ class MotionTDBUDevice(MotionPositionDevice):
await self.async_request_position_till_stop() await self.async_request_position_till_stop()
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
async with self._api_lock: async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Stop, self._motor_key) await self.hass.async_add_executor_job(self._blind.Stop, self._motor_key)

View File

@ -3,6 +3,7 @@ from __future__ import annotations
import functools import functools
import logging import logging
from typing import Any
import voluptuous as vol import voluptuous as vol
@ -545,7 +546,7 @@ class MqttCover(MqttEntity, CoverEntity):
return supported_features return supported_features
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Move the cover up. """Move the cover up.
This method is a coroutine. This method is a coroutine.
@ -566,7 +567,7 @@ class MqttCover(MqttEntity, CoverEntity):
) )
self.async_write_ha_state() self.async_write_ha_state()
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Move the cover down. """Move the cover down.
This method is a coroutine. This method is a coroutine.
@ -587,7 +588,7 @@ class MqttCover(MqttEntity, CoverEntity):
) )
self.async_write_ha_state() self.async_write_ha_state()
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the device. """Stop the device.
This method is a coroutine. This method is a coroutine.
@ -600,7 +601,7 @@ class MqttCover(MqttEntity, CoverEntity):
self._config[CONF_ENCODING], self._config[CONF_ENCODING],
) )
async def async_open_cover_tilt(self, **kwargs): async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Tilt the cover open.""" """Tilt the cover open."""
tilt_open_position = self._config[CONF_TILT_OPEN_POSITION] tilt_open_position = self._config[CONF_TILT_OPEN_POSITION]
variables = { variables = {
@ -625,7 +626,7 @@ class MqttCover(MqttEntity, CoverEntity):
) )
self.async_write_ha_state() self.async_write_ha_state()
async def async_close_cover_tilt(self, **kwargs): async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Tilt the cover closed.""" """Tilt the cover closed."""
tilt_closed_position = self._config[CONF_TILT_CLOSED_POSITION] tilt_closed_position = self._config[CONF_TILT_CLOSED_POSITION]
variables = { variables = {
@ -652,7 +653,7 @@ class MqttCover(MqttEntity, CoverEntity):
) )
self.async_write_ha_state() self.async_write_ha_state()
async def async_set_cover_tilt_position(self, **kwargs): async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover tilt to a specific position.""" """Move the cover tilt to a specific position."""
tilt = kwargs[ATTR_TILT_POSITION] tilt = kwargs[ATTR_TILT_POSITION]
percentage_tilt = tilt percentage_tilt = tilt
@ -680,7 +681,7 @@ class MqttCover(MqttEntity, CoverEntity):
self._tilt_value = percentage_tilt self._tilt_value = percentage_tilt
self.async_write_ha_state() self.async_write_ha_state()
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
position = kwargs[ATTR_POSITION] position = kwargs[ATTR_POSITION]
percentage_position = position percentage_position = position
@ -711,7 +712,7 @@ class MqttCover(MqttEntity, CoverEntity):
self._position = percentage_position self._position = percentage_position
self.async_write_ha_state() self.async_write_ha_state()
async def async_toggle_tilt(self, **kwargs): async def async_toggle_tilt(self, **kwargs: Any) -> None:
"""Toggle the entity.""" """Toggle the entity."""
if self.is_tilt_closed(): if self.is_tilt_closed():
await self.async_open_cover_tilt(**kwargs) await self.async_open_cover_tilt(**kwargs)

View File

@ -1,4 +1,6 @@
"""Support for MyQ-Enabled Garage Doors.""" """Support for MyQ-Enabled Garage Doors."""
from typing import Any
from pymyq.const import DEVICE_TYPE_GATE as MYQ_DEVICE_TYPE_GATE from pymyq.const import DEVICE_TYPE_GATE as MYQ_DEVICE_TYPE_GATE
from pymyq.errors import MyQError from pymyq.errors import MyQError
@ -67,7 +69,7 @@ class MyQCover(MyQEntity, CoverEntity):
"""Return if the cover is opening or not.""" """Return if the cover is opening or not."""
return MYQ_TO_HASS.get(self._device.state) == STATE_OPENING return MYQ_TO_HASS.get(self._device.state) == STATE_OPENING
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Issue close command to cover.""" """Issue close command to cover."""
if self.is_closing or self.is_closed: if self.is_closing or self.is_closed:
return return
@ -90,7 +92,7 @@ class MyQCover(MyQEntity, CoverEntity):
if not result: if not result:
raise HomeAssistantError(f"Closing of cover {self._device.name} failed") raise HomeAssistantError(f"Closing of cover {self._device.name} failed")
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Issue open command to cover.""" """Issue open command to cover."""
if self.is_opening or self.is_open: if self.is_opening or self.is_open:
return return

View File

@ -1,5 +1,6 @@
"""Platform for the opengarage.io cover component.""" """Platform for the opengarage.io cover component."""
import logging import logging
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
CoverDeviceClass, CoverDeviceClass,
@ -62,7 +63,7 @@ class OpenGarageCover(OpenGarageEntity, CoverEntity):
return None return None
return self._state == STATE_OPENING return self._state == STATE_OPENING
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
if self._state in [STATE_CLOSED, STATE_CLOSING]: if self._state in [STATE_CLOSED, STATE_CLOSING]:
return return
@ -70,7 +71,7 @@ class OpenGarageCover(OpenGarageEntity, CoverEntity):
self._state = STATE_CLOSING self._state = STATE_CLOSING
await self._push_button() await self._push_button()
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
if self._state in [STATE_OPEN, STATE_OPENING]: if self._state in [STATE_OPEN, STATE_OPENING]:
return return

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
import voluptuous as vol import voluptuous as vol
@ -155,15 +156,15 @@ class RflinkCover(RflinkCommand, CoverEntity, RestoreEntity):
"""Return True because covers can be stopped midway.""" """Return True because covers can be stopped midway."""
return True return True
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Turn the device close.""" """Turn the device close."""
await self._async_handle_command("close_cover") await self._async_handle_command("close_cover")
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Turn the device open.""" """Turn the device open."""
await self._async_handle_command("open_cover") await self._async_handle_command("open_cover")
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Turn the device stop.""" """Turn the device stop."""
await self._async_handle_command("stop_cover") await self._async_handle_command("stop_cover")

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from scsgate.tasks import ( from scsgate.tasks import (
HaltRollerShutterTask, HaltRollerShutterTask,
@ -85,15 +86,15 @@ class SCSGateCover(CoverEntity):
"""Return if the cover is closed.""" """Return if the cover is closed."""
return None return None
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Move the cover.""" """Move the cover."""
self._scsgate.append_task(RaiseRollerShutterTask(target=self._scs_id)) self._scsgate.append_task(RaiseRollerShutterTask(target=self._scs_id))
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Move the cover down.""" """Move the cover down."""
self._scsgate.append_task(LowerRollerShutterTask(target=self._scs_id)) self._scsgate.append_task(LowerRollerShutterTask(target=self._scs_id))
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
self._scsgate.append_task(HaltRollerShutterTask(target=self._scs_id)) self._scsgate.append_task(HaltRollerShutterTask(target=self._scs_id))

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
from homeassistant.components.cover import ATTR_POSITION, CoverDeviceClass, CoverEntity from homeassistant.components.cover import ATTR_POSITION, CoverDeviceClass, CoverEntity
from homeassistant.const import ATTR_ID, STATE_CLOSED, STATE_CLOSING, STATE_OPENING from homeassistant.const import ATTR_ID, STATE_CLOSED, STATE_CLOSING, STATE_OPENING
@ -83,21 +84,21 @@ class SlideCover(CoverEntity):
pos = int(pos * 100) pos = int(pos * 100)
return pos return pos
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
self._slide["state"] = STATE_OPENING self._slide["state"] = STATE_OPENING
await self._api.slide_open(self._id) await self._api.slide_open(self._id)
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
self._slide["state"] = STATE_CLOSING self._slide["state"] = STATE_CLOSING
await self._api.slide_close(self._id) await self._api.slide_close(self._id)
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
await self._api.slide_stop(self._id) await self._api.slide_stop(self._id)
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
position = kwargs[ATTR_POSITION] / 100 position = kwargs[ATTR_POSITION] / 100
if not self._invert: if not self._invert:

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Sequence from collections.abc import Sequence
from typing import Any
from pysmartthings import Attribute, Capability from pysmartthings import Attribute, Capability
@ -81,7 +82,7 @@ class SmartThingsCover(SmartThingsEntity, CoverEntity):
if Capability.switch_level in device.capabilities: if Capability.switch_level in device.capabilities:
self._attr_supported_features |= CoverEntityFeature.SET_POSITION self._attr_supported_features |= CoverEntityFeature.SET_POSITION
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close cover.""" """Close cover."""
# Same command for all 3 supported capabilities # Same command for all 3 supported capabilities
await self._device.close(set_status=True) await self._device.close(set_status=True)
@ -89,7 +90,7 @@ class SmartThingsCover(SmartThingsEntity, CoverEntity):
# the entity state ahead of receiving the confirming push updates # the entity state ahead of receiving the confirming push updates
self.async_schedule_update_ha_state(True) self.async_schedule_update_ha_state(True)
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
# Same for all capability types # Same for all capability types
await self._device.open(set_status=True) await self._device.open(set_status=True)

View File

@ -1,6 +1,8 @@
"""Support for Soma Covers.""" """Support for Soma Covers."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homeassistant.components.cover import ( from homeassistant.components.cover import (
ATTR_POSITION, ATTR_POSITION,
ATTR_TILT_POSITION, ATTR_TILT_POSITION,
@ -59,7 +61,7 @@ class SomaTilt(SomaEntity, CoverEntity):
"""Return if the cover tilt is closed.""" """Return if the cover tilt is closed."""
return self.current_position == 0 return self.current_position == 0
def close_cover_tilt(self, **kwargs): def close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the cover tilt.""" """Close the cover tilt."""
response = self.api.set_shade_position(self.device["mac"], 100) response = self.api.set_shade_position(self.device["mac"], 100)
if not is_api_response_success(response): if not is_api_response_success(response):
@ -68,7 +70,7 @@ class SomaTilt(SomaEntity, CoverEntity):
) )
self.set_position(0) self.set_position(0)
def open_cover_tilt(self, **kwargs): def open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the cover tilt.""" """Open the cover tilt."""
response = self.api.set_shade_position(self.device["mac"], -100) response = self.api.set_shade_position(self.device["mac"], -100)
if not is_api_response_success(response): if not is_api_response_success(response):
@ -77,7 +79,7 @@ class SomaTilt(SomaEntity, CoverEntity):
) )
self.set_position(100) self.set_position(100)
def stop_cover_tilt(self, **kwargs): def stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the cover tilt.""" """Stop the cover tilt."""
response = self.api.stop_shade(self.device["mac"]) response = self.api.stop_shade(self.device["mac"])
if not is_api_response_success(response): if not is_api_response_success(response):
@ -87,7 +89,7 @@ class SomaTilt(SomaEntity, CoverEntity):
# Set cover position to some value where up/down are both enabled # Set cover position to some value where up/down are both enabled
self.set_position(50) self.set_position(50)
def set_cover_tilt_position(self, **kwargs): def set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover tilt to a specific position.""" """Move the cover tilt to a specific position."""
# 0 -> Closed down (api: 100) # 0 -> Closed down (api: 100)
# 50 -> Fully open (api: 0) # 50 -> Fully open (api: 0)
@ -133,7 +135,7 @@ class SomaShade(SomaEntity, CoverEntity):
"""Return if the cover is closed.""" """Return if the cover is closed."""
return self.current_position == 0 return self.current_position == 0
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
response = self.api.set_shade_position(self.device["mac"], 100) response = self.api.set_shade_position(self.device["mac"], 100)
if not is_api_response_success(response): if not is_api_response_success(response):
@ -141,7 +143,7 @@ class SomaShade(SomaEntity, CoverEntity):
f'Error while closing the cover ({self.name}): {response["msg"]}' f'Error while closing the cover ({self.name}): {response["msg"]}'
) )
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
response = self.api.set_shade_position(self.device["mac"], 0) response = self.api.set_shade_position(self.device["mac"], 0)
if not is_api_response_success(response): if not is_api_response_success(response):
@ -149,7 +151,7 @@ class SomaShade(SomaEntity, CoverEntity):
f'Error while opening the cover ({self.name}): {response["msg"]}' f'Error while opening the cover ({self.name}): {response["msg"]}'
) )
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
response = self.api.stop_shade(self.device["mac"]) response = self.api.stop_shade(self.device["mac"])
if not is_api_response_success(response): if not is_api_response_success(response):
@ -159,7 +161,7 @@ class SomaShade(SomaEntity, CoverEntity):
# Set cover position to some value where up/down are both enabled # Set cover position to some value where up/down are both enabled
self.set_position(50) self.set_position(50)
def set_cover_position(self, **kwargs): def set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover shutter to a specific position.""" """Move the cover shutter to a specific position."""
self.current_position = kwargs[ATTR_POSITION] self.current_position = kwargs[ATTR_POSITION]
response = self.api.set_shade_position( response = self.api.set_shade_position(

View File

@ -1,5 +1,6 @@
"""Cover Platform for the Somfy MyLink component.""" """Cover Platform for the Somfy MyLink component."""
import logging import logging
from typing import Any
from homeassistant.components.cover import CoverDeviceClass, CoverEntity from homeassistant.components.cover import CoverDeviceClass, CoverEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -87,7 +88,7 @@ class SomfyShade(RestoreEntity, CoverEntity):
name=name, name=name,
) )
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
self._attr_is_closing = True self._attr_is_closing = True
self.async_write_ha_state() self.async_write_ha_state()
@ -102,7 +103,7 @@ class SomfyShade(RestoreEntity, CoverEntity):
self._attr_is_closing = None self._attr_is_closing = None
self.async_write_ha_state() self.async_write_ha_state()
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
self._attr_is_opening = True self._attr_is_opening = True
self.async_write_ha_state() self.async_write_ha_state()
@ -117,11 +118,11 @@ class SomfyShade(RestoreEntity, CoverEntity):
self._attr_is_opening = None self._attr_is_opening = None
self.async_write_ha_state() self.async_write_ha_state()
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
await self.somfy_mylink.move_stop(self._target_id) await self.somfy_mylink.move_stop(self._target_id)
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Complete the initialization.""" """Complete the initialization."""
await super().async_added_to_hass() await super().async_added_to_hass()
# Restore the last state # Restore the last state

View File

@ -3,6 +3,7 @@ from __future__ import annotations
import logging import logging
from pprint import pformat from pprint import pformat
from typing import Any
from homeassistant.components.cover import ATTR_POSITION, CoverDeviceClass, CoverEntity from homeassistant.components.cover import ATTR_POSITION, CoverDeviceClass, CoverEntity
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -65,7 +66,7 @@ class SuplaCover(SuplaChannel, CoverEntity):
return 100 - state["shut"] return 100 - state["shut"]
return None return None
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
await self.async_action("REVEAL", percentage=kwargs.get(ATTR_POSITION)) await self.async_action("REVEAL", percentage=kwargs.get(ATTR_POSITION))
@ -76,15 +77,15 @@ class SuplaCover(SuplaChannel, CoverEntity):
return None return None
return self.current_cover_position == 0 return self.current_cover_position == 0
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
await self.async_action("REVEAL") await self.async_action("REVEAL")
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
await self.async_action("SHUT") await self.async_action("SHUT")
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
await self.async_action("STOP") await self.async_action("STOP")
@ -100,21 +101,21 @@ class SuplaGateDoor(SuplaChannel, CoverEntity):
return state.get("hi") return state.get("hi")
return None return None
async def async_open_cover(self, **kwargs) -> None: async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the gate.""" """Open the gate."""
if self.is_closed: if self.is_closed:
await self.async_action("OPEN_CLOSE") await self.async_action("OPEN_CLOSE")
async def async_close_cover(self, **kwargs) -> None: async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the gate.""" """Close the gate."""
if not self.is_closed: if not self.is_closed:
await self.async_action("OPEN_CLOSE") await self.async_action("OPEN_CLOSE")
async def async_stop_cover(self, **kwargs) -> None: async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the gate.""" """Stop the gate."""
await self.async_action("OPEN_CLOSE") await self.async_action("OPEN_CLOSE")
async def async_toggle(self, **kwargs) -> None: async def async_toggle(self, **kwargs: Any) -> None:
"""Toggle the gate.""" """Toggle the gate."""
await self.async_action("OPEN_CLOSE") await self.async_action("OPEN_CLOSE")

View File

@ -1,4 +1,6 @@
"""Support for Tellstick covers using Tellstick Net.""" """Support for Tellstick covers using Tellstick Net."""
from typing import Any
from homeassistant.components import cover, tellduslive from homeassistant.components import cover, tellduslive
from homeassistant.components.cover import CoverEntity from homeassistant.components.cover import CoverEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
@ -36,17 +38,17 @@ class TelldusLiveCover(TelldusLiveEntity, CoverEntity):
"""Return the current position of the cover.""" """Return the current position of the cover."""
return self.device.is_down return self.device.is_down
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
self.device.down() self.device.down()
self._update_callback() self._update_callback()
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
self.device.up() self.device.up()
self._update_callback() self._update_callback()
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
self.device.stop() self.device.stop()
self._update_callback() self._update_callback()

View File

@ -1,6 +1,8 @@
"""Support for Tellstick covers.""" """Support for Tellstick covers."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from homeassistant.components.cover import CoverEntity from homeassistant.components.cover import CoverEntity
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
@ -51,15 +53,15 @@ class TellstickCover(TellstickDevice, CoverEntity):
"""Return True if unable to access real state of the entity.""" """Return True if unable to access real state of the entity."""
return True return True
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
self._tellcore_device.down() self._tellcore_device.down()
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
self._tellcore_device.up() self._tellcore_device.up()
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
self._tellcore_device.stop() self._tellcore_device.stop()

View File

@ -2,6 +2,7 @@
from __future__ import annotations from __future__ import annotations
import logging import logging
from typing import Any
import voluptuous as vol import voluptuous as vol
@ -180,7 +181,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
self._is_closing = False self._is_closing = False
self._tilt_value = None self._tilt_value = None
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Register callbacks.""" """Register callbacks."""
if self._template: if self._template:
self.add_template_attribute( self.add_template_attribute(
@ -322,7 +323,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
return supported_features return supported_features
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Move the cover up.""" """Move the cover up."""
if self._open_script: if self._open_script:
await self.async_run_script(self._open_script, context=self._context) await self.async_run_script(self._open_script, context=self._context)
@ -336,7 +337,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
self._position = 100 self._position = 100
self.async_write_ha_state() self.async_write_ha_state()
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Move the cover down.""" """Move the cover down."""
if self._close_script: if self._close_script:
await self.async_run_script(self._close_script, context=self._context) await self.async_run_script(self._close_script, context=self._context)
@ -350,12 +351,12 @@ class CoverTemplate(TemplateEntity, CoverEntity):
self._position = 0 self._position = 0
self.async_write_ha_state() self.async_write_ha_state()
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Fire the stop action.""" """Fire the stop action."""
if self._stop_script: if self._stop_script:
await self.async_run_script(self._stop_script, context=self._context) await self.async_run_script(self._stop_script, context=self._context)
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Set cover position.""" """Set cover position."""
self._position = kwargs[ATTR_POSITION] self._position = kwargs[ATTR_POSITION]
await self.async_run_script( await self.async_run_script(
@ -366,7 +367,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
if self._optimistic: if self._optimistic:
self.async_write_ha_state() self.async_write_ha_state()
async def async_open_cover_tilt(self, **kwargs): async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Tilt the cover open.""" """Tilt the cover open."""
self._tilt_value = 100 self._tilt_value = 100
await self.async_run_script( await self.async_run_script(
@ -377,7 +378,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
if self._tilt_optimistic: if self._tilt_optimistic:
self.async_write_ha_state() self.async_write_ha_state()
async def async_close_cover_tilt(self, **kwargs): async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Tilt the cover closed.""" """Tilt the cover closed."""
self._tilt_value = 0 self._tilt_value = 0
await self.async_run_script( await self.async_run_script(
@ -388,7 +389,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
if self._tilt_optimistic: if self._tilt_optimistic:
self.async_write_ha_state() self.async_write_ha_state()
async def async_set_cover_tilt_position(self, **kwargs): async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover tilt to a specific position.""" """Move the cover tilt to a specific position."""
self._tilt_value = kwargs[ATTR_TILT_POSITION] self._tilt_value = kwargs[ATTR_TILT_POSITION]
await self.async_run_script( await self.async_run_script(

View File

@ -360,7 +360,7 @@ class TuyaCoverEntity(TuyaEntity, CoverEntity):
] ]
) )
def set_cover_tilt_position(self, **kwargs): def set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move the cover tilt to a specific position.""" """Move the cover tilt to a specific position."""
if self._tilt is None: if self._tilt is None:
raise RuntimeError( raise RuntimeError(

View File

@ -1,6 +1,8 @@
"""Support for Velux covers.""" """Support for Velux covers."""
from __future__ import annotations from __future__ import annotations
from typing import Any
from pyvlx import OpeningDevice, Position from pyvlx import OpeningDevice, Position
from pyvlx.opening_device import Awning, Blind, GarageDoor, Gate, RollerShutter, Window from pyvlx.opening_device import Awning, Blind, GarageDoor, Gate, RollerShutter, Window
@ -89,15 +91,15 @@ class VeluxCover(VeluxEntity, CoverEntity):
"""Return if the cover is closed.""" """Return if the cover is closed."""
return self.node.position.closed return self.node.position.closed
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
await self.node.close(wait_for_completion=False) await self.node.close(wait_for_completion=False)
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
await self.node.open(wait_for_completion=False) await self.node.open(wait_for_completion=False)
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
position_percent = 100 - kwargs[ATTR_POSITION] position_percent = 100 - kwargs[ATTR_POSITION]
@ -105,23 +107,23 @@ class VeluxCover(VeluxEntity, CoverEntity):
Position(position_percent=position_percent), wait_for_completion=False Position(position_percent=position_percent), wait_for_completion=False
) )
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
await self.node.stop(wait_for_completion=False) await self.node.stop(wait_for_completion=False)
async def async_close_cover_tilt(self, **kwargs): async def async_close_cover_tilt(self, **kwargs: Any) -> None:
"""Close cover tilt.""" """Close cover tilt."""
await self.node.close_orientation(wait_for_completion=False) await self.node.close_orientation(wait_for_completion=False)
async def async_open_cover_tilt(self, **kwargs): async def async_open_cover_tilt(self, **kwargs: Any) -> None:
"""Open cover tilt.""" """Open cover tilt."""
await self.node.open_orientation(wait_for_completion=False) await self.node.open_orientation(wait_for_completion=False)
async def async_stop_cover_tilt(self, **kwargs): async def async_stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop cover tilt.""" """Stop cover tilt."""
await self.node.stop_orientation(wait_for_completion=False) await self.node.stop_orientation(wait_for_completion=False)
async def async_set_cover_tilt_position(self, **kwargs): async def async_set_cover_tilt_position(self, **kwargs: Any) -> None:
"""Move cover tilt to a specific position.""" """Move cover tilt to a specific position."""
position_percent = 100 - kwargs[ATTR_TILT_POSITION] position_percent = 100 - kwargs[ATTR_TILT_POSITION]
orientation = Position(position_percent=position_percent) orientation = Position(position_percent=position_percent)

View File

@ -55,7 +55,7 @@ class VeraCover(VeraDevice[veraApi.VeraCurtain], CoverEntity):
return 100 return 100
return position return position
def set_cover_position(self, **kwargs) -> None: def set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
self.vera_device.set_level(kwargs.get(ATTR_POSITION)) self.vera_device.set_level(kwargs.get(ATTR_POSITION))
self.schedule_update_ha_state() self.schedule_update_ha_state()

View File

@ -1,4 +1,6 @@
"""Support for WiLight Cover.""" """Support for WiLight Cover."""
from typing import Any
from pywilight.const import ( from pywilight.const import (
COVER_V1, COVER_V1,
ITEM_COVER, ITEM_COVER,
@ -86,19 +88,19 @@ class WiLightCover(WiLightDevice, CoverEntity):
and wilight_to_hass_position(self._status["position_current"]) == 0 and wilight_to_hass_position(self._status["position_current"]) == 0
) )
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
await self._client.cover_command(self._index, WL_OPEN) await self._client.cover_command(self._index, WL_OPEN)
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close cover.""" """Close cover."""
await self._client.cover_command(self._index, WL_CLOSE) await self._client.cover_command(self._index, WL_CLOSE)
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
position = hass_to_wilight_position(kwargs[ATTR_POSITION]) position = hass_to_wilight_position(kwargs[ATTR_POSITION])
await self._client.set_cover_position(self._index, position) await self._client.set_cover_position(self._index, position)
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
await self._client.cover_command(self._index, WL_STOP) await self._client.cover_command(self._index, WL_STOP)

View File

@ -1,4 +1,6 @@
"""Support for Xiaomi curtain.""" """Support for Xiaomi curtain."""
from typing import Any
from homeassistant.components.cover import ATTR_POSITION, CoverEntity from homeassistant.components.cover import ATTR_POSITION, CoverEntity
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
@ -53,19 +55,19 @@ class XiaomiGenericCover(XiaomiDevice, CoverEntity):
"""Return if the cover is closed.""" """Return if the cover is closed."""
return self.current_cover_position <= 0 return self.current_cover_position <= 0
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Close the cover.""" """Close the cover."""
self._write_to_hub(self._sid, **{self._data_key: "close"}) self._write_to_hub(self._sid, **{self._data_key: "close"})
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
self._write_to_hub(self._sid, **{self._data_key: "open"}) self._write_to_hub(self._sid, **{self._data_key: "open"})
def stop_cover(self, **kwargs): def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
self._write_to_hub(self._sid, **{self._data_key: "stop"}) self._write_to_hub(self._sid, **{self._data_key: "stop"})
def set_cover_position(self, **kwargs): def set_cover_position(self, **kwargs: Any) -> None:
"""Move the cover to a specific position.""" """Move the cover to a specific position."""
position = kwargs.get(ATTR_POSITION) position = kwargs.get(ATTR_POSITION)
if self._data_key == DATA_KEY_PROTO_V2: if self._data_key == DATA_KEY_PROTO_V2:

View File

@ -4,7 +4,7 @@ from __future__ import annotations
import asyncio import asyncio
import functools import functools
import logging import logging
from typing import TYPE_CHECKING from typing import TYPE_CHECKING, Any
from zigpy.zcl.foundation import Status from zigpy.zcl.foundation import Status
@ -77,7 +77,7 @@ class ZhaCover(ZhaEntity, CoverEntity):
self._cover_channel = self.cluster_channels.get(CHANNEL_COVER) self._cover_channel = self.cluster_channels.get(CHANNEL_COVER)
self._current_position = None self._current_position = None
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Run when about to be added to hass.""" """Run when about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.async_accept_signal( self.async_accept_signal(
@ -134,19 +134,19 @@ class ZhaCover(ZhaEntity, CoverEntity):
self._state = state self._state = state
self.async_write_ha_state() self.async_write_ha_state()
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the window cover.""" """Open the window cover."""
res = await self._cover_channel.up_open() res = await self._cover_channel.up_open()
if not isinstance(res, Exception) and res[1] is Status.SUCCESS: if not isinstance(res, Exception) and res[1] is Status.SUCCESS:
self.async_update_state(STATE_OPENING) self.async_update_state(STATE_OPENING)
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the window cover.""" """Close the window cover."""
res = await self._cover_channel.down_close() res = await self._cover_channel.down_close()
if not isinstance(res, Exception) and res[1] is Status.SUCCESS: if not isinstance(res, Exception) and res[1] is Status.SUCCESS:
self.async_update_state(STATE_CLOSING) self.async_update_state(STATE_CLOSING)
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the roller shutter to a specific position.""" """Move the roller shutter to a specific position."""
new_pos = kwargs[ATTR_POSITION] new_pos = kwargs[ATTR_POSITION]
res = await self._cover_channel.go_to_lift_percentage(100 - new_pos) res = await self._cover_channel.go_to_lift_percentage(100 - new_pos)
@ -155,7 +155,7 @@ class ZhaCover(ZhaEntity, CoverEntity):
STATE_CLOSING if new_pos < self._current_position else STATE_OPENING STATE_CLOSING if new_pos < self._current_position else STATE_OPENING
) )
async def async_stop_cover(self, **kwargs): async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the window cover.""" """Stop the window cover."""
res = await self._cover_channel.stop() res = await self._cover_channel.stop()
if not isinstance(res, Exception) and res[1] is Status.SUCCESS: if not isinstance(res, Exception) and res[1] is Status.SUCCESS:
@ -221,7 +221,7 @@ class Shade(ZhaEntity, CoverEntity):
return None return None
return not self._is_open return not self._is_open
async def async_added_to_hass(self): async def async_added_to_hass(self) -> None:
"""Run when about to be added to hass.""" """Run when about to be added to hass."""
await super().async_added_to_hass() await super().async_added_to_hass()
self.async_accept_signal( self.async_accept_signal(
@ -251,7 +251,7 @@ class Shade(ZhaEntity, CoverEntity):
self._position = int(value * 100 / 255) self._position = int(value * 100 / 255)
self.async_write_ha_state() self.async_write_ha_state()
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the window cover.""" """Open the window cover."""
res = await self._on_off_channel.on() res = await self._on_off_channel.on()
if isinstance(res, Exception) or res[1] != Status.SUCCESS: if isinstance(res, Exception) or res[1] != Status.SUCCESS:
@ -261,7 +261,7 @@ class Shade(ZhaEntity, CoverEntity):
self._is_open = True self._is_open = True
self.async_write_ha_state() self.async_write_ha_state()
async def async_close_cover(self, **kwargs): async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the window cover.""" """Close the window cover."""
res = await self._on_off_channel.off() res = await self._on_off_channel.off()
if isinstance(res, Exception) or res[1] != Status.SUCCESS: if isinstance(res, Exception) or res[1] != Status.SUCCESS:
@ -271,7 +271,7 @@ class Shade(ZhaEntity, CoverEntity):
self._is_open = False self._is_open = False
self.async_write_ha_state() self.async_write_ha_state()
async def async_set_cover_position(self, **kwargs): async def async_set_cover_position(self, **kwargs: Any) -> None:
"""Move the roller shutter to a specific position.""" """Move the roller shutter to a specific position."""
new_pos = kwargs[ATTR_POSITION] new_pos = kwargs[ATTR_POSITION]
res = await self._level_channel.move_to_level_with_on_off( res = await self._level_channel.move_to_level_with_on_off(
@ -285,7 +285,7 @@ class Shade(ZhaEntity, CoverEntity):
self._position = new_pos self._position = new_pos
self.async_write_ha_state() self.async_write_ha_state()
async def async_stop_cover(self, **kwargs) -> None: async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover.""" """Stop the cover."""
res = await self._level_channel.stop() res = await self._level_channel.stop()
if isinstance(res, Exception) or res[1] != Status.SUCCESS: if isinstance(res, Exception) or res[1] != Status.SUCCESS:
@ -301,7 +301,7 @@ class KeenVent(Shade):
_attr_device_class = CoverDeviceClass.DAMPER _attr_device_class = CoverDeviceClass.DAMPER
async def async_open_cover(self, **kwargs): async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover.""" """Open the cover."""
position = self._position or 100 position = self._position or 100
tasks = [ tasks = [

View File

@ -53,11 +53,11 @@ class ZWaveMeCover(ZWaveMeEntity, CoverEntity):
| CoverEntityFeature.SET_POSITION | CoverEntityFeature.SET_POSITION
) )
def close_cover(self, **kwargs): def close_cover(self, **kwargs: Any) -> None:
"""Close cover.""" """Close cover."""
self.controller.zwave_api.send_command(self.device.id, "exact?level=0") self.controller.zwave_api.send_command(self.device.id, "exact?level=0")
def open_cover(self, **kwargs): def open_cover(self, **kwargs: Any) -> None:
"""Open cover.""" """Open cover."""
self.controller.zwave_api.send_command(self.device.id, "exact?level=99") self.controller.zwave_api.send_command(self.device.id, "exact?level=99")