Adjust CoverEntity function type hints in components (#73912)

Adjust CoverEntity functions in components
pull/73944/head
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."""
from __future__ import annotations
from typing import Any
from homeassistant.components.cover import (
ATTR_POSITION,
CoverEntity,
@ -92,31 +94,31 @@ class AcmedaCover(AcmedaBase, CoverEntity):
"""Return if the cover is closed."""
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."""
await self.roller.move_down()
async def async_open_cover(self, **kwargs):
async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the roller."""
await self.roller.move_up()
async def async_stop_cover(self, **kwargs):
async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the roller."""
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."""
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."""
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."""
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."""
await self.roller.move_stop()

View File

@ -1,6 +1,8 @@
"""Support for ADS covers."""
from __future__ import annotations
from typing import Any
import pyads
import voluptuous as vol
@ -122,7 +124,7 @@ class AdsCover(AdsEntity, CoverEntity):
if ads_var_pos_set is not None:
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."""
if self._ads_var is not None:
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 self._state_dict[STATE_KEY_POSITION]
def stop_cover(self, **kwargs):
def stop_cover(self, **kwargs: Any) -> None:
"""Fire the stop action."""
if self._ads_var_stop:
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."""
position = kwargs[ATTR_POSITION]
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
)
def open_cover(self, **kwargs):
def open_cover(self, **kwargs: Any) -> None:
"""Move the cover up."""
if self._ads_var_open is not None:
self._ads_hub.write_by_name(self._ads_var_open, True, pyads.PLCTYPE_BOOL)
elif self._ads_var_pos_set is not None:
self.set_cover_position(position=100)
def close_cover(self, **kwargs):
def close_cover(self, **kwargs: Any) -> None:
"""Move the cover down."""
if self._ads_var_close is not None:
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."""
from typing import Any
from homeassistant.components.cover import (
ATTR_POSITION,
CoverDeviceClass,
@ -67,7 +69,7 @@ class AdvantageAirZoneVent(AdvantageAirEntity, CoverEntity):
return self._zone["value"]
return 0
async def async_open_cover(self, **kwargs):
async def async_open_cover(self, **kwargs: Any) -> None:
"""Fully open zone vent."""
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."""
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."""
position = round(kwargs[ATTR_POSITION] / 5) * 5
if position == 0:

View File

@ -1,4 +1,6 @@
"""BleBox cover entity."""
from typing import Any
from homeassistant.components.cover import (
ATTR_POSITION,
CoverEntity,
@ -62,21 +64,21 @@ class BleBoxCoverEntity(BleBoxEntity, CoverEntity):
"""Return whether cover is 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."""
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."""
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."""
position = kwargs[ATTR_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."""
await self._feature.async_stop()

View File

@ -1,4 +1,6 @@
"""Platform for cover integration."""
from typing import Any
from boschshcpy import SHCSession, SHCShutterControl
from homeassistant.components.cover import (
@ -54,7 +56,7 @@ class ShutterControlCover(SHCEntity, CoverEntity):
"""Return the current cover position."""
return round(self._device.level * 100.0)
def stop_cover(self, **kwargs):
def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover."""
self._device.stop()
@ -79,15 +81,15 @@ class ShutterControlCover(SHCEntity, CoverEntity):
== SHCShutterControl.ShutterControlService.State.CLOSING
)
def open_cover(self, **kwargs):
def open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
self._device.level = 1.0
def close_cover(self, **kwargs):
def close_cover(self, **kwargs: Any) -> None:
"""Close cover."""
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."""
position = kwargs[ATTR_POSITION]
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)
self._state = int(payload)
def open_cover(self, **kwargs) -> None:
def open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
self._move_cover(self._command_open)
def close_cover(self, **kwargs) -> None:
def close_cover(self, **kwargs: Any) -> None:
"""Close the cover."""
self._move_cover(self._command_close)
def stop_cover(self, **kwargs) -> None:
def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover."""
self._move_cover(self._command_stop)

View File

@ -1,6 +1,8 @@
"""Demo platform for the cover component."""
from __future__ import annotations
from typing import Any
from homeassistant.components.cover import (
ATTR_POSITION,
ATTR_TILT_POSITION,
@ -159,7 +161,7 @@ class DemoCover(CoverEntity):
return self._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."""
if self._position == 0:
return
@ -173,7 +175,7 @@ class DemoCover(CoverEntity):
self._requested_closing = True
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."""
if self._tilt_position in (0, None):
return
@ -181,7 +183,7 @@ class DemoCover(CoverEntity):
self._listen_cover_tilt()
self._requested_closing_tilt = True
async def async_open_cover(self, **kwargs):
async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
if self._position == 100:
return
@ -195,7 +197,7 @@ class DemoCover(CoverEntity):
self._requested_closing = False
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."""
if self._tilt_position in (100, None):
return
@ -223,7 +225,7 @@ class DemoCover(CoverEntity):
self._listen_cover_tilt()
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."""
self._is_closing = False
self._is_opening = False
@ -234,7 +236,7 @@ class DemoCover(CoverEntity):
self._unsub_listener_cover = 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."""
if self._tilt_position is None:
return

