diff --git a/homeassistant/components/xbox/media_player.py b/homeassistant/components/xbox/media_player.py index ae361d6806e..8209136fa23 100644 --- a/homeassistant/components/xbox/media_player.py +++ b/homeassistant/components/xbox/media_player.py @@ -2,6 +2,7 @@ from __future__ import annotations import re +from typing import Any from xbox.webapi.api.client import XboxLiveClient from xbox.webapi.api.provider.catalog.models import Image @@ -154,42 +155,42 @@ class XboxMediaPlayer(CoordinatorEntity[XboxUpdateCoordinator], MediaPlayerEntit """If the image url is remotely accessible.""" return True - async def async_turn_on(self): + async def async_turn_on(self) -> None: """Turn the media player on.""" await self.client.smartglass.wake_up(self._console.id) - async def async_turn_off(self): + async def async_turn_off(self) -> None: """Turn the media player off.""" await self.client.smartglass.turn_off(self._console.id) - async def async_mute_volume(self, mute): + async def async_mute_volume(self, mute: bool) -> None: """Mute the volume.""" if mute: await self.client.smartglass.mute(self._console.id) else: await self.client.smartglass.unmute(self._console.id) - async def async_volume_up(self): + async def async_volume_up(self) -> None: """Turn volume up for media player.""" await self.client.smartglass.volume(self._console.id, VolumeDirection.Up) - async def async_volume_down(self): + async def async_volume_down(self) -> None: """Turn volume down for media player.""" await self.client.smartglass.volume(self._console.id, VolumeDirection.Down) - async def async_media_play(self): + async def async_media_play(self) -> None: """Send play command.""" await self.client.smartglass.play(self._console.id) - async def async_media_pause(self): + async def async_media_pause(self) -> None: """Send pause command.""" await self.client.smartglass.pause(self._console.id) - async def async_media_previous_track(self): + async def async_media_previous_track(self) -> None: """Send previous track command.""" await self.client.smartglass.previous(self._console.id) - async def async_media_next_track(self): + async def async_media_next_track(self) -> None: """Send next track command.""" await self.client.smartglass.next(self._console.id) @@ -203,7 +204,9 @@ class XboxMediaPlayer(CoordinatorEntity[XboxUpdateCoordinator], MediaPlayerEntit media_content_id, ) - async def async_play_media(self, media_type, media_id, **kwargs): + async def async_play_media( + self, media_type: str, media_id: str, **kwargs: Any + ) -> None: """Launch an app on the Xbox.""" if media_id == "Home": await self.client.smartglass.go_home(self._console.id) diff --git a/homeassistant/components/xbox_live/sensor.py b/homeassistant/components/xbox_live/sensor.py index b1500e6cedc..3081f334821 100644 --- a/homeassistant/components/xbox_live/sensor.py +++ b/homeassistant/components/xbox_live/sensor.py @@ -128,7 +128,7 @@ class XboxSensor(SensorEntity): """Return the icon to use in the frontend.""" return ICON - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Start custom polling.""" @callback @@ -138,7 +138,7 @@ class XboxSensor(SensorEntity): async_track_time_interval(self.hass, async_update, self._interval) - def update(self): + def update(self) -> None: """Update state data from Xbox API.""" presence = self._api.gamer(gamertag="", xuid=self._xuid).get("presence") _LOGGER.debug("User presence: %s", presence) diff --git a/homeassistant/components/xiaomi_aqara/binary_sensor.py b/homeassistant/components/xiaomi_aqara/binary_sensor.py index 44c17b634cb..9ed79bc8250 100644 --- a/homeassistant/components/xiaomi_aqara/binary_sensor.py +++ b/homeassistant/components/xiaomi_aqara/binary_sensor.py @@ -153,7 +153,7 @@ class XiaomiBinarySensor(XiaomiDevice, BinarySensorEntity): """Return the class of binary sensor.""" return self._device_class - def update(self): + def update(self) -> None: """Update the sensor state.""" _LOGGER.debug("Updating xiaomi sensor (%s) by polling", self._sid) self._get_from_hub(self._sid) diff --git a/homeassistant/components/xiaomi_aqara/switch.py b/homeassistant/components/xiaomi_aqara/switch.py index 39bf637256f..0ea6a65f68e 100644 --- a/homeassistant/components/xiaomi_aqara/switch.py +++ b/homeassistant/components/xiaomi_aqara/switch.py @@ -1,5 +1,6 @@ """Support for Xiaomi Aqara binary sensors.""" import logging +from typing import Any from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry @@ -179,13 +180,13 @@ class XiaomiGenericSwitch(XiaomiDevice, SwitchEntity): attrs.update(super().extra_state_attributes) return attrs - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" if self._write_to_hub(self._sid, **{self._data_key: "on"}): self._state = True self.schedule_update_ha_state() - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" if self._write_to_hub(self._sid, **{self._data_key: "off"}): self._state = False @@ -216,7 +217,7 @@ class XiaomiGenericSwitch(XiaomiDevice, SwitchEntity): self._state = state return True - def update(self): + def update(self) -> None: """Get data from hub.""" _LOGGER.debug("Update data from hub: %s", self._name) self._get_from_hub(self._sid) diff --git a/homeassistant/components/xiaomi_miio/light.py b/homeassistant/components/xiaomi_miio/light.py index 2a7fce01442..49554311b91 100644 --- a/homeassistant/components/xiaomi_miio/light.py +++ b/homeassistant/components/xiaomi_miio/light.py @@ -1018,7 +1018,7 @@ class XiaomiGatewayLight(LightEntity): self._gateway.light.set_rgb(0, self._rgb) self.schedule_update_ha_state() - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" try: state_dict = await self.hass.async_add_executor_job( diff --git a/homeassistant/components/xiaomi_miio/remote.py b/homeassistant/components/xiaomi_miio/remote.py index 39a9c984a8c..ffae02a2ee4 100644 --- a/homeassistant/components/xiaomi_miio/remote.py +++ b/homeassistant/components/xiaomi_miio/remote.py @@ -5,6 +5,7 @@ import asyncio from datetime import timedelta import logging import time +from typing import Any from miio import ChuangmiIr, DeviceException import voluptuous as vol @@ -227,14 +228,14 @@ class XiaomiMiioRemote(RemoteEntity): except DeviceException: return False - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" _LOGGER.error( "Device does not support turn_on, " "please use 'remote.send_command' to send commands" ) - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the device off.""" _LOGGER.error( "Device does not support turn_off, " diff --git a/homeassistant/components/xiaomi_miio/sensor.py b/homeassistant/components/xiaomi_miio/sensor.py index 819d95f208c..472339a4103 100644 --- a/homeassistant/components/xiaomi_miio/sensor.py +++ b/homeassistant/components/xiaomi_miio/sensor.py @@ -892,7 +892,7 @@ class XiaomiAirQualityMonitor(XiaomiMiioEntity, SensorEntity): """Return the state attributes of the device.""" return self._state_attrs - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the miio device.""" try: state = await self.hass.async_add_executor_job(self._device.status) @@ -958,7 +958,7 @@ class XiaomiGatewayIlluminanceSensor(SensorEntity): """Return the state of the device.""" return self._state - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" try: self._state = await self.hass.async_add_executor_job( diff --git a/homeassistant/components/xiaomi_miio/switch.py b/homeassistant/components/xiaomi_miio/switch.py index 577f9af837f..dbe783c6a87 100644 --- a/homeassistant/components/xiaomi_miio/switch.py +++ b/homeassistant/components/xiaomi_miio/switch.py @@ -5,6 +5,7 @@ import asyncio from dataclasses import dataclass from functools import partial import logging +from typing import Any from miio import AirConditioningCompanionV3, ChuangmiPlug, DeviceException, PowerStrip from miio.powerstrip import PowerMode @@ -527,7 +528,7 @@ class XiaomiGenericCoordinatedSwitch(XiaomiCoordinatedMiioEntity, SwitchEntity): self.async_write_ha_state() @property - def available(self): + def available(self) -> bool: """Return true when state is known.""" if ( super().available @@ -537,7 +538,7 @@ class XiaomiGenericCoordinatedSwitch(XiaomiCoordinatedMiioEntity, SwitchEntity): return False return super().available - async def async_turn_on(self, **kwargs) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn on an option of the miio device.""" method = getattr(self, self.entity_description.method_on) if await method(): @@ -545,7 +546,7 @@ class XiaomiGenericCoordinatedSwitch(XiaomiCoordinatedMiioEntity, SwitchEntity): self._attr_is_on = True self.async_write_ha_state() - async def async_turn_off(self, **kwargs) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn off an option of the miio device.""" method = getattr(self, self.entity_description.method_off) if await method(): @@ -748,15 +749,15 @@ class XiaomiGatewaySwitch(XiaomiGatewayDevice, SwitchEntity): """Return true if switch is on.""" return self._sub_device.status[self._data_key] == "on" - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" await self.hass.async_add_executor_job(self._sub_device.on, self._channel) - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" await self.hass.async_add_executor_job(self._sub_device.off, self._channel) - async def async_toggle(self, **kwargs): + async def async_toggle(self, **kwargs: Any) -> None: """Toggle the switch.""" await self.hass.async_add_executor_job(self._sub_device.toggle, self._channel) @@ -816,7 +817,7 @@ class XiaomiPlugGenericSwitch(XiaomiMiioEntity, SwitchEntity): return False - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the plug on.""" result = await self._try_command("Turning the plug on failed", self._device.on) @@ -824,7 +825,7 @@ class XiaomiPlugGenericSwitch(XiaomiMiioEntity, SwitchEntity): self._state = True self._skip_update = True - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the plug off.""" result = await self._try_command( "Turning the plug off failed", self._device.off @@ -834,7 +835,7 @@ class XiaomiPlugGenericSwitch(XiaomiMiioEntity, SwitchEntity): self._state = False self._skip_update = True - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" # On state change the device doesn't provide the new state immediately. if self._skip_update: @@ -907,7 +908,7 @@ class XiaomiPowerStripSwitch(XiaomiPlugGenericSwitch): if self._device_features & FEATURE_SET_POWER_PRICE == 1: self._state_attrs[ATTR_POWER_PRICE] = None - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" # On state change the device doesn't provide the new state immediately. if self._skip_update: @@ -972,7 +973,7 @@ class ChuangMiPlugSwitch(XiaomiPlugGenericSwitch): if self._channel_usb is False: self._state_attrs[ATTR_LOAD_POWER] = None - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn a channel on.""" if self._channel_usb: result = await self._try_command( @@ -987,7 +988,7 @@ class ChuangMiPlugSwitch(XiaomiPlugGenericSwitch): self._state = True self._skip_update = True - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn a channel off.""" if self._channel_usb: result = await self._try_command( @@ -1002,7 +1003,7 @@ class ChuangMiPlugSwitch(XiaomiPlugGenericSwitch): self._state = False self._skip_update = True - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" # On state change the device doesn't provide the new state immediately. if self._skip_update: @@ -1042,7 +1043,7 @@ class XiaomiAirConditioningCompanionSwitch(XiaomiPlugGenericSwitch): self._state_attrs.update({ATTR_TEMPERATURE: None, ATTR_LOAD_POWER: None}) - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the socket on.""" result = await self._try_command( "Turning the socket on failed", self._device.socket_on @@ -1052,7 +1053,7 @@ class XiaomiAirConditioningCompanionSwitch(XiaomiPlugGenericSwitch): self._state = True self._skip_update = True - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the socket off.""" result = await self._try_command( "Turning the socket off failed", self._device.socket_off @@ -1062,7 +1063,7 @@ class XiaomiAirConditioningCompanionSwitch(XiaomiPlugGenericSwitch): self._state = False self._skip_update = True - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" # On state change the device doesn't provide the new state immediately. if self._skip_update: diff --git a/homeassistant/components/xiaomi_miio/vacuum.py b/homeassistant/components/xiaomi_miio/vacuum.py index 7df38109d16..19c38ac0a82 100644 --- a/homeassistant/components/xiaomi_miio/vacuum.py +++ b/homeassistant/components/xiaomi_miio/vacuum.py @@ -329,7 +329,10 @@ class MiroboVacuum( await self._try_command("Unable to locate the botvac: %s", self._device.find) async def async_send_command( - self, command: str, params: dict | list | None = None, **kwargs: Any + self, + command: str, + params: dict[str, Any] | list[Any] | None = None, + **kwargs: Any, ) -> None: """Send raw command.""" await self._try_command( diff --git a/homeassistant/components/xiaomi_tv/media_player.py b/homeassistant/components/xiaomi_tv/media_player.py index a808d1e3b8e..df174b6b0f0 100644 --- a/homeassistant/components/xiaomi_tv/media_player.py +++ b/homeassistant/components/xiaomi_tv/media_player.py @@ -87,7 +87,7 @@ class XiaomiTV(MediaPlayerEntity): """Indicate that state is assumed.""" return True - def turn_off(self): + def turn_off(self) -> None: """ Instruct the TV to turn sleep. @@ -100,17 +100,17 @@ class XiaomiTV(MediaPlayerEntity): self._state = STATE_OFF - def turn_on(self): + def turn_on(self) -> None: """Wake the TV back up from sleep.""" if self._state != STATE_ON: self._tv.wake() self._state = STATE_ON - def volume_up(self): + def volume_up(self) -> None: """Increase volume by one.""" self._tv.volume_up() - def volume_down(self): + def volume_down(self) -> None: """Decrease volume by one.""" self._tv.volume_down() diff --git a/homeassistant/components/xs1/climate.py b/homeassistant/components/xs1/climate.py index bf2ab898112..f74950437df 100644 --- a/homeassistant/components/xs1/climate.py +++ b/homeassistant/components/xs1/climate.py @@ -1,6 +1,8 @@ """Support for XS1 climate devices.""" from __future__ import annotations +from typing import Any + from xs1_api_client.api_constants import ActuatorType from homeassistant.components.climate import ClimateEntity @@ -69,7 +71,7 @@ class XS1ThermostatEntity(XS1DeviceEntity, ClimateEntity): return self.sensor.value() @property - def temperature_unit(self): + def temperature_unit(self) -> str: """Return the unit of measurement used by the platform.""" return self.device.unit() @@ -88,7 +90,7 @@ class XS1ThermostatEntity(XS1DeviceEntity, ClimateEntity): """Return the maximum temperature.""" return MAX_TEMP - def set_temperature(self, **kwargs): + def set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" temp = kwargs.get(ATTR_TEMPERATURE) @@ -100,7 +102,7 @@ class XS1ThermostatEntity(XS1DeviceEntity, ClimateEntity): def set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target hvac mode.""" - async def async_update(self): + async def async_update(self) -> None: """Also update the sensor when available.""" await super().async_update() if self.sensor is not None: diff --git a/homeassistant/components/xs1/switch.py b/homeassistant/components/xs1/switch.py index 0f40678986b..0b231a0303c 100644 --- a/homeassistant/components/xs1/switch.py +++ b/homeassistant/components/xs1/switch.py @@ -1,6 +1,8 @@ """Support for XS1 switches.""" from __future__ import annotations +from typing import Any + from xs1_api_client.api_constants import ActuatorType from homeassistant.components.switch import SwitchEntity @@ -43,10 +45,10 @@ class XS1SwitchEntity(XS1DeviceEntity, SwitchEntity): """Return true if switch is on.""" return self.device.value() == 100 - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" self.device.turn_on() - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the device off.""" self.device.turn_off()