diff --git a/homeassistant/components/acmeda/cover.py b/homeassistant/components/acmeda/cover.py index d772d8ab01f..887e26cd7fc 100644 --- a/homeassistant/components/acmeda/cover.py +++ b/homeassistant/components/acmeda/cover.py @@ -47,7 +47,7 @@ class AcmedaCover(AcmedaBase, CoverEntity): """Representation of a Acmeda cover device.""" @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """Return the current position of the roller blind. None is unknown, 0 is closed, 100 is fully open. @@ -58,7 +58,7 @@ class AcmedaCover(AcmedaBase, CoverEntity): return position @property - def current_cover_tilt_position(self): + def current_cover_tilt_position(self) -> int | None: """Return the current tilt of the roller blind. None is unknown, 0 is closed, 100 is fully open. @@ -69,7 +69,7 @@ class AcmedaCover(AcmedaBase, CoverEntity): return position @property - def supported_features(self): + def supported_features(self) -> int: """Flag supported features.""" supported_features = 0 if self.current_cover_position is not None: @@ -90,7 +90,7 @@ class AcmedaCover(AcmedaBase, CoverEntity): return supported_features @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed.""" return self.roller.closed_percent == 100 diff --git a/homeassistant/components/ads/cover.py b/homeassistant/components/ads/cover.py index a976ce15877..a2fb1888cd3 100644 --- a/homeassistant/components/ads/cover.py +++ b/homeassistant/components/ads/cover.py @@ -135,7 +135,7 @@ class AdsCover(AdsEntity, CoverEntity): ) @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the cover is closed.""" if self._ads_var is not None: return self._state_dict[STATE_KEY_STATE] @@ -144,7 +144,7 @@ class AdsCover(AdsEntity, CoverEntity): return None @property - def current_cover_position(self): + def current_cover_position(self) -> int: """Return current position of cover.""" return self._state_dict[STATE_KEY_POSITION] diff --git a/homeassistant/components/advantage_air/cover.py b/homeassistant/components/advantage_air/cover.py index bbe17835d71..36ae2c7fff0 100644 --- a/homeassistant/components/advantage_air/cover.py +++ b/homeassistant/components/advantage_air/cover.py @@ -58,12 +58,12 @@ class AdvantageAirZoneVent(AdvantageAirEntity, CoverEntity): ) @property - def is_closed(self): + def is_closed(self) -> bool: """Return if vent is fully closed.""" return self._zone["state"] == ADVANTAGE_AIR_STATE_CLOSE @property - def current_cover_position(self): + def current_cover_position(self) -> int: """Return vents current position as a percentage.""" if self._zone["state"] == ADVANTAGE_AIR_STATE_OPEN: return self._zone["value"] diff --git a/homeassistant/components/blebox/cover.py b/homeassistant/components/blebox/cover.py index a7f531fe519..368443988a4 100644 --- a/homeassistant/components/blebox/cover.py +++ b/homeassistant/components/blebox/cover.py @@ -1,4 +1,6 @@ """BleBox cover entity.""" +from __future__ import annotations + from typing import Any from homeassistant.components.cover import ( @@ -41,7 +43,7 @@ class BleBoxCoverEntity(BleBoxEntity, CoverEntity): ) @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """Return the current cover position.""" position = self._feature.current if position == -1: # possible for shutterBox @@ -50,17 +52,17 @@ class BleBoxCoverEntity(BleBoxEntity, CoverEntity): return None if position is None else 100 - position @property - def is_opening(self): + def is_opening(self) -> bool | None: """Return whether cover is opening.""" return self._is_state(STATE_OPENING) @property - def is_closing(self): + def is_closing(self) -> bool | None: """Return whether cover is closing.""" return self._is_state(STATE_CLOSING) @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return whether cover is closed.""" return self._is_state(STATE_CLOSED) @@ -82,6 +84,6 @@ class BleBoxCoverEntity(BleBoxEntity, CoverEntity): """Stop the cover.""" await self._feature.async_stop() - def _is_state(self, state_name): + def _is_state(self, state_name) -> bool | None: value = BLEBOX_TO_HASS_COVER_STATES[self._feature.state] return None if value is None else value == state_name diff --git a/homeassistant/components/bosch_shc/cover.py b/homeassistant/components/bosch_shc/cover.py index cdbe884dc45..91dc361a23d 100644 --- a/homeassistant/components/bosch_shc/cover.py +++ b/homeassistant/components/bosch_shc/cover.py @@ -52,7 +52,7 @@ class ShutterControlCover(SHCEntity, CoverEntity): ) @property - def current_cover_position(self): + def current_cover_position(self) -> int: """Return the current cover position.""" return round(self._device.level * 100.0) @@ -61,12 +61,12 @@ class ShutterControlCover(SHCEntity, CoverEntity): self._device.stop() @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed or not.""" return self.current_cover_position == 0 @property - def is_opening(self): + def is_opening(self) -> bool: """Return if the cover is opening or not.""" return ( self._device.operation_state @@ -74,7 +74,7 @@ class ShutterControlCover(SHCEntity, CoverEntity): ) @property - def is_closing(self): + def is_closing(self) -> bool: """Return if the cover is closing or not.""" return ( self._device.operation_state diff --git a/homeassistant/components/brunt/cover.py b/homeassistant/components/brunt/cover.py index c38dfa0eb78..489229622b2 100644 --- a/homeassistant/components/brunt/cover.py +++ b/homeassistant/components/brunt/cover.py @@ -1,7 +1,6 @@ """Support for Brunt Blind Engine covers.""" from __future__ import annotations -from collections.abc import MutableMapping from typing import Any from aiohttp.client_exceptions import ClientResponseError @@ -140,7 +139,7 @@ class BruntDevice(CoordinatorEntity, CoverEntity): return self.move_state == 2 @property - def extra_state_attributes(self) -> MutableMapping[str, Any]: + def extra_state_attributes(self) -> dict[str, Any]: """Return the detailed device state attributes.""" return { ATTR_REQUEST_POSITION: self.request_cover_position, diff --git a/homeassistant/components/demo/cover.py b/homeassistant/components/demo/cover.py index 5c908dfa33a..f867ed3faa4 100644 --- a/homeassistant/components/demo/cover.py +++ b/homeassistant/components/demo/cover.py @@ -110,42 +110,42 @@ class DemoCover(CoverEntity): ) @property - def unique_id(self): + def unique_id(self) -> str: """Return unique ID for cover.""" return self._unique_id @property - def name(self): + def name(self) -> str: """Return the name of the cover.""" return self._name @property - def should_poll(self): + def should_poll(self) -> bool: """No polling needed for a demo cover.""" return False @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """Return the current position of the cover.""" return self._position @property - def current_cover_tilt_position(self): + def current_cover_tilt_position(self) -> int | None: """Return the current tilt position of the cover.""" return self._tilt_position @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed.""" return self._closed @property - def is_closing(self): + def is_closing(self) -> bool: """Return if the cover is closing.""" return self._is_closing @property - def is_opening(self): + def is_opening(self) -> bool: """Return if the cover is opening.""" return self._is_opening @@ -155,7 +155,7 @@ class DemoCover(CoverEntity): return self._device_class @property - def supported_features(self): + def supported_features(self) -> int: """Flag supported features.""" if self._supported_features is not None: return self._supported_features diff --git a/homeassistant/components/esphome/cover.py b/homeassistant/components/esphome/cover.py index 4296c899253..ab8b7af2185 100644 --- a/homeassistant/components/esphome/cover.py +++ b/homeassistant/components/esphome/cover.py @@ -111,7 +111,7 @@ class EsphomeCover(EsphomeEntity[CoverInfo, CoverState], CoverEntity): """Stop the cover.""" await self._client.cover_command(key=self._static_info.key, stop=True) - async def async_set_cover_position(self, **kwargs: int) -> None: + async def async_set_cover_position(self, **kwargs: Any) -> None: """Move the cover to a specific position.""" await self._client.cover_command( key=self._static_info.key, position=kwargs[ATTR_POSITION] / 100 diff --git a/homeassistant/components/fibaro/cover.py b/homeassistant/components/fibaro/cover.py index 1e5583f20d6..c0749f9c100 100644 --- a/homeassistant/components/fibaro/cover.py +++ b/homeassistant/components/fibaro/cover.py @@ -72,12 +72,12 @@ class FibaroCover(FibaroDevice, CoverEntity): return False @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """Return current position of cover. 0 is closed, 100 is open.""" return self.bound(self.level) @property - def current_cover_tilt_position(self): + def current_cover_tilt_position(self) -> int | None: """Return the current tilt position for venetian blinds.""" return self.bound(self.level2) @@ -90,7 +90,7 @@ class FibaroCover(FibaroDevice, CoverEntity): self.set_level2(kwargs.get(ATTR_TILT_POSITION)) @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the cover is closed.""" if self._is_open_close_only(): return self.fibaro_device.properties.state.lower() == "closed" diff --git a/homeassistant/components/garadget/cover.py b/homeassistant/components/garadget/cover.py index e0372db0c6c..96ebe698605 100644 --- a/homeassistant/components/garadget/cover.py +++ b/homeassistant/components/garadget/cover.py @@ -7,7 +7,11 @@ from typing import Any import requests import voluptuous as vol -from homeassistant.components.cover import PLATFORM_SCHEMA, CoverEntity +from homeassistant.components.cover import ( + PLATFORM_SCHEMA, + CoverDeviceClass, + CoverEntity, +) from homeassistant.const import ( CONF_ACCESS_TOKEN, CONF_COVERS, @@ -135,17 +139,17 @@ class GaradgetCover(CoverEntity): self.remove_token() @property - def name(self): + def name(self) -> str: """Return the name of the cover.""" return self._name @property - def available(self): + def available(self) -> bool: """Return True if entity is available.""" return self._available @property - def extra_state_attributes(self): + def extra_state_attributes(self) -> dict[str, Any]: """Return the device state attributes.""" data = {} @@ -164,16 +168,16 @@ class GaradgetCover(CoverEntity): return data @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the cover is closed.""" if self._state is None: return None return self._state == STATE_CLOSED @property - def device_class(self): + def device_class(self) -> CoverDeviceClass: """Return the class of this device, from component DEVICE_CLASSES.""" - return "garage" + return CoverDeviceClass.GARAGE def get_token(self): """Get new token for usage during this session.""" diff --git a/homeassistant/components/gogogate2/cover.py b/homeassistant/components/gogogate2/cover.py index b7434952fc1..f0039d85295 100644 --- a/homeassistant/components/gogogate2/cover.py +++ b/homeassistant/components/gogogate2/cover.py @@ -62,12 +62,12 @@ class DeviceCover(GoGoGate2Entity, CoverEntity): ) @property - def name(self): + def name(self) -> str | None: """Return the name of the door.""" return self.door.name @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return true if cover is closed, else False.""" door_status = self.door_status if door_status == DoorStatus.OPENED: @@ -77,12 +77,12 @@ class DeviceCover(GoGoGate2Entity, CoverEntity): return None @property - def is_closing(self): + def is_closing(self) -> bool: """Return if the cover is closing or not.""" return self.door_status == TransitionDoorStatus.CLOSING @property - def is_opening(self): + def is_opening(self) -> bool: """Return if the cover is opening or not.""" return self.door_status == TransitionDoorStatus.OPENING diff --git a/homeassistant/components/homematic/cover.py b/homeassistant/components/homematic/cover.py index d138e172784..d5f1802e774 100644 --- a/homeassistant/components/homematic/cover.py +++ b/homeassistant/components/homematic/cover.py @@ -43,7 +43,7 @@ class HMCover(HMDevice, CoverEntity): """Representation a HomeMatic Cover.""" @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """ Return current position of cover. @@ -60,7 +60,7 @@ class HMCover(HMDevice, CoverEntity): self._hmdevice.set_level(level, self._channel) @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return whether the cover is closed.""" if self.current_cover_position is not None: return self.current_cover_position == 0 @@ -86,7 +86,7 @@ class HMCover(HMDevice, CoverEntity): self._data.update({"LEVEL_2": None}) @property - def current_cover_tilt_position(self): + def current_cover_tilt_position(self) -> int | None: """Return current position of cover tilt. None is unknown, 0 is closed, 100 is fully open. @@ -125,7 +125,7 @@ class HMGarage(HMCover): _attr_device_class = CoverDeviceClass.GARAGE @property - def current_cover_position(self): + def current_cover_position(self) -> None: """ Return current position of cover. @@ -135,7 +135,7 @@ class HMGarage(HMCover): return None @property - def is_closed(self): + def is_closed(self) -> bool: """Return whether the cover is closed.""" return self._hmdevice.is_closed(self._hm_get_state()) diff --git a/homeassistant/components/hunterdouglas_powerview/cover.py b/homeassistant/components/hunterdouglas_powerview/cover.py index fe26a100569..3f7d04f5b87 100644 --- a/homeassistant/components/hunterdouglas_powerview/cover.py +++ b/homeassistant/components/hunterdouglas_powerview/cover.py @@ -192,7 +192,7 @@ class PowerViewShadeBase(ShadeEntity, CoverEntity): return {STATE_ATTRIBUTE_ROOM_NAME: self._room_name} @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed.""" return self.positions.primary <= CLOSED_POSITION @@ -474,7 +474,7 @@ class PowerViewShadeTDBUTop(PowerViewShadeTDBU): return False @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed.""" # top shade needs to check other motor return self.positions.secondary <= CLOSED_POSITION diff --git a/homeassistant/components/insteon/cover.py b/homeassistant/components/insteon/cover.py index 68f7f6156e3..645450166b9 100644 --- a/homeassistant/components/insteon/cover.py +++ b/homeassistant/components/insteon/cover.py @@ -47,7 +47,7 @@ class InsteonCoverEntity(InsteonEntity, CoverEntity): ) @property - def current_cover_position(self): + def current_cover_position(self) -> int: """Return the current cover position.""" if self._insteon_device_group.value is not None: pos = self._insteon_device_group.value @@ -56,7 +56,7 @@ class InsteonCoverEntity(InsteonEntity, CoverEntity): return int(math.ceil(pos * 100 / 255)) @property - def is_closed(self): + def is_closed(self) -> bool: """Return the boolean response if the node is on.""" return bool(self.current_cover_position) diff --git a/homeassistant/components/lutron/cover.py b/homeassistant/components/lutron/cover.py index 67a0e093337..fa62ef3745a 100644 --- a/homeassistant/components/lutron/cover.py +++ b/homeassistant/components/lutron/cover.py @@ -43,12 +43,12 @@ class LutronCover(LutronDevice, CoverEntity): ) @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed.""" return self._lutron_device.last_level() < 1 @property - def current_cover_position(self): + def current_cover_position(self) -> int: """Return the current position of cover.""" return self._lutron_device.last_level() @@ -73,6 +73,6 @@ class LutronCover(LutronDevice, CoverEntity): _LOGGER.debug("Lutron ID: %d updated to %f", self._lutron_device.id, level) @property - def extra_state_attributes(self): + def extra_state_attributes(self) -> dict[str, Any]: """Return the state attributes.""" return {"lutron_integration_id": self._lutron_device.id} diff --git a/homeassistant/components/lutron_caseta/cover.py b/homeassistant/components/lutron_caseta/cover.py index 68932a2a011..b74642a8589 100644 --- a/homeassistant/components/lutron_caseta/cover.py +++ b/homeassistant/components/lutron_caseta/cover.py @@ -50,12 +50,12 @@ class LutronCasetaCover(LutronCasetaDeviceUpdatableEntity, CoverEntity): _attr_device_class = CoverDeviceClass.SHADE @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed.""" return self._device["current_state"] < 1 @property - def current_cover_position(self): + def current_cover_position(self) -> int: """Return the current position of cover.""" return self._device["current_state"] diff --git a/homeassistant/components/motion_blinds/cover.py b/homeassistant/components/motion_blinds/cover.py index 301d2c6fbc7..a73166912f4 100644 --- a/homeassistant/components/motion_blinds/cover.py +++ b/homeassistant/components/motion_blinds/cover.py @@ -1,4 +1,6 @@ """Support for Motion Blinds using their WLAN API.""" +from __future__ import annotations + import logging from typing import Any @@ -216,7 +218,7 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity): ) @property - def available(self): + def available(self) -> bool: """Return True if entity is available.""" if self.coordinator.data is None: return False @@ -227,7 +229,7 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity): return self.coordinator.data[self._blind.mac][ATTR_AVAILABLE] @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """ Return current position of cover. @@ -238,7 +240,7 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity): return 100 - self._blind.position @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the cover is closed or not.""" if self._blind.position is None: return None @@ -249,7 +251,7 @@ class MotionPositionDevice(CoordinatorEntity, CoverEntity): self._blind.Register_callback(self.unique_id, self.schedule_update_ha_state) await super().async_added_to_hass() - async def async_will_remove_from_hass(self): + async def async_will_remove_from_hass(self) -> None: """Unsubscribe when removed.""" self._blind.Remove_callback(self.unique_id) await super().async_will_remove_from_hass() @@ -340,7 +342,7 @@ class MotionTiltDevice(MotionPositionDevice): _restore_tilt = True @property - def current_cover_tilt_position(self): + def current_cover_tilt_position(self) -> int | None: """ Return current angle of cover. @@ -378,7 +380,7 @@ class MotionTiltOnlyDevice(MotionTiltDevice): _restore_tilt = False @property - def supported_features(self): + def supported_features(self) -> int: """Flag supported features.""" supported_features = ( CoverEntityFeature.OPEN_TILT @@ -392,12 +394,12 @@ class MotionTiltOnlyDevice(MotionTiltDevice): return supported_features @property - def current_cover_position(self): + def current_cover_position(self) -> None: """Return current position of cover.""" return None @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the cover is closed or not.""" if self._blind.angle is None: return None @@ -430,7 +432,7 @@ class MotionTDBUDevice(MotionPositionDevice): _LOGGER.error("Unknown motor '%s'", self._motor) @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """ Return current position of cover. @@ -442,7 +444,7 @@ class MotionTDBUDevice(MotionPositionDevice): return 100 - self._blind.scaled_position[self._motor_key] @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the cover is closed or not.""" if self._blind.position is None: return None @@ -453,7 +455,7 @@ class MotionTDBUDevice(MotionPositionDevice): return self._blind.position[self._motor_key] == 100 @property - def extra_state_attributes(self): + def extra_state_attributes(self) -> dict[str, Any]: """Return device specific state attributes.""" attributes = {} if self._blind.position is not None: diff --git a/homeassistant/components/mqtt/cover.py b/homeassistant/components/mqtt/cover.py index 8a32471ecec..54ed4f2b0a0 100644 --- a/homeassistant/components/mqtt/cover.py +++ b/homeassistant/components/mqtt/cover.py @@ -12,6 +12,7 @@ from homeassistant.components.cover import ( ATTR_POSITION, ATTR_TILT_POSITION, DEVICE_CLASSES_SCHEMA, + CoverDeviceClass, CoverEntity, CoverEntityFeature, ) @@ -486,12 +487,12 @@ class MqttCover(MqttEntity, CoverEntity): await subscription.async_subscribe_topics(self.hass, self._sub_state) @property - def assumed_state(self): + def assumed_state(self) -> bool: """Return true if we do optimistic updates.""" - return self._optimistic + return bool(self._optimistic) @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return true if the cover is closed or None if the status is unknown.""" if self._state is None: return None @@ -499,17 +500,17 @@ class MqttCover(MqttEntity, CoverEntity): return self._state == STATE_CLOSED @property - def is_opening(self): + def is_opening(self) -> bool: """Return true if the cover is actively opening.""" return self._state == STATE_OPENING @property - def is_closing(self): + def is_closing(self) -> bool: """Return true if the cover is actively closing.""" return self._state == STATE_CLOSING @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """Return current position of cover. None is unknown, 0 is closed, 100 is fully open. @@ -517,17 +518,17 @@ class MqttCover(MqttEntity, CoverEntity): return self._position @property - def current_cover_tilt_position(self): + def current_cover_tilt_position(self) -> int | None: """Return current position of cover tilt.""" return self._tilt_value @property - def device_class(self): + def device_class(self) -> CoverDeviceClass | None: """Return the class of this sensor.""" return self._config.get(CONF_DEVICE_CLASS) @property - def supported_features(self): + def supported_features(self) -> int: """Flag supported features.""" supported_features = 0 if self._config.get(CONF_COMMAND_TOPIC) is not None: diff --git a/homeassistant/components/myq/cover.py b/homeassistant/components/myq/cover.py index fe8ef16bc89..51d0b3290a6 100644 --- a/homeassistant/components/myq/cover.py +++ b/homeassistant/components/myq/cover.py @@ -50,22 +50,22 @@ class MyQCover(MyQEntity, CoverEntity): self._attr_unique_id = device.device_id @property - def is_closed(self): + def is_closed(self) -> bool: """Return true if cover is closed, else False.""" return MYQ_TO_HASS.get(self._device.state) == STATE_CLOSED @property - def is_closing(self): + def is_closing(self) -> bool: """Return if the cover is closing or not.""" return MYQ_TO_HASS.get(self._device.state) == STATE_CLOSING @property - def is_open(self): + def is_open(self) -> bool: """Return if the cover is opening or not.""" return MYQ_TO_HASS.get(self._device.state) == STATE_OPEN @property - def is_opening(self): + def is_opening(self) -> bool: """Return if the cover is opening or not.""" return MYQ_TO_HASS.get(self._device.state) == STATE_OPENING diff --git a/homeassistant/components/opengarage/cover.py b/homeassistant/components/opengarage/cover.py index ac0af64737a..aff913cf205 100644 --- a/homeassistant/components/opengarage/cover.py +++ b/homeassistant/components/opengarage/cover.py @@ -1,4 +1,6 @@ """Platform for the opengarage.io cover component.""" +from __future__ import annotations + import logging from typing import Any @@ -43,21 +45,21 @@ class OpenGarageCover(OpenGarageEntity, CoverEntity): super().__init__(open_garage_data_coordinator, device_id) @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the cover is closed.""" if self._state is None: return None return self._state == STATE_CLOSED @property - def is_closing(self): + def is_closing(self) -> bool | None: """Return if the cover is closing.""" if self._state is None: return None return self._state == STATE_CLOSING @property - def is_opening(self): + def is_opening(self) -> bool | None: """Return if the cover is opening.""" if self._state is None: return None diff --git a/homeassistant/components/scsgate/cover.py b/homeassistant/components/scsgate/cover.py index 8d94f4214af..4aa08cae3bd 100644 --- a/homeassistant/components/scsgate/cover.py +++ b/homeassistant/components/scsgate/cover.py @@ -72,17 +72,17 @@ class SCSGateCover(CoverEntity): return self._scs_id @property - def should_poll(self): + def should_poll(self) -> bool: """No polling needed.""" return False @property - def name(self): + def name(self) -> str: """Return the name of the cover.""" return self._name @property - def is_closed(self): + def is_closed(self) -> None: """Return if the cover is closed.""" return None diff --git a/homeassistant/components/slide/cover.py b/homeassistant/components/slide/cover.py index 52fcc3c8da4..866d3d40307 100644 --- a/homeassistant/components/slide/cover.py +++ b/homeassistant/components/slide/cover.py @@ -52,29 +52,29 @@ class SlideCover(CoverEntity): self._invert = slide["invert"] @property - def is_opening(self): + def is_opening(self) -> bool: """Return if the cover is opening or not.""" return self._slide["state"] == STATE_OPENING @property - def is_closing(self): + def is_closing(self) -> bool: """Return if the cover is closing or not.""" return self._slide["state"] == STATE_CLOSING @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return None if status is unknown, True if closed, else False.""" if self._slide["state"] is None: return None return self._slide["state"] == STATE_CLOSED @property - def available(self): + def available(self) -> bool: """Return False if state is not available.""" return self._slide["online"] @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """Return the current position of cover shutter.""" if (pos := self._slide["pos"]) is not None: if (1 - pos) <= DEFAULT_OFFSET or pos <= DEFAULT_OFFSET: diff --git a/homeassistant/components/smartthings/cover.py b/homeassistant/components/smartthings/cover.py index 7e2de17cad3..80a30131301 100644 --- a/homeassistant/components/smartthings/cover.py +++ b/homeassistant/components/smartthings/cover.py @@ -126,17 +126,17 @@ class SmartThingsCover(SmartThingsEntity, CoverEntity): self._state_attrs[ATTR_BATTERY_LEVEL] = battery @property - def is_opening(self): + def is_opening(self) -> bool: """Return if the cover is opening or not.""" return self._state == STATE_OPENING @property - def is_closing(self): + def is_closing(self) -> bool: """Return if the cover is closing or not.""" return self._state == STATE_CLOSING @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the cover is closed or not.""" if self._state == STATE_CLOSED: return True @@ -150,11 +150,11 @@ class SmartThingsCover(SmartThingsEntity, CoverEntity): return self._device.status.level @property - def device_class(self): + def device_class(self) -> CoverDeviceClass | None: """Define this cover as a garage door.""" return self._device_class @property - def extra_state_attributes(self): + def extra_state_attributes(self) -> dict[str, Any]: """Get additional state attributes.""" return self._state_attrs diff --git a/homeassistant/components/soma/cover.py b/homeassistant/components/soma/cover.py index 5777e904597..0130b0ca7b1 100644 --- a/homeassistant/components/soma/cover.py +++ b/homeassistant/components/soma/cover.py @@ -52,12 +52,12 @@ class SomaTilt(SomaEntity, CoverEntity): ) @property - def current_cover_tilt_position(self): + def current_cover_tilt_position(self) -> int: """Return the current cover tilt position.""" return self.current_position @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover tilt is closed.""" return self.current_position == 0 @@ -126,12 +126,12 @@ class SomaShade(SomaEntity, CoverEntity): ) @property - def current_cover_position(self): + def current_cover_position(self) -> int: """Return the current cover position.""" return self.current_position @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed.""" return self.current_position == 0 diff --git a/homeassistant/components/supla/cover.py b/homeassistant/components/supla/cover.py index b1cc0951259..c6c1d9c07db 100644 --- a/homeassistant/components/supla/cover.py +++ b/homeassistant/components/supla/cover.py @@ -60,7 +60,7 @@ class SuplaCover(SuplaChannel, CoverEntity): """Representation of a Supla Cover.""" @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """Return current position of cover. 0 is closed, 100 is open.""" if state := self.channel_data.get("state"): return 100 - state["shut"] @@ -71,7 +71,7 @@ class SuplaCover(SuplaChannel, CoverEntity): await self.async_action("REVEAL", percentage=kwargs.get(ATTR_POSITION)) @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the cover is closed.""" if self.current_cover_position is None: return None @@ -94,7 +94,7 @@ class SuplaGateDoor(SuplaChannel, CoverEntity): """Representation of a Supla gate door.""" @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the gate is closed or not.""" state = self.channel_data.get("state") if state and "hi" in state: @@ -120,6 +120,6 @@ class SuplaGateDoor(SuplaChannel, CoverEntity): await self.async_action("OPEN_CLOSE") @property - def device_class(self): + def device_class(self) -> CoverDeviceClass: """Return the class of this device, from component DEVICE_CLASSES.""" return CoverDeviceClass.GARAGE diff --git a/homeassistant/components/tellduslive/cover.py b/homeassistant/components/tellduslive/cover.py index 49c35ac3114..829478fc990 100644 --- a/homeassistant/components/tellduslive/cover.py +++ b/homeassistant/components/tellduslive/cover.py @@ -8,6 +8,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback +from . import TelldusLiveClient from .entry import TelldusLiveEntity @@ -20,7 +21,7 @@ async def async_setup_entry( async def async_discover_cover(device_id): """Discover and add a discovered sensor.""" - client = hass.data[tellduslive.DOMAIN] + client: TelldusLiveClient = hass.data[tellduslive.DOMAIN] async_add_entities([TelldusLiveCover(client, device_id)]) async_dispatcher_connect( @@ -34,7 +35,7 @@ class TelldusLiveCover(TelldusLiveEntity, CoverEntity): """Representation of a cover.""" @property - def is_closed(self): + def is_closed(self) -> bool: """Return the current position of the cover.""" return self.device.is_down diff --git a/homeassistant/components/tellstick/cover.py b/homeassistant/components/tellstick/cover.py index 7c38741960b..17da5684670 100644 --- a/homeassistant/components/tellstick/cover.py +++ b/homeassistant/components/tellstick/cover.py @@ -44,12 +44,12 @@ class TellstickCover(TellstickDevice, CoverEntity): """Representation of a Tellstick cover.""" @property - def is_closed(self): + def is_closed(self) -> None: """Return the current position of the cover is not possible.""" return None @property - def assumed_state(self): + def assumed_state(self) -> bool: """Return True if unable to access real state of the entity.""" return True diff --git a/homeassistant/components/template/cover.py b/homeassistant/components/template/cover.py index 0c86b1d5d5a..aad0270e434 100644 --- a/homeassistant/components/template/cover.py +++ b/homeassistant/components/template/cover.py @@ -12,6 +12,7 @@ from homeassistant.components.cover import ( DEVICE_CLASSES_SCHEMA, ENTITY_ID_FORMAT, PLATFORM_SCHEMA, + CoverDeviceClass, CoverEntity, CoverEntityFeature, ) @@ -154,7 +155,7 @@ class CoverTemplate(TemplateEntity, CoverEntity): self._template = config.get(CONF_VALUE_TEMPLATE) self._position_template = config.get(CONF_POSITION_TEMPLATE) self._tilt_template = config.get(CONF_TILT_TEMPLATE) - self._device_class = config.get(CONF_DEVICE_CLASS) + self._device_class: CoverDeviceClass | None = config.get(CONF_DEVICE_CLASS) self._open_script = None if (open_action := config.get(OPEN_ACTION)) is not None: self._open_script = Script(hass, open_action, friendly_name, DOMAIN) @@ -270,22 +271,22 @@ class CoverTemplate(TemplateEntity, CoverEntity): self._tilt_value = state @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed.""" return self._position == 0 @property - def is_opening(self): + def is_opening(self) -> bool: """Return if the cover is currently opening.""" return self._is_opening @property - def is_closing(self): + def is_closing(self) -> bool: """Return if the cover is currently closing.""" return self._is_closing @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """Return current position of cover. None is unknown, 0 is closed, 100 is fully open. @@ -295,7 +296,7 @@ class CoverTemplate(TemplateEntity, CoverEntity): return None @property - def current_cover_tilt_position(self): + def current_cover_tilt_position(self) -> int | None: """Return current position of cover tilt. None is unknown, 0 is closed, 100 is fully open. @@ -303,12 +304,12 @@ class CoverTemplate(TemplateEntity, CoverEntity): return self._tilt_value @property - def device_class(self): + def device_class(self) -> CoverDeviceClass | None: """Return the device class of the cover.""" return self._device_class @property - def supported_features(self): + def supported_features(self) -> int: """Flag supported features.""" supported_features = CoverEntityFeature.OPEN | CoverEntityFeature.CLOSE diff --git a/homeassistant/components/velux/cover.py b/homeassistant/components/velux/cover.py index 1c8a4afcc6f..f721a628ef8 100644 --- a/homeassistant/components/velux/cover.py +++ b/homeassistant/components/velux/cover.py @@ -40,7 +40,7 @@ class VeluxCover(VeluxEntity, CoverEntity): """Representation of a Velux cover.""" @property - def supported_features(self): + def supported_features(self) -> int: """Flag supported features.""" supported_features = ( CoverEntityFeature.OPEN @@ -58,19 +58,19 @@ class VeluxCover(VeluxEntity, CoverEntity): return supported_features @property - def current_cover_position(self): + def current_cover_position(self) -> int: """Return the current position of the cover.""" return 100 - self.node.position.position_percent @property - def current_cover_tilt_position(self): + def current_cover_tilt_position(self) -> int | None: """Return the current position of the cover.""" if isinstance(self.node, Blind): return 100 - self.node.orientation.position_percent return None @property - def device_class(self): + def device_class(self) -> CoverDeviceClass: """Define this cover as either awning, blind, garage, gate, shutter or window.""" if isinstance(self.node, Awning): return CoverDeviceClass.AWNING @@ -87,7 +87,7 @@ class VeluxCover(VeluxEntity, CoverEntity): return CoverDeviceClass.WINDOW @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed.""" return self.node.position.closed diff --git a/homeassistant/components/xiaomi_aqara/cover.py b/homeassistant/components/xiaomi_aqara/cover.py index e9946e37815..b6de7189d83 100644 --- a/homeassistant/components/xiaomi_aqara/cover.py +++ b/homeassistant/components/xiaomi_aqara/cover.py @@ -46,12 +46,12 @@ class XiaomiGenericCover(XiaomiDevice, CoverEntity): super().__init__(device, name, xiaomi_hub, config_entry) @property - def current_cover_position(self): + def current_cover_position(self) -> int: """Return the current position of the cover.""" return self._pos @property - def is_closed(self): + def is_closed(self) -> bool: """Return if the cover is closed.""" return self.current_cover_position <= 0 diff --git a/homeassistant/components/zha/cover.py b/homeassistant/components/zha/cover.py index 39f76b6b77f..6ade62343b1 100644 --- a/homeassistant/components/zha/cover.py +++ b/homeassistant/components/zha/cover.py @@ -92,24 +92,24 @@ class ZhaCover(ZhaEntity, CoverEntity): self._current_position = last_state.attributes["current_position"] @property - def is_closed(self): + def is_closed(self) -> bool | None: """Return if the cover is closed.""" if self.current_cover_position is None: return None return self.current_cover_position == 0 @property - def is_opening(self): + def is_opening(self) -> bool: """Return if the cover is opening or not.""" return self._state == STATE_OPENING @property - def is_closing(self): + def is_closing(self) -> bool: """Return if the cover is closing or not.""" return self._state == STATE_CLOSING @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """Return the current position of ZHA cover. None is unknown, 0 is closed, 100 is fully open. @@ -207,7 +207,7 @@ class Shade(ZhaEntity, CoverEntity): self._is_open: bool | None = None @property - def current_cover_position(self): + def current_cover_position(self) -> int | None: """Return current position of cover. None is unknown, 0 is closed, 100 is fully open.