View File

@ -1,5 +1,7 @@
"""Support for the Dynalite channels as covers."""
from typing import Any
from homeassistant.components.cover import DEVICE_CLASSES, CoverDeviceClass, CoverEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant, callback
@ -60,19 +62,19 @@ class DynaliteCover(DynaliteBase, CoverEntity):
"""Return true if cover 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."""
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."""
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."""
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."""
await self._device.async_stop_cover(**kwargs)
@ -85,18 +87,18 @@ class DynaliteCoverWithTilt(DynaliteCover):
"""Return the current 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."""
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."""
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."""
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."""
await self._device.async_stop_cover_tilt(**kwargs)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
"""Support for HomematicIP Cloud cover devices."""
from __future__ import annotations
from typing import Any
from homematicip.aio.device import (
AsyncBlindModule,
AsyncDinRailBlind4,
@ -86,14 +88,14 @@ class HomematicipBlindModule(HomematicipGenericEntity, CoverEntity):
return int((1 - self._device.secondaryShadingLevel) * 100)
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."""
position = kwargs[ATTR_POSITION]
# HmIP cover is closed:1 -> open:0
level = 1 - position / 100.0
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."""
position = kwargs[ATTR_TILT_POSITION]
# HmIP slats is closed:1 -> open:0
@ -110,37 +112,37 @@ class HomematicipBlindModule(HomematicipGenericEntity, CoverEntity):
return self._device.primaryShadingLevel == HMIP_COVER_CLOSED
return None
async def async_open_cover(self, **kwargs) -> None:
async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
await self._device.set_primary_shading_level(
primaryShadingLevel=HMIP_COVER_OPEN
)
async def async_close_cover(self, **kwargs) -> None:
async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover."""
await self._device.set_primary_shading_level(
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."""
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."""
await self._device.set_secondary_shading_level(
primaryShadingLevel=self._device.primaryShadingLevel,
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."""
await self._device.set_secondary_shading_level(
primaryShadingLevel=self._device.primaryShadingLevel,
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."""
await self._device.stop()
@ -174,7 +176,7 @@ class HomematicipMultiCoverShutter(HomematicipGenericEntity, CoverEntity):
)
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."""
position = kwargs[ATTR_POSITION]
# HmIP cover is closed:1 -> open:0
@ -191,15 +193,15 @@ class HomematicipMultiCoverShutter(HomematicipGenericEntity, CoverEntity):
)
return None
async def async_open_cover(self, **kwargs) -> None:
async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
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."""
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."""
await self._device.set_shutter_stop(self._channel)
@ -236,26 +238,26 @@ class HomematicipMultiCoverSlats(HomematicipMultiCoverShutter, CoverEntity):
)
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."""
position = kwargs[ATTR_TILT_POSITION]
# HmIP slats is closed:1 -> open:0
level = 1 - position / 100.0
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."""
await self._device.set_slats_level(
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."""
await self._device.set_slats_level(
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."""
await self._device.set_shutter_stop(self._channel)
@ -292,15 +294,15 @@ class HomematicipGarageDoorModule(HomematicipGenericEntity, CoverEntity):
"""Return if the cover is 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."""
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."""
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."""
await self._device.send_door_command(DoorCommand.STOP)
@ -339,40 +341,40 @@ class HomematicipCoverShutterGroup(HomematicipGenericEntity, CoverEntity):
return self._device.shutterLevel == HMIP_COVER_CLOSED
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."""
position = kwargs[ATTR_POSITION]
# HmIP cover is closed:1 -> open:0
level = 1 - position / 100.0
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."""
position = kwargs[ATTR_TILT_POSITION]
# HmIP slats is closed:1 -> open:0
level = 1 - position / 100.0
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."""
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."""
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."""
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."""
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."""
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."""
await self._device.set_shutter_stop()

View File

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

View File

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

View File

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

View File

@ -1,5 +1,6 @@
"""Support for Motion Blinds using their WLAN API."""
import logging
from typing import Any
from motionblinds import DEVICE_TYPES_WIFI, BlindType
import voluptuous as vol
@ -243,7 +244,7 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity):
return None
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."""
self._blind.Register_callback(self.unique_id, self.schedule_update_ha_state)
await super().async_added_to_hass()
@ -288,19 +289,19 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity):
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."""
async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Open)
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."""
async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Close)
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."""
position = kwargs[ATTR_POSITION]
async with self._api_lock:
@ -327,7 +328,7 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity):
)
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."""
async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Stop)
@ -349,23 +350,23 @@ class MotionTiltDevice(MotionPositionDevice):
return None
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."""
async with self._api_lock:
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."""
async with self._api_lock:
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."""
angle = kwargs[ATTR_TILT_POSITION] * 180 / 100
async with self._api_lock:
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."""
async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Stop)
@ -463,19 +464,19 @@ class MotionTDBUDevice(MotionPositionDevice):
attributes[ATTR_WIDTH] = self._blind.width
return attributes
async def async_open_cover(self, **kwargs):
async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Open, self._motor_key)
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."""
async with self._api_lock:
await self.hass.async_add_executor_job(self._blind.Close, self._motor_key)
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."""
position = kwargs[ATTR_POSITION]
async with self._api_lock:
@ -496,7 +497,7 @@ class MotionTDBUDevice(MotionPositionDevice):
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."""
async with self._api_lock:
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 logging
from typing import Any
import voluptuous as vol
@ -545,7 +546,7 @@ class MqttCover(MqttEntity, CoverEntity):
return supported_features
async def async_open_cover(self, **kwargs):
async def async_open_cover(self, **kwargs: Any) -> None:
"""Move the cover up.
This method is a coroutine.
@ -566,7 +567,7 @@ class MqttCover(MqttEntity, CoverEntity):
)
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.
This method is a coroutine.
@ -587,7 +588,7 @@ class MqttCover(MqttEntity, CoverEntity):
)
self.async_write_ha_state()
async def async_stop_cover(self, **kwargs):
async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the device.
This method is a coroutine.
@ -600,7 +601,7 @@ class MqttCover(MqttEntity, CoverEntity):
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_open_position = self._config[CONF_TILT_OPEN_POSITION]
variables = {
@ -625,7 +626,7 @@ class MqttCover(MqttEntity, CoverEntity):
)
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_closed_position = self._config[CONF_TILT_CLOSED_POSITION]
variables = {
@ -652,7 +653,7 @@ class MqttCover(MqttEntity, CoverEntity):
)
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."""
tilt = kwargs[ATTR_TILT_POSITION]
percentage_tilt = tilt
@ -680,7 +681,7 @@ class MqttCover(MqttEntity, CoverEntity):
self._tilt_value = percentage_tilt
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."""
position = kwargs[ATTR_POSITION]
percentage_position = position
@ -711,7 +712,7 @@ class MqttCover(MqttEntity, CoverEntity):
self._position = percentage_position
self.async_write_ha_state()
async def async_toggle_tilt(self, **kwargs):
async def async_toggle_tilt(self, **kwargs: Any) -> None:
"""Toggle the entity."""
if self.is_tilt_closed():
await self.async_open_cover_tilt(**kwargs)

View File

@ -1,4 +1,6 @@
"""Support for MyQ-Enabled Garage Doors."""
from typing import Any
from pymyq.const import DEVICE_TYPE_GATE as MYQ_DEVICE_TYPE_GATE
from pymyq.errors import MyQError
@ -67,7 +69,7 @@ class MyQCover(MyQEntity, CoverEntity):
"""Return if the cover is opening or not."""
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."""
if self.is_closing or self.is_closed:
return
@ -90,7 +92,7 @@ class MyQCover(MyQEntity, CoverEntity):
if not result:
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."""
if self.is_opening or self.is_open:
return

View File

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

View File

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

View File

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

View File

@ -2,6 +2,7 @@
from __future__ import annotations
import logging
from typing import Any
from homeassistant.components.cover import ATTR_POSITION, CoverDeviceClass, CoverEntity
from homeassistant.const import ATTR_ID, STATE_CLOSED, STATE_CLOSING, STATE_OPENING
@ -83,21 +84,21 @@ class SlideCover(CoverEntity):
pos = int(pos * 100)
return pos
async def async_open_cover(self, **kwargs):
async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
self._slide["state"] = STATE_OPENING
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."""
self._slide["state"] = STATE_CLOSING
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."""
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."""
position = kwargs[ATTR_POSITION] / 100
if not self._invert:

