diff --git a/homeassistant/components/daikin/climate.py b/homeassistant/components/daikin/climate.py index 1b84b182ac8..271449a01cd 100644 --- a/homeassistant/components/daikin/climate.py +++ b/homeassistant/components/daikin/climate.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any import voluptuous as vol @@ -177,7 +178,7 @@ class DaikinClimate(ClimateEntity): return self._api.device.mac @property - def temperature_unit(self): + def temperature_unit(self) -> str: """Return the unit of measurement which this thermostat uses.""" return TEMP_CELSIUS @@ -196,7 +197,7 @@ class DaikinClimate(ClimateEntity): """Return the supported step of target temperature.""" return 1 - async def async_set_temperature(self, **kwargs): + async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" await self._set(kwargs) @@ -232,7 +233,7 @@ class DaikinClimate(ClimateEntity): """Return the fan setting.""" return self._api.device.represent(HA_ATTR_TO_DAIKIN[ATTR_FAN_MODE])[1].title() - async def async_set_fan_mode(self, fan_mode): + async def async_set_fan_mode(self, fan_mode: str) -> None: """Set fan mode.""" await self._set({ATTR_FAN_MODE: fan_mode}) @@ -246,7 +247,7 @@ class DaikinClimate(ClimateEntity): """Return the fan setting.""" return self._api.device.represent(HA_ATTR_TO_DAIKIN[ATTR_SWING_MODE])[1].title() - async def async_set_swing_mode(self, swing_mode): + async def async_set_swing_mode(self, swing_mode: str) -> None: """Set new target temperature.""" await self._set({ATTR_SWING_MODE: swing_mode}) @@ -275,7 +276,7 @@ class DaikinClimate(ClimateEntity): return PRESET_ECO return PRESET_NONE - async def async_set_preset_mode(self, preset_mode): + async def async_set_preset_mode(self, preset_mode: str) -> None: """Set preset mode.""" if preset_mode == PRESET_AWAY: await self._api.device.set_holiday(ATTR_STATE_ON) @@ -309,15 +310,15 @@ class DaikinClimate(ClimateEntity): ret += [PRESET_ECO, PRESET_BOOST] return ret - async def async_update(self): + async def async_update(self) -> None: """Retrieve latest state.""" await self._api.async_update() - async def async_turn_on(self): + async def async_turn_on(self) -> None: """Turn device on.""" await self._api.device.set({}) - async def async_turn_off(self): + async def async_turn_off(self) -> None: """Turn device off.""" await self._api.device.set( {HA_ATTR_TO_DAIKIN[ATTR_HVAC_MODE]: HA_STATE_TO_DAIKIN[HVACMode.OFF]} diff --git a/homeassistant/components/daikin/sensor.py b/homeassistant/components/daikin/sensor.py index 1843bdac25f..1adacd322cc 100644 --- a/homeassistant/components/daikin/sensor.py +++ b/homeassistant/components/daikin/sensor.py @@ -21,6 +21,7 @@ from homeassistant.const import ( TEMP_CELSIUS, ) from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType @@ -181,7 +182,7 @@ class DaikinSensor(SensorEntity): self._attr_name = f"{api.name} {description.name}" @property - def unique_id(self): + def unique_id(self) -> str: """Return a unique ID.""" return f"{self._api.device.mac}-{self.entity_description.key}" @@ -190,11 +191,11 @@ class DaikinSensor(SensorEntity): """Return the state of the sensor.""" return self.entity_description.value_func(self._api.device) - async def async_update(self): + async def async_update(self) -> None: """Retrieve latest state.""" await self._api.async_update() @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return a device description for device registry.""" return self._api.device_info diff --git a/homeassistant/components/daikin/switch.py b/homeassistant/components/daikin/switch.py index d5601a38989..0f885e63bf7 100644 --- a/homeassistant/components/daikin/switch.py +++ b/homeassistant/components/daikin/switch.py @@ -1,13 +1,16 @@ """Support for Daikin AirBase zones.""" from __future__ import annotations +from typing import Any + from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType -from . import DOMAIN as DAIKIN_DOMAIN +from . import DOMAIN as DAIKIN_DOMAIN, DaikinApi ZONE_ICON = "mdi:home-circle" STREAMER_ICON = "mdi:air-filter" @@ -32,7 +35,7 @@ async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback ) -> None: """Set up Daikin climate based on config_entry.""" - daikin_api = hass.data[DAIKIN_DOMAIN][entry.entry_id] + daikin_api: DaikinApi = hass.data[DAIKIN_DOMAIN][entry.entry_id] switches: list[DaikinZoneSwitch | DaikinStreamerSwitch] = [] if zones := daikin_api.device.zones: switches.extend( @@ -54,13 +57,13 @@ async def async_setup_entry( class DaikinZoneSwitch(SwitchEntity): """Representation of a zone.""" - def __init__(self, daikin_api, zone_id): + def __init__(self, daikin_api: DaikinApi, zone_id): """Initialize the zone.""" self._api = daikin_api self._zone_id = zone_id @property - def unique_id(self): + def unique_id(self) -> str: """Return a unique ID.""" return f"{self._api.device.mac}-zone{self._zone_id}" @@ -70,29 +73,29 @@ class DaikinZoneSwitch(SwitchEntity): return ZONE_ICON @property - def name(self): + def name(self) -> str: """Return the name of the sensor.""" return f"{self._api.name} {self._api.device.zones[self._zone_id][0]}" @property - def is_on(self): + def is_on(self) -> bool: """Return the state of the sensor.""" return self._api.device.zones[self._zone_id][1] == "1" @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return a device description for device registry.""" return self._api.device_info - async def async_update(self): + async def async_update(self) -> None: """Retrieve latest state.""" await self._api.async_update() - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the zone on.""" await self._api.device.set_zone(self._zone_id, "1") - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the zone off.""" await self._api.device.set_zone(self._zone_id, "0") @@ -100,12 +103,12 @@ class DaikinZoneSwitch(SwitchEntity): class DaikinStreamerSwitch(SwitchEntity): """Streamer state.""" - def __init__(self, daikin_api): + def __init__(self, daikin_api: DaikinApi) -> None: """Initialize streamer switch.""" self._api = daikin_api @property - def unique_id(self): + def unique_id(self) -> str: """Return a unique ID.""" return f"{self._api.device.mac}-streamer" @@ -115,30 +118,30 @@ class DaikinStreamerSwitch(SwitchEntity): return STREAMER_ICON @property - def name(self): + def name(self) -> str: """Return the name of the sensor.""" return f"{self._api.name} streamer" @property - def is_on(self): + def is_on(self) -> bool: """Return the state of the sensor.""" return ( DAIKIN_ATTR_STREAMER in self._api.device.represent(DAIKIN_ATTR_ADVANCED)[1] ) @property - def device_info(self): + def device_info(self) -> DeviceInfo: """Return a device description for device registry.""" return self._api.device_info - async def async_update(self): + async def async_update(self) -> None: """Retrieve latest state.""" await self._api.async_update() - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the zone on.""" await self._api.device.set_streamer("on") - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the zone off.""" await self._api.device.set_streamer("off") diff --git a/homeassistant/components/danfoss_air/binary_sensor.py b/homeassistant/components/danfoss_air/binary_sensor.py index b01e51e5061..3764345a7b8 100644 --- a/homeassistant/components/danfoss_air/binary_sensor.py +++ b/homeassistant/components/danfoss_air/binary_sensor.py @@ -50,7 +50,7 @@ class DanfossAirBinarySensor(BinarySensorEntity): self._type = sensor_type self._attr_device_class = device_class - def update(self): + def update(self) -> None: """Fetch new state data for the sensor.""" self._data.update() diff --git a/homeassistant/components/danfoss_air/sensor.py b/homeassistant/components/danfoss_air/sensor.py index d85e8248e60..de736b2c599 100644 --- a/homeassistant/components/danfoss_air/sensor.py +++ b/homeassistant/components/danfoss_air/sensor.py @@ -119,7 +119,7 @@ class DanfossAir(SensorEntity): self._attr_device_class = device_class self._attr_state_class = state_class - def update(self): + def update(self) -> None: """Update the new state of the sensor. This is done through the DanfossAir object that does the actual diff --git a/homeassistant/components/danfoss_air/switch.py b/homeassistant/components/danfoss_air/switch.py index b2e7189550f..b1ee7dce44a 100644 --- a/homeassistant/components/danfoss_air/switch.py +++ b/homeassistant/components/danfoss_air/switch.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from pydanfossair.commands import ReadCommand, UpdateCommand @@ -75,17 +76,17 @@ class DanfossAir(SwitchEntity): """Return true if switch is on.""" return self._state - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" _LOGGER.debug("Turning on switch with command %s", self._on_command) self._data.update_state(self._on_command, self._state_command) - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" _LOGGER.debug("Turning off switch with command %s", self._off_command) self._data.update_state(self._off_command, self._state_command) - def update(self): + def update(self) -> None: """Update the switch's state.""" self._data.update() diff --git a/homeassistant/components/darksky/sensor.py b/homeassistant/components/darksky/sensor.py index 0686f304674..84a0b0f23f2 100644 --- a/homeassistant/components/darksky/sensor.py +++ b/homeassistant/components/darksky/sensor.py @@ -825,7 +825,7 @@ class DarkSkyAlertSensor(SensorEntity): """Return the state attributes.""" return self._alerts - def update(self): + def update(self) -> None: """Get the latest data from Dark Sky and updates the states.""" # Call the API for new forecast data. Each sensor will re-trigger this # same exact call, but that's fine. We cache results for a short period diff --git a/homeassistant/components/darksky/weather.py b/homeassistant/components/darksky/weather.py index 1bc56706007..88f3b6b2bc9 100644 --- a/homeassistant/components/darksky/weather.py +++ b/homeassistant/components/darksky/weather.py @@ -131,7 +131,7 @@ class DarkSkyWeather(WeatherEntity): self._ds_daily = None @property - def available(self): + def available(self) -> bool: """Return if weather data is available from Dark Sky.""" return self._ds_data is not None @@ -233,7 +233,7 @@ class DarkSkyWeather(WeatherEntity): return data - def update(self): + def update(self) -> None: """Get the latest data from Dark Sky.""" self._dark_sky.update() diff --git a/homeassistant/components/delijn/sensor.py b/homeassistant/components/delijn/sensor.py index ee58a4f21c7..f0a263d0d0f 100644 --- a/homeassistant/components/delijn/sensor.py +++ b/homeassistant/components/delijn/sensor.py @@ -92,7 +92,7 @@ class DeLijnPublicTransportSensor(SensorEntity): self.line = line self._attr_extra_state_attributes = {} - async def async_update(self): + async def async_update(self) -> None: """Get the latest data from the De Lijn API.""" try: await self.line.get_passages() diff --git a/homeassistant/components/demo/media_player.py b/homeassistant/components/demo/media_player.py index f3046a6f807..e52bf8720e1 100644 --- a/homeassistant/components/demo/media_player.py +++ b/homeassistant/components/demo/media_player.py @@ -1,6 +1,8 @@ """Demo implementation of the media player.""" from __future__ import annotations +from typing import Any + from homeassistant.components.media_player import ( MediaPlayerDeviceClass, MediaPlayerEntity, @@ -164,57 +166,57 @@ class AbstractDemoPlayer(MediaPlayerEntity): """Return the device class of the media player.""" return self._device_class - def turn_on(self): + def turn_on(self) -> None: """Turn the media player on.""" self._player_state = STATE_PLAYING self.schedule_update_ha_state() - def turn_off(self): + def turn_off(self) -> None: """Turn the media player off.""" self._player_state = STATE_OFF self.schedule_update_ha_state() - def mute_volume(self, mute): + def mute_volume(self, mute: bool) -> None: """Mute the volume.""" self._volume_muted = mute self.schedule_update_ha_state() - def volume_up(self): + def volume_up(self) -> None: """Increase volume.""" self._volume_level = min(1.0, self._volume_level + 0.1) self.schedule_update_ha_state() - def volume_down(self): + def volume_down(self) -> None: """Decrease volume.""" self._volume_level = max(0.0, self._volume_level - 0.1) self.schedule_update_ha_state() - def set_volume_level(self, volume): + def set_volume_level(self, volume: float) -> None: """Set the volume level, range 0..1.""" self._volume_level = volume self.schedule_update_ha_state() - def media_play(self): + def media_play(self) -> None: """Send play command.""" self._player_state = STATE_PLAYING self.schedule_update_ha_state() - def media_pause(self): + def media_pause(self) -> None: """Send pause command.""" self._player_state = STATE_PAUSED self.schedule_update_ha_state() - def media_stop(self): + def media_stop(self) -> None: """Send stop command.""" self._player_state = STATE_OFF self.schedule_update_ha_state() - def set_shuffle(self, shuffle): + def set_shuffle(self, shuffle: bool) -> None: """Enable/disable shuffle mode.""" self._shuffle = shuffle self.schedule_update_ha_state() - def select_sound_mode(self, sound_mode): + def select_sound_mode(self, sound_mode: str) -> None: """Select sound mode.""" self._sound_mode = sound_mode self.schedule_update_ha_state() @@ -291,12 +293,12 @@ class DemoYoutubePlayer(AbstractDemoPlayer): if self._player_state == STATE_PLAYING: return self._progress_updated_at - def play_media(self, media_type, media_id, **kwargs): + def play_media(self, media_type: str, media_id: str, **kwargs: Any) -> None: """Play a piece of media.""" self.youtube_id = media_id self.schedule_update_ha_state() - def media_pause(self): + def media_pause(self) -> None: """Send pause command.""" self._progress = self.media_position self._progress_updated_at = dt_util.utcnow() @@ -393,38 +395,38 @@ class DemoMusicPlayer(AbstractDemoPlayer): """Flag media player features that are supported.""" return MUSIC_PLAYER_SUPPORT - def media_previous_track(self): + def media_previous_track(self) -> None: """Send previous track command.""" if self._cur_track > 0: self._cur_track -= 1 self.schedule_update_ha_state() - def media_next_track(self): + def media_next_track(self) -> None: """Send next track command.""" if self._cur_track < len(self.tracks) - 1: self._cur_track += 1 self.schedule_update_ha_state() - def clear_playlist(self): + def clear_playlist(self) -> None: """Clear players playlist.""" self.tracks = [] self._cur_track = 0 self._player_state = STATE_OFF self.schedule_update_ha_state() - def set_repeat(self, repeat): + def set_repeat(self, repeat: str) -> None: """Enable/disable repeat mode.""" self._repeat = repeat self.schedule_update_ha_state() - def join_players(self, group_members): + def join_players(self, group_members: list[str]) -> None: """Join `group_members` as a player group with the current player.""" self._group_members = [ self.entity_id, ] + group_members self.schedule_update_ha_state() - def unjoin_player(self): + def unjoin_player(self) -> None: """Remove this player from any group.""" self._group_members = [] self.schedule_update_ha_state() @@ -505,19 +507,19 @@ class DemoTVShowPlayer(AbstractDemoPlayer): """Flag media player features that are supported.""" return NETFLIX_PLAYER_SUPPORT - def media_previous_track(self): + def media_previous_track(self) -> None: """Send previous track command.""" if self._cur_episode > 1: self._cur_episode -= 1 self.schedule_update_ha_state() - def media_next_track(self): + def media_next_track(self) -> None: """Send next track command.""" if self._cur_episode < self._episode_count: self._cur_episode += 1 self.schedule_update_ha_state() - def select_source(self, source): + def select_source(self, source: str) -> None: """Set the input source.""" self._source = source self.schedule_update_ha_state() diff --git a/homeassistant/components/demo/vacuum.py b/homeassistant/components/demo/vacuum.py index 58b76ba6347..10952f86785 100644 --- a/homeassistant/components/demo/vacuum.py +++ b/homeassistant/components/demo/vacuum.py @@ -240,7 +240,12 @@ class DemoVacuum(VacuumEntity): self._battery_level += 5 self.schedule_update_ha_state() - def send_command(self, command, params=None, **kwargs: Any) -> None: + def send_command( + self, + command: str, + params: dict[str, Any] | list[Any] | None = None, + **kwargs: Any, + ) -> None: """Send a command to the vacuum.""" if self.supported_features & VacuumEntityFeature.SEND_COMMAND == 0: return diff --git a/homeassistant/components/demo/water_heater.py b/homeassistant/components/demo/water_heater.py index 70332277d90..c3cb2be4fb3 100644 --- a/homeassistant/components/demo/water_heater.py +++ b/homeassistant/components/demo/water_heater.py @@ -1,6 +1,8 @@ """Demo platform that offers a fake water heater device.""" from __future__ import annotations +from typing import Any + from homeassistant.components.water_heater import ( WaterHeaterEntity, WaterHeaterEntityFeature, @@ -79,22 +81,22 @@ class DemoWaterHeater(WaterHeaterEntity): "off", ] - def set_temperature(self, **kwargs): + def set_temperature(self, **kwargs: Any) -> None: """Set new target temperatures.""" self._attr_target_temperature = kwargs.get(ATTR_TEMPERATURE) self.schedule_update_ha_state() - def set_operation_mode(self, operation_mode): + def set_operation_mode(self, operation_mode: str) -> None: """Set new operation mode.""" self._attr_current_operation = operation_mode self.schedule_update_ha_state() - def turn_away_mode_on(self): + def turn_away_mode_on(self) -> None: """Turn away mode on.""" self._attr_is_away_mode_on = True self.schedule_update_ha_state() - def turn_away_mode_off(self): + def turn_away_mode_off(self) -> None: """Turn away mode off.""" self._attr_is_away_mode_on = False self.schedule_update_ha_state() diff --git a/homeassistant/components/denon/media_player.py b/homeassistant/components/denon/media_player.py index d55adcf5db7..4533af66927 100644 --- a/homeassistant/components/denon/media_player.py +++ b/homeassistant/components/denon/media_player.py @@ -253,51 +253,51 @@ class DenonDevice(MediaPlayerEntity): if self._mediasource == name: return pretty_name - def turn_off(self): + def turn_off(self) -> None: """Turn off media player.""" self.telnet_command("PWSTANDBY") - def volume_up(self): + def volume_up(self) -> None: """Volume up media player.""" self.telnet_command("MVUP") - def volume_down(self): + def volume_down(self) -> None: """Volume down media player.""" self.telnet_command("MVDOWN") - def set_volume_level(self, volume): + def set_volume_level(self, volume: float) -> None: """Set volume level, range 0..1.""" self.telnet_command(f"MV{round(volume * self._volume_max):02}") - def mute_volume(self, mute): + def mute_volume(self, mute: bool) -> None: """Mute (true) or unmute (false) media player.""" mute_status = "ON" if mute else "OFF" self.telnet_command(f"MU{mute_status})") - def media_play(self): + def media_play(self) -> None: """Play media player.""" self.telnet_command("NS9A") - def media_pause(self): + def media_pause(self) -> None: """Pause media player.""" self.telnet_command("NS9B") - def media_stop(self): + def media_stop(self) -> None: """Pause media player.""" self.telnet_command("NS9C") - def media_next_track(self): + def media_next_track(self) -> None: """Send the next track command.""" self.telnet_command("NS9D") - def media_previous_track(self): + def media_previous_track(self) -> None: """Send the previous track command.""" self.telnet_command("NS9E") - def turn_on(self): + def turn_on(self) -> None: """Turn the media player on.""" self.telnet_command("PWON") - def select_source(self, source): + def select_source(self, source: str) -> None: """Select input source.""" self.telnet_command(f"SI{self._source_list.get(source)}") diff --git a/homeassistant/components/denonavr/media_player.py b/homeassistant/components/denonavr/media_player.py index 7c5d98ca1b3..bc3b4264d24 100644 --- a/homeassistant/components/denonavr/media_player.py +++ b/homeassistant/components/denonavr/media_player.py @@ -390,32 +390,32 @@ class DenonDevice(MediaPlayerEntity): return self._receiver.dynamic_eq @async_log_errors - async def async_media_play_pause(self): + async def async_media_play_pause(self) -> None: """Play or pause the media player.""" await self._receiver.async_toggle_play_pause() @async_log_errors - async def async_media_play(self): + async def async_media_play(self) -> None: """Send play command.""" await self._receiver.async_play() @async_log_errors - async def async_media_pause(self): + async def async_media_pause(self) -> None: """Send pause command.""" await self._receiver.async_pause() @async_log_errors - async def async_media_previous_track(self): + async def async_media_previous_track(self) -> None: """Send previous track command.""" await self._receiver.async_previous_track() @async_log_errors - async def async_media_next_track(self): + async def async_media_next_track(self) -> None: """Send next track command.""" await self._receiver.async_next_track() @async_log_errors - async def async_select_source(self, source: str): + async def async_select_source(self, source: str) -> None: """Select input source.""" # Ensure that the AVR is turned on, which is necessary for input # switch to work. @@ -423,27 +423,27 @@ class DenonDevice(MediaPlayerEntity): await self._receiver.async_set_input_func(source) @async_log_errors - async def async_select_sound_mode(self, sound_mode: str): + async def async_select_sound_mode(self, sound_mode: str) -> None: """Select sound mode.""" await self._receiver.async_set_sound_mode(sound_mode) @async_log_errors - async def async_turn_on(self): + async def async_turn_on(self) -> None: """Turn on media player.""" await self._receiver.async_power_on() @async_log_errors - async def async_turn_off(self): + async def async_turn_off(self) -> None: """Turn off media player.""" await self._receiver.async_power_off() @async_log_errors - async def async_volume_up(self): + async def async_volume_up(self) -> None: """Volume up the media player.""" await self._receiver.async_volume_up() @async_log_errors - async def async_volume_down(self): + async def async_volume_down(self) -> None: """Volume down media player.""" await self._receiver.async_volume_down() @@ -458,7 +458,7 @@ class DenonDevice(MediaPlayerEntity): await self._receiver.async_set_volume(volume_denon) @async_log_errors - async def async_mute_volume(self, mute: bool): + async def async_mute_volume(self, mute: bool) -> None: """Send mute command.""" await self._receiver.async_mute(mute) diff --git a/homeassistant/components/derivative/sensor.py b/homeassistant/components/derivative/sensor.py index fb5bf7e518d..5337328bbe2 100644 --- a/homeassistant/components/derivative/sensor.py +++ b/homeassistant/components/derivative/sensor.py @@ -168,7 +168,7 @@ class DerivativeSensor(RestoreEntity, SensorEntity): self._unit_time = UNIT_TIME[unit_time] self._time_window = time_window.total_seconds() - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Handle entity which will be added.""" await super().async_added_to_hass() if (state := await self.async_get_last_state()) is not None: diff --git a/homeassistant/components/deutsche_bahn/sensor.py b/homeassistant/components/deutsche_bahn/sensor.py index 07c330fd402..9638fccf2cd 100644 --- a/homeassistant/components/deutsche_bahn/sensor.py +++ b/homeassistant/components/deutsche_bahn/sensor.py @@ -98,7 +98,7 @@ class DeutscheBahnSensor(SensorEntity): connections["next_on"] = self.data.connections[2]["departure"] return connections - def update(self): + def update(self) -> None: """Get the latest delay from bahn.de and updates the state.""" self.data.update() self._state = self.data.connections[0].get("departure", "Unknown") diff --git a/homeassistant/components/devolo_home_control/climate.py b/homeassistant/components/devolo_home_control/climate.py index cde7ca33152..4b8e8fc00e6 100644 --- a/homeassistant/components/devolo_home_control/climate.py +++ b/homeassistant/components/devolo_home_control/climate.py @@ -88,7 +88,7 @@ class DevoloClimateDeviceEntity(DevoloMultiLevelSwitchDeviceEntity, ClimateEntit """Return the target temperature.""" return self._value - def set_hvac_mode(self, hvac_mode: str) -> None: + def set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Do nothing as devolo devices do not support changing the hvac mode.""" def set_temperature(self, **kwargs: Any) -> None: diff --git a/homeassistant/components/digital_ocean/binary_sensor.py b/homeassistant/components/digital_ocean/binary_sensor.py index b92e009e618..9728da99a6f 100644 --- a/homeassistant/components/digital_ocean/binary_sensor.py +++ b/homeassistant/components/digital_ocean/binary_sensor.py @@ -102,7 +102,7 @@ class DigitalOceanBinarySensor(BinarySensorEntity): ATTR_VCPUS: self.data.vcpus, } - def update(self): + def update(self) -> None: """Update state of sensor.""" self._digital_ocean.update() diff --git a/homeassistant/components/digital_ocean/switch.py b/homeassistant/components/digital_ocean/switch.py index efaa4fec6be..da955e221a3 100644 --- a/homeassistant/components/digital_ocean/switch.py +++ b/homeassistant/components/digital_ocean/switch.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any import voluptuous as vol @@ -94,17 +95,17 @@ class DigitalOceanSwitch(SwitchEntity): ATTR_VCPUS: self.data.vcpus, } - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Boot-up the droplet.""" if self.data.status != "active": self.data.power_on() - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Shutdown the droplet.""" if self.data.status == "active": self.data.power_off() - def update(self): + def update(self) -> None: """Get the latest data from the device and update the data.""" self._digital_ocean.update() diff --git a/homeassistant/components/directv/media_player.py b/homeassistant/components/directv/media_player.py index 2fb5acf8295..affefcacd85 100644 --- a/homeassistant/components/directv/media_player.py +++ b/homeassistant/components/directv/media_player.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from directv import DIRECTV @@ -278,7 +279,7 @@ class DIRECTVMediaPlayer(DIRECTVEntity, MediaPlayerEntity): return dt_util.as_local(self._program.start_time) - async def async_turn_on(self): + async def async_turn_on(self) -> None: """Turn on the receiver.""" if self._is_client: raise NotImplementedError() @@ -286,7 +287,7 @@ class DIRECTVMediaPlayer(DIRECTVEntity, MediaPlayerEntity): _LOGGER.debug("Turn on %s", self.name) await self.dtv.remote("poweron", self._address) - async def async_turn_off(self): + async def async_turn_off(self) -> None: """Turn off the receiver.""" if self._is_client: raise NotImplementedError() @@ -294,32 +295,34 @@ class DIRECTVMediaPlayer(DIRECTVEntity, MediaPlayerEntity): _LOGGER.debug("Turn off %s", self.name) await self.dtv.remote("poweroff", self._address) - async def async_media_play(self): + async def async_media_play(self) -> None: """Send play command.""" _LOGGER.debug("Play on %s", self.name) await self.dtv.remote("play", self._address) - async def async_media_pause(self): + async def async_media_pause(self) -> None: """Send pause command.""" _LOGGER.debug("Pause on %s", self.name) await self.dtv.remote("pause", self._address) - async def async_media_stop(self): + async def async_media_stop(self) -> None: """Send stop command.""" _LOGGER.debug("Stop on %s", self.name) await self.dtv.remote("stop", self._address) - async def async_media_previous_track(self): + async def async_media_previous_track(self) -> None: """Send rewind command.""" _LOGGER.debug("Rewind on %s", self.name) await self.dtv.remote("rew", self._address) - async def async_media_next_track(self): + async def async_media_next_track(self) -> None: """Send fast forward command.""" _LOGGER.debug("Fast forward on %s", self.name) await self.dtv.remote("ffwd", self._address) - 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: """Select input source.""" if media_type != MEDIA_TYPE_CHANNEL: _LOGGER.error( diff --git a/homeassistant/components/discogs/sensor.py b/homeassistant/components/discogs/sensor.py index 447eb4a754e..e207755ec24 100644 --- a/homeassistant/components/discogs/sensor.py +++ b/homeassistant/components/discogs/sensor.py @@ -157,7 +157,7 @@ class DiscogsSensor(SensorEntity): return None - def update(self): + def update(self) -> None: """Set state to the amount of records in user's collection.""" if self.entity_description.key == SENSOR_COLLECTION_TYPE: self._attr_native_value = self._discogs_data["collection_count"] diff --git a/homeassistant/components/dlink/switch.py b/homeassistant/components/dlink/switch.py index 4d5d7b5c639..f1ca99c51f2 100644 --- a/homeassistant/components/dlink/switch.py +++ b/homeassistant/components/dlink/switch.py @@ -3,6 +3,7 @@ from __future__ import annotations from datetime import timedelta import logging +from typing import Any import urllib from pyW215.pyW215 import SmartPlug @@ -106,15 +107,15 @@ class SmartPlugSwitch(SwitchEntity): """Return true if switch is on.""" return self.data.state == "ON" - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" self.data.smartplug.state = "ON" - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" self.data.smartplug.state = "OFF" - def update(self): + def update(self) -> None: """Get the latest data from the smart plug and updates the states.""" self.data.update() diff --git a/homeassistant/components/dlna_dmr/media_player.py b/homeassistant/components/dlna_dmr/media_player.py index 9ecf9f8ad40..156e8fdffef 100644 --- a/homeassistant/components/dlna_dmr/media_player.py +++ b/homeassistant/components/dlna_dmr/media_player.py @@ -578,7 +578,7 @@ class DlnaDmrEntity(MediaPlayerEntity): await self._device.async_stop() @catch_request_errors - async def async_media_seek(self, position: int | float) -> None: + async def async_media_seek(self, position: float) -> None: """Send seek command.""" assert self._device is not None time = timedelta(seconds=position) diff --git a/homeassistant/components/doorbird/camera.py b/homeassistant/components/doorbird/camera.py index 77dc8a2d45c..fce76a65ff5 100644 --- a/homeassistant/components/doorbird/camera.py +++ b/homeassistant/components/doorbird/camera.py @@ -134,7 +134,7 @@ class DoorBirdCamera(DoorBirdEntity, Camera): ) return self._last_image - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Add callback after being added to hass. Registers entity_id map for the logbook diff --git a/homeassistant/components/dovado/sensor.py b/homeassistant/components/dovado/sensor.py index 99b1bd459fe..ee23592ef2d 100644 --- a/homeassistant/components/dovado/sensor.py +++ b/homeassistant/components/dovado/sensor.py @@ -133,7 +133,7 @@ class DovadoSensor(SensorEntity): return round(float(state) / 1e6, 1) return state - def update(self): + def update(self) -> None: """Update sensor values.""" self._data.update() self._attr_native_value = self._compute_state() diff --git a/homeassistant/components/dsmr_reader/sensor.py b/homeassistant/components/dsmr_reader/sensor.py index 3dac30dcf6c..603b5682f42 100644 --- a/homeassistant/components/dsmr_reader/sensor.py +++ b/homeassistant/components/dsmr_reader/sensor.py @@ -35,7 +35,7 @@ class DSMRSensor(SensorEntity): slug = slugify(description.key.replace("/", "_")) self.entity_id = f"sensor.{slug}" - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Subscribe to MQTT events.""" @callback diff --git a/homeassistant/components/dte_energy_bridge/sensor.py b/homeassistant/components/dte_energy_bridge/sensor.py index 7f85710206d..b97a8eb83eb 100644 --- a/homeassistant/components/dte_energy_bridge/sensor.py +++ b/homeassistant/components/dte_energy_bridge/sensor.py @@ -71,7 +71,7 @@ class DteEnergyBridgeSensor(SensorEntity): self._attr_name = name - def update(self): + def update(self) -> None: """Get the energy usage data from the DTE energy bridge.""" try: response = requests.get(self._url, timeout=5) diff --git a/homeassistant/components/dublin_bus_transport/sensor.py b/homeassistant/components/dublin_bus_transport/sensor.py index e6ee4d92de9..cf65c18e91c 100644 --- a/homeassistant/components/dublin_bus_transport/sensor.py +++ b/homeassistant/components/dublin_bus_transport/sensor.py @@ -125,7 +125,7 @@ class DublinPublicTransportSensor(SensorEntity): """Icon to use in the frontend, if any.""" return ICON - def update(self): + def update(self) -> None: """Get the latest data from opendata.ch and update the states.""" self.data.update() self._times = self.data.info diff --git a/homeassistant/components/dwd_weather_warnings/sensor.py b/homeassistant/components/dwd_weather_warnings/sensor.py index 941e1ee9017..1436b416031 100644 --- a/homeassistant/components/dwd_weather_warnings/sensor.py +++ b/homeassistant/components/dwd_weather_warnings/sensor.py @@ -164,11 +164,11 @@ class DwdWeatherWarningsSensor(SensorEntity): return data @property - def available(self): + def available(self) -> bool: """Could the device be accessed during the last update call.""" return self._api.api.data_valid - def update(self): + def update(self) -> None: """Get the latest data from the DWD-Weather-Warnings API.""" _LOGGER.debug( "Update requested for %s (%s) by %s", diff --git a/homeassistant/components/dweet/sensor.py b/homeassistant/components/dweet/sensor.py index fd5b64e206a..8a1b5a1bc6c 100644 --- a/homeassistant/components/dweet/sensor.py +++ b/homeassistant/components/dweet/sensor.py @@ -92,7 +92,7 @@ class DweetSensor(SensorEntity): """Return the state.""" return self._state - def update(self): + def update(self) -> None: """Get the latest data from REST API.""" self.dweet.update() diff --git a/homeassistant/components/dynalite/switch.py b/homeassistant/components/dynalite/switch.py index c98a1ce0ec4..3e459e45847 100644 --- a/homeassistant/components/dynalite/switch.py +++ b/homeassistant/components/dynalite/switch.py @@ -1,5 +1,7 @@ """Support for the Dynalite channels and presets as switches.""" +from typing import Any + from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant @@ -27,10 +29,10 @@ class DynaliteSwitch(DynaliteBase, SwitchEntity): """Return true if switch is on.""" return self._device.is_on - async def async_turn_on(self, **kwargs) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" await self._device.async_turn_on() - async def async_turn_off(self, **kwargs) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" await self._device.async_turn_off()