View File

@ -2,6 +2,7 @@
from __future__ import annotations
from collections.abc import Sequence
from typing import Any
from pysmartthings import Attribute, Capability
@ -81,7 +82,7 @@ class SmartThingsCover(SmartThingsEntity, CoverEntity):
if Capability.switch_level in device.capabilities:
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."""
# Same command for all 3 supported capabilities
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
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."""
# Same for all capability types
await self._device.open(set_status=True)

View File

@ -1,6 +1,8 @@
"""Support for Soma Covers."""
from __future__ import annotations
from typing import Any
from homeassistant.components.cover import (
ATTR_POSITION,
ATTR_TILT_POSITION,
@ -59,7 +61,7 @@ class SomaTilt(SomaEntity, CoverEntity):
"""Return if the cover tilt is closed."""
return self.current_position == 0
def close_cover_tilt(self, **kwargs):
def close_cover_tilt(self, **kwargs: Any) -> None:
"""Close the cover tilt."""
response = self.api.set_shade_position(self.device["mac"], 100)
if not is_api_response_success(response):
@ -68,7 +70,7 @@ class SomaTilt(SomaEntity, CoverEntity):
)
self.set_position(0)
def open_cover_tilt(self, **kwargs):
def open_cover_tilt(self, **kwargs: Any) -> None:
"""Open the cover tilt."""
response = self.api.set_shade_position(self.device["mac"], -100)
if not is_api_response_success(response):
@ -77,7 +79,7 @@ class SomaTilt(SomaEntity, CoverEntity):
)
self.set_position(100)
def stop_cover_tilt(self, **kwargs):
def stop_cover_tilt(self, **kwargs: Any) -> None:
"""Stop the cover tilt."""
response = self.api.stop_shade(self.device["mac"])
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
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."""
# 0 -> Closed down (api: 100)
# 50 -> Fully open (api: 0)
@ -133,7 +135,7 @@ class SomaShade(SomaEntity, CoverEntity):
"""Return if the cover is closed."""
return self.current_position == 0
def close_cover(self, **kwargs):
def close_cover(self, **kwargs: Any) -> None:
"""Close the cover."""
response = self.api.set_shade_position(self.device["mac"], 100)
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"]}'
)
def open_cover(self, **kwargs):
def open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
response = self.api.set_shade_position(self.device["mac"], 0)
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"]}'
)
def stop_cover(self, **kwargs):
def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover."""
response = self.api.stop_shade(self.device["mac"])
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
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."""
self.current_position = kwargs[ATTR_POSITION]
response = self.api.set_shade_position(

View File

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

View File

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

View File

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

View File

@ -1,6 +1,8 @@
"""Support for Tellstick covers."""
from __future__ import annotations
from typing import Any
from homeassistant.components.cover import CoverEntity
from homeassistant.core import HomeAssistant
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
def close_cover(self, **kwargs):
def close_cover(self, **kwargs: Any) -> None:
"""Close the cover."""
self._tellcore_device.down()
def open_cover(self, **kwargs):
def open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
self._tellcore_device.up()
def stop_cover(self, **kwargs):
def stop_cover(self, **kwargs: Any) -> None:
"""Stop the cover."""
self._tellcore_device.stop()

View File

@ -2,6 +2,7 @@
from __future__ import annotations
import logging
from typing import Any
import voluptuous as vol
@ -180,7 +181,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
self._is_closing = False
self._tilt_value = None
async def async_added_to_hass(self):
async def async_added_to_hass(self) -> None:
"""Register callbacks."""
if self._template:
self.add_template_attribute(
@ -322,7 +323,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
return supported_features
async def async_open_cover(self, **kwargs):
async def async_open_cover(self, **kwargs: Any) -> None:
"""Move the cover up."""
if self._open_script:
await self.async_run_script(self._open_script, context=self._context)
@ -336,7 +337,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
self._position = 100
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."""
if self._close_script:
await self.async_run_script(self._close_script, context=self._context)
@ -350,12 +351,12 @@ class CoverTemplate(TemplateEntity, CoverEntity):
self._position = 0
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."""
if self._stop_script:
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."""
self._position = kwargs[ATTR_POSITION]
await self.async_run_script(
@ -366,7 +367,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
if self._optimistic:
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."""
self._tilt_value = 100
await self.async_run_script(
@ -377,7 +378,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
if self._tilt_optimistic:
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."""
self._tilt_value = 0
await self.async_run_script(
@ -388,7 +389,7 @@ class CoverTemplate(TemplateEntity, CoverEntity):
if self._tilt_optimistic:
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."""
self._tilt_value = kwargs[ATTR_TILT_POSITION]
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."""
if self._tilt is None:
raise RuntimeError(

View File

@ -1,6 +1,8 @@
"""Support for Velux covers."""
from __future__ import annotations
from typing import Any
from pyvlx import OpeningDevice, Position
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 self.node.position.closed
async def async_close_cover(self, **kwargs):
async def async_close_cover(self, **kwargs: Any) -> None:
"""Close the cover."""
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."""
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."""
position_percent = 100 - kwargs[ATTR_POSITION]
@ -105,23 +107,23 @@ class VeluxCover(VeluxEntity, CoverEntity):
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."""
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."""
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."""
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."""
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."""
position_percent = 100 - kwargs[ATTR_TILT_POSITION]
orientation = Position(position_percent=position_percent)

View File

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

View File

@ -1,4 +1,6 @@
"""Support for WiLight Cover."""
from typing import Any
from pywilight.const import (
COVER_V1,
ITEM_COVER,
@ -86,19 +88,19 @@ class WiLightCover(WiLightDevice, CoverEntity):
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."""
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."""
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."""
position = hass_to_wilight_position(kwargs[ATTR_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."""
await self._client.cover_command(self._index, WL_STOP)

View File

@ -1,4 +1,6 @@
"""Support for Xiaomi curtain."""
from typing import Any
from homeassistant.components.cover import ATTR_POSITION, CoverEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
@ -53,19 +55,19 @@ class XiaomiGenericCover(XiaomiDevice, CoverEntity):
"""Return if the cover is closed."""
return self.current_cover_position <= 0
def close_cover(self, **kwargs):
def close_cover(self, **kwargs: Any) -> None:
"""Close the cover."""
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."""
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."""
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."""
position = kwargs.get(ATTR_POSITION)
if self._data_key == DATA_KEY_PROTO_V2:

View File

@ -4,7 +4,7 @@ from __future__ import annotations
import asyncio
import functools
import logging
from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Any
from zigpy.zcl.foundation import Status
@ -77,7 +77,7 @@ class ZhaCover(ZhaEntity, CoverEntity):
self._cover_channel = self.cluster_channels.get(CHANNEL_COVER)
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."""
await super().async_added_to_hass()
self.async_accept_signal(
@ -134,19 +134,19 @@ class ZhaCover(ZhaEntity, CoverEntity):
self._state = 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."""
res = await self._cover_channel.up_open()
if not isinstance(res, Exception) and res[1] is Status.SUCCESS:
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."""
res = await self._cover_channel.down_close()
if not isinstance(res, Exception) and res[1] is Status.SUCCESS:
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."""
new_pos = kwargs[ATTR_POSITION]
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
)
async def async_stop_cover(self, **kwargs):
async def async_stop_cover(self, **kwargs: Any) -> None:
"""Stop the window cover."""
res = await self._cover_channel.stop()
if not isinstance(res, Exception) and res[1] is Status.SUCCESS:
@ -221,7 +221,7 @@ class Shade(ZhaEntity, CoverEntity):
return None
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."""
await super().async_added_to_hass()
self.async_accept_signal(
@ -251,7 +251,7 @@ class Shade(ZhaEntity, CoverEntity):
self._position = int(value * 100 / 255)
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."""
res = await self._on_off_channel.on()
if isinstance(res, Exception) or res[1] != Status.SUCCESS:
@ -261,7 +261,7 @@ class Shade(ZhaEntity, CoverEntity):
self._is_open = True
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."""
res = await self._on_off_channel.off()
if isinstance(res, Exception) or res[1] != Status.SUCCESS:
@ -271,7 +271,7 @@ class Shade(ZhaEntity, CoverEntity):
self._is_open = False
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."""
new_pos = kwargs[ATTR_POSITION]
res = await self._level_channel.move_to_level_with_on_off(
@ -285,7 +285,7 @@ class Shade(ZhaEntity, CoverEntity):
self._position = new_pos
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."""
res = await self._level_channel.stop()
if isinstance(res, Exception) or res[1] != Status.SUCCESS:
@ -301,7 +301,7 @@ class KeenVent(Shade):
_attr_device_class = CoverDeviceClass.DAMPER
async def async_open_cover(self, **kwargs):
async def async_open_cover(self, **kwargs: Any) -> None:
"""Open the cover."""
position = self._position or 100
tasks = [

View File

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