From 0c767bd0d37a41af37728b1d8b4eae8dceb7e188 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Tue, 6 Sep 2022 13:35:14 +0200 Subject: [PATCH] Improve entity type hints [s] (part 1/2) (#77881) --- homeassistant/components/sabnzbd/sensor.py | 2 +- .../components/satel_integra/binary_sensor.py | 2 +- .../components/satel_integra/switch.py | 7 ++--- homeassistant/components/schluter/climate.py | 3 ++- .../components/screenlogic/climate.py | 7 ++--- homeassistant/components/scsgate/switch.py | 5 ++-- .../components/sense/binary_sensor.py | 2 +- homeassistant/components/sense/sensor.py | 6 ++--- homeassistant/components/serial/sensor.py | 2 +- homeassistant/components/serial_pm/sensor.py | 2 +- .../components/seventeentrack/sensor.py | 6 ++--- homeassistant/components/sigfox/sensor.py | 2 +- homeassistant/components/simulated/sensor.py | 2 +- .../components/sisyphus/media_player.py | 26 +++++++++---------- .../components/slimproto/media_player.py | 7 +++-- .../components/smappee/binary_sensor.py | 4 +-- homeassistant/components/smappee/sensor.py | 2 +- homeassistant/components/smappee/switch.py | 10 ++++--- .../components/smartthings/climate.py | 17 ++++++------ .../components/smartthings/switch.py | 5 ++-- homeassistant/components/smarttub/climate.py | 8 +++--- homeassistant/components/smarttub/switch.py | 8 +++--- .../components/snapcast/media_player.py | 12 ++++----- homeassistant/components/snmp/sensor.py | 2 +- homeassistant/components/snmp/switch.py | 7 ++--- 25 files changed, 86 insertions(+), 70 deletions(-) diff --git a/homeassistant/components/sabnzbd/sensor.py b/homeassistant/components/sabnzbd/sensor.py index b2828a30969..b4231a469ec 100644 --- a/homeassistant/components/sabnzbd/sensor.py +++ b/homeassistant/components/sabnzbd/sensor.py @@ -167,7 +167,7 @@ class SabnzbdSensor(SensorEntity): name=DEFAULT_NAME, ) - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Call when entity about to be added to hass.""" self.async_on_remove( async_dispatcher_connect( diff --git a/homeassistant/components/satel_integra/binary_sensor.py b/homeassistant/components/satel_integra/binary_sensor.py index f55545239fb..389bde884ef 100644 --- a/homeassistant/components/satel_integra/binary_sensor.py +++ b/homeassistant/components/satel_integra/binary_sensor.py @@ -73,7 +73,7 @@ class SatelIntegraBinarySensor(BinarySensorEntity): self._react_to_signal = react_to_signal self._satel = controller - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Register callbacks.""" if self._react_to_signal == SIGNAL_OUTPUTS_UPDATED: if self._device_number in self._satel.violated_outputs: diff --git a/homeassistant/components/satel_integra/switch.py b/homeassistant/components/satel_integra/switch.py index 7c7b91c4ac6..469b2280290 100644 --- a/homeassistant/components/satel_integra/switch.py +++ b/homeassistant/components/satel_integra/switch.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from homeassistant.components.switch import SwitchEntity from homeassistant.core import HomeAssistant, callback @@ -61,7 +62,7 @@ class SatelIntegraSwitch(SwitchEntity): self._code = code self._satel = controller - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Register callbacks.""" async_dispatcher_connect( self.hass, SIGNAL_OUTPUTS_UPDATED, self._devices_updated @@ -78,13 +79,13 @@ class SatelIntegraSwitch(SwitchEntity): self._state = new_state self.async_write_ha_state() - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" _LOGGER.debug("Switch: %s status: %s, turning on", self._name, self._state) await self._satel.set_output(self._code, self._device_number, True) self.async_write_ha_state() - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the device off.""" _LOGGER.debug( "Switch name: %s status: %s, turning off", self._name, self._state diff --git a/homeassistant/components/schluter/climate.py b/homeassistant/components/schluter/climate.py index 3ccea458960..dd4f578cebb 100644 --- a/homeassistant/components/schluter/climate.py +++ b/homeassistant/components/schluter/climate.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from requests import RequestException import voluptuous as vol @@ -131,7 +132,7 @@ class SchluterThermostat(CoordinatorEntity, ClimateEntity): async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Mode is always heating, so do nothing.""" - def set_temperature(self, **kwargs): + def set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" target_temp = None target_temp = kwargs.get(ATTR_TEMPERATURE) diff --git a/homeassistant/components/screenlogic/climate.py b/homeassistant/components/screenlogic/climate.py index adc103fa684..b5e83ec827a 100644 --- a/homeassistant/components/screenlogic/climate.py +++ b/homeassistant/components/screenlogic/climate.py @@ -1,5 +1,6 @@ """Support for a ScreenLogic heating device.""" import logging +from typing import Any from screenlogicpy.const import DATA as SL_DATA, EQUIPMENT, HEAT_MODE @@ -130,7 +131,7 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity): HEAT_MODE.NAME_FOR_NUM[mode_num] for mode_num in self._configured_heat_modes ] - async def async_set_temperature(self, **kwargs) -> None: + async def async_set_temperature(self, **kwargs: Any) -> None: """Change the setpoint of the heater.""" if (temperature := kwargs.get(ATTR_TEMPERATURE)) is None: raise ValueError(f"Expected attribute {ATTR_TEMPERATURE}") @@ -144,7 +145,7 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity): f"Failed to set_temperature {temperature} on body {self.body['body_type']['value']}" ) - async def async_set_hvac_mode(self, hvac_mode) -> None: + async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set the operation mode.""" if hvac_mode == HVACMode.OFF: mode = HEAT_MODE.OFF @@ -172,7 +173,7 @@ class ScreenLogicClimate(ScreenlogicEntity, ClimateEntity, RestoreEntity): f"Failed to set_preset_mode {mode} on body {self.body['body_type']['value']}" ) - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Run when entity is about to be added.""" await super().async_added_to_hass() diff --git a/homeassistant/components/scsgate/switch.py b/homeassistant/components/scsgate/switch.py index b9c25207745..3f215130048 100644 --- a/homeassistant/components/scsgate/switch.py +++ b/homeassistant/components/scsgate/switch.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from scsgate.messages import ScenarioTriggeredMessage, StateMessage from scsgate.tasks import ToggleStatusTask @@ -116,7 +117,7 @@ class SCSGateSwitch(SwitchEntity): """Return true if switch is on.""" return self._toggled - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" self._scsgate.append_task(ToggleStatusTask(target=self._scs_id, toggled=True)) @@ -124,7 +125,7 @@ class SCSGateSwitch(SwitchEntity): self._toggled = True self.schedule_update_ha_state() - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the device off.""" self._scsgate.append_task(ToggleStatusTask(target=self._scs_id, toggled=False)) diff --git a/homeassistant/components/sense/binary_sensor.py b/homeassistant/components/sense/binary_sensor.py index b9c1a3cb9eb..0d4fbcf1de2 100644 --- a/homeassistant/components/sense/binary_sensor.py +++ b/homeassistant/components/sense/binary_sensor.py @@ -126,7 +126,7 @@ class SenseDevice(BinarySensorEntity): """Return the device class of the binary sensor.""" return BinarySensorDeviceClass.POWER - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Register callbacks.""" self.async_on_remove( async_dispatcher_connect( diff --git a/homeassistant/components/sense/sensor.py b/homeassistant/components/sense/sensor.py index 8362f47f090..54f05e2dbb5 100644 --- a/homeassistant/components/sense/sensor.py +++ b/homeassistant/components/sense/sensor.py @@ -182,7 +182,7 @@ class SenseActiveSensor(SensorEntity): self._variant_id = variant_id self._variant_name = variant_name - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Register callbacks.""" self.async_on_remove( async_dispatcher_connect( @@ -230,7 +230,7 @@ class SenseVoltageSensor(SensorEntity): self._sense_monitor_id = sense_monitor_id self._voltage_index = index - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Register callbacks.""" self.async_on_remove( async_dispatcher_connect( @@ -323,7 +323,7 @@ class SenseEnergyDevice(SensorEntity): self._attr_icon = sense_to_mdi(device["icon"]) self._sense_devices_data = sense_devices_data - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Register callbacks.""" self.async_on_remove( async_dispatcher_connect( diff --git a/homeassistant/components/serial/sensor.py b/homeassistant/components/serial/sensor.py index 9f1e04f1373..63253375cc7 100644 --- a/homeassistant/components/serial/sensor.py +++ b/homeassistant/components/serial/sensor.py @@ -143,7 +143,7 @@ class SerialSensor(SensorEntity): self._template = value_template self._attributes = None - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Handle when an entity is about to be added to Home Assistant.""" self._serial_loop_task = self.hass.loop.create_task( self.serial_read( diff --git a/homeassistant/components/serial_pm/sensor.py b/homeassistant/components/serial_pm/sensor.py index 2f34b1e3aca..2c94b9bcf01 100644 --- a/homeassistant/components/serial_pm/sensor.py +++ b/homeassistant/components/serial_pm/sensor.py @@ -90,7 +90,7 @@ class ParticulateMatterSensor(SensorEntity): """Return the unit of measurement of this entity, if any.""" return CONCENTRATION_MICROGRAMS_PER_CUBIC_METER - def update(self): + def update(self) -> None: """Read from sensor and update the state.""" _LOGGER.debug("Reading data from PM sensor") try: diff --git a/homeassistant/components/seventeentrack/sensor.py b/homeassistant/components/seventeentrack/sensor.py index 12cdcc0680c..363eb507710 100644 --- a/homeassistant/components/seventeentrack/sensor.py +++ b/homeassistant/components/seventeentrack/sensor.py @@ -134,7 +134,7 @@ class SeventeenTrackSummarySensor(SensorEntity): """Return the state.""" return self._state - async def async_update(self): + async def async_update(self) -> None: """Update the sensor.""" await self._data.async_update() @@ -189,7 +189,7 @@ class SeventeenTrackPackageSensor(SensorEntity): ) @property - def available(self): + def available(self) -> bool: """Return whether the entity is available.""" return self._data.packages.get(self._tracking_number) is not None @@ -205,7 +205,7 @@ class SeventeenTrackPackageSensor(SensorEntity): """Return the state.""" return self._state - async def async_update(self): + async def async_update(self) -> None: """Update the sensor.""" await self._data.async_update() diff --git a/homeassistant/components/sigfox/sensor.py b/homeassistant/components/sigfox/sensor.py index 392bfeead89..1a1d7bb74b0 100644 --- a/homeassistant/components/sigfox/sensor.py +++ b/homeassistant/components/sigfox/sensor.py @@ -149,7 +149,7 @@ class SigfoxDevice(SensorEntity): "time": epoch_to_datetime(epoch_time), } - def update(self): + def update(self) -> None: """Fetch the latest device message.""" self._message_data = self.get_last_message() self._state = self._message_data["payload"] diff --git a/homeassistant/components/simulated/sensor.py b/homeassistant/components/simulated/sensor.py index ddd5d99ac97..f2e64655acc 100644 --- a/homeassistant/components/simulated/sensor.py +++ b/homeassistant/components/simulated/sensor.py @@ -121,7 +121,7 @@ class SimulatedSensor(SensorEntity): noise = self._random.gauss(mu=0, sigma=fwhm) return round(mean + periodic + noise, 3) - async def async_update(self): + async def async_update(self) -> None: """Update the sensor.""" self._state = self.signal_calc() diff --git a/homeassistant/components/sisyphus/media_player.py b/homeassistant/components/sisyphus/media_player.py index 208799361fe..ddd9da23e98 100644 --- a/homeassistant/components/sisyphus/media_player.py +++ b/homeassistant/components/sisyphus/media_player.py @@ -65,11 +65,11 @@ class SisyphusPlayer(MediaPlayerEntity): self._host = host self._table = table - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Add listeners after this object has been initialized.""" self._table.add_listener(self.async_write_ha_state) - async def async_update(self): + async def async_update(self) -> None: """Force update table state.""" await self._table.refresh() @@ -79,7 +79,7 @@ class SisyphusPlayer(MediaPlayerEntity): return self._table.id @property - def available(self): + def available(self) -> bool: """Return true if the table is responding to heartbeats.""" return self._table.is_connected @@ -113,7 +113,7 @@ class SisyphusPlayer(MediaPlayerEntity): """Return True if the current playlist is in shuffle mode.""" return self._table.is_shuffle - async def async_set_shuffle(self, shuffle): + async def async_set_shuffle(self, shuffle: bool) -> None: """Change the shuffle mode of the current playlist.""" await self._table.set_shuffle(shuffle) @@ -164,35 +164,35 @@ class SisyphusPlayer(MediaPlayerEntity): return super().media_image_url - async def async_turn_on(self): + async def async_turn_on(self) -> None: """Wake up a sleeping table.""" await self._table.wakeup() - async def async_turn_off(self): + async def async_turn_off(self) -> None: """Put the table to sleep.""" await self._table.sleep() - async def async_volume_down(self): + async def async_volume_down(self) -> None: """Slow down playback.""" await self._table.set_speed(max(0, self._table.speed - 0.1)) - async def async_volume_up(self): + async def async_volume_up(self) -> None: """Speed up playback.""" await self._table.set_speed(min(1.0, self._table.speed + 0.1)) - async def async_set_volume_level(self, volume): + async def async_set_volume_level(self, volume: float) -> None: """Set playback speed (0..1).""" await self._table.set_speed(volume) - async def async_media_play(self): + async def async_media_play(self) -> None: """Start playing.""" await self._table.play() - async def async_media_pause(self): + async def async_media_pause(self) -> None: """Pause.""" await self._table.pause() - async def async_media_next_track(self): + async def async_media_next_track(self) -> None: """Skip to next track.""" cur_track_index = self._get_current_track_index() @@ -200,7 +200,7 @@ class SisyphusPlayer(MediaPlayerEntity): self._table.active_playlist.tracks[cur_track_index + 1] ) - async def async_media_previous_track(self): + async def async_media_previous_track(self) -> None: """Skip to previous track.""" cur_track_index = self._get_current_track_index() diff --git a/homeassistant/components/slimproto/media_player.py b/homeassistant/components/slimproto/media_player.py index bcd538f57e8..a241cd2cd93 100644 --- a/homeassistant/components/slimproto/media_player.py +++ b/homeassistant/components/slimproto/media_player.py @@ -2,6 +2,7 @@ from __future__ import annotations import asyncio +from typing import Any from aioslimproto.client import PlayerState, SlimClient from aioslimproto.const import EventType, SlimEvent @@ -175,7 +176,9 @@ class SlimProtoPlayer(MediaPlayerEntity): """Turn off device.""" await self.player.power(False) - async def async_play_media(self, media_type: str, media_id: str, **kwargs) -> None: + async def async_play_media( + self, media_type: str, media_id: str, **kwargs: Any + ) -> None: """Send the play_media command to the media player.""" to_send_media_type: str | None = media_type # Handle media_source @@ -193,7 +196,7 @@ class SlimProtoPlayer(MediaPlayerEntity): await self.player.play_url(media_id, mime_type=to_send_media_type) async def async_browse_media( - self, media_content_type=None, media_content_id=None + self, media_content_type: str | None = None, media_content_id: str | None = None ) -> BrowseMedia: """Implement the websocket media browsing helper.""" return await media_source.async_browse_media( diff --git a/homeassistant/components/smappee/binary_sensor.py b/homeassistant/components/smappee/binary_sensor.py index 1d7f00f5f4e..88d46e3689d 100644 --- a/homeassistant/components/smappee/binary_sensor.py +++ b/homeassistant/components/smappee/binary_sensor.py @@ -91,7 +91,7 @@ class SmappeePresence(BinarySensorEntity): sw_version=self._service_location.firmware_version, ) - async def async_update(self): + async def async_update(self) -> None: """Get the latest data from Smappee and update the state.""" await self._smappee_base.async_update() @@ -174,7 +174,7 @@ class SmappeeAppliance(BinarySensorEntity): sw_version=self._service_location.firmware_version, ) - async def async_update(self): + async def async_update(self) -> None: """Get the latest data from Smappee and update the state.""" await self._smappee_base.async_update() diff --git a/homeassistant/components/smappee/sensor.py b/homeassistant/components/smappee/sensor.py index b82d84f2c15..ff258677b3e 100644 --- a/homeassistant/components/smappee/sensor.py +++ b/homeassistant/components/smappee/sensor.py @@ -388,7 +388,7 @@ class SmappeeSensor(SensorEntity): sw_version=self._service_location.firmware_version, ) - async def async_update(self): + async def async_update(self) -> None: """Get the latest data from Smappee and update the state.""" await self._smappee_base.async_update() diff --git a/homeassistant/components/smappee/switch.py b/homeassistant/components/smappee/switch.py index e445b8e955b..b179daaf1a8 100644 --- a/homeassistant/components/smappee/switch.py +++ b/homeassistant/components/smappee/switch.py @@ -1,4 +1,6 @@ """Support for interacting with Smappee Comport Plugs, Switches and Output Modules.""" +from typing import Any + from homeassistant.components.switch import SwitchEntity from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant @@ -108,7 +110,7 @@ class SmappeeActuator(SwitchEntity): """Icon to use in the frontend.""" return ICON - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn on Comport Plug.""" if self._actuator_type in ("SWITCH", "COMFORT_PLUG"): self._service_location.set_actuator_state(self._actuator_id, state="ON_ON") @@ -117,7 +119,7 @@ class SmappeeActuator(SwitchEntity): self._actuator_id, state=self._actuator_state_option ) - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn off Comport Plug.""" if self._actuator_type in ("SWITCH", "COMFORT_PLUG"): self._service_location.set_actuator_state( @@ -129,7 +131,7 @@ class SmappeeActuator(SwitchEntity): ) @property - def available(self): + def available(self) -> bool: """Return True if entity is available. Unavailable for COMFORT_PLUGS.""" return ( self._connection_state == "CONNECTED" @@ -166,7 +168,7 @@ class SmappeeActuator(SwitchEntity): sw_version=self._service_location.firmware_version, ) - async def async_update(self): + async def async_update(self) -> None: """Get the latest data from Smappee and update the state.""" await self._smappee_base.async_update() diff --git a/homeassistant/components/smartthings/climate.py b/homeassistant/components/smartthings/climate.py index db13b5e6b37..7f628b8d8a0 100644 --- a/homeassistant/components/smartthings/climate.py +++ b/homeassistant/components/smartthings/climate.py @@ -4,6 +4,7 @@ from __future__ import annotations import asyncio from collections.abc import Iterable, Sequence import logging +from typing import Any from pysmartthings import Attribute, Capability @@ -160,7 +161,7 @@ class SmartThingsThermostat(SmartThingsEntity, ClimateEntity): flags |= ClimateEntityFeature.FAN_MODE return flags - async def async_set_fan_mode(self, fan_mode): + async def async_set_fan_mode(self, fan_mode: str) -> None: """Set new target fan mode.""" await self._device.set_thermostat_fan_mode(fan_mode, set_status=True) @@ -177,7 +178,7 @@ class SmartThingsThermostat(SmartThingsEntity, ClimateEntity): # the entity state ahead of receiving the confirming push updates self.async_schedule_update_ha_state(True) - async def async_set_temperature(self, **kwargs): + async def async_set_temperature(self, **kwargs: Any) -> None: """Set new operation mode and target temperatures.""" # Operation state if operation_state := kwargs.get(ATTR_HVAC_MODE): @@ -214,7 +215,7 @@ class SmartThingsThermostat(SmartThingsEntity, ClimateEntity): # the entity state ahead of receiving the confirming push updates self.async_schedule_update_ha_state(True) - async def async_update(self): + async def async_update(self) -> None: """Update the attributes of the climate device.""" thermostat_mode = self._device.status.thermostat_mode self._hvac_mode = MODE_TO_STATE.get(thermostat_mode) @@ -326,7 +327,7 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity): super().__init__(device) self._hvac_modes = None - async def async_set_fan_mode(self, fan_mode): + async def async_set_fan_mode(self, fan_mode: str) -> None: """Set new target fan mode.""" await self._device.set_fan_mode(fan_mode, set_status=True) # State is set optimistically in the command above, therefore update @@ -352,7 +353,7 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity): # the entity state ahead of receiving the confirming push updates self.async_write_ha_state() - async def async_set_temperature(self, **kwargs): + async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" tasks = [] # operation mode @@ -372,21 +373,21 @@ class SmartThingsAirConditioner(SmartThingsEntity, ClimateEntity): # the entity state ahead of receiving the confirming push updates self.async_write_ha_state() - async def async_turn_on(self): + async def async_turn_on(self) -> None: """Turn device on.""" await self._device.switch_on(set_status=True) # State is set optimistically in the command above, therefore update # the entity state ahead of receiving the confirming push updates self.async_write_ha_state() - async def async_turn_off(self): + async def async_turn_off(self) -> None: """Turn device off.""" await self._device.switch_off(set_status=True) # State is set optimistically in the command above, therefore update # the entity state ahead of receiving the confirming push updates self.async_write_ha_state() - async def async_update(self): + async def async_update(self) -> None: """Update the calculated fields of the AC.""" modes = {HVACMode.OFF} for mode in self._device.status.supported_ac_modes: diff --git a/homeassistant/components/smartthings/switch.py b/homeassistant/components/smartthings/switch.py index f9df5dacdad..e6432dcb50c 100644 --- a/homeassistant/components/smartthings/switch.py +++ b/homeassistant/components/smartthings/switch.py @@ -2,6 +2,7 @@ from __future__ import annotations from collections.abc import Sequence +from typing import Any from pysmartthings import Capability @@ -41,14 +42,14 @@ def get_capabilities(capabilities: Sequence[str]) -> Sequence[str] | None: class SmartThingsSwitch(SmartThingsEntity, SwitchEntity): """Define a SmartThings switch.""" - async def async_turn_off(self, **kwargs) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the switch off.""" await self._device.switch_off(set_status=True) # State is set optimistically in the command above, therefore update # the entity state ahead of receiving the confirming push updates self.async_write_ha_state() - async def async_turn_on(self, **kwargs) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the switch on.""" await self._device.switch_on(set_status=True) # State is set optimistically in the command above, therefore update diff --git a/homeassistant/components/smarttub/climate.py b/homeassistant/components/smarttub/climate.py index 78d1d7b2495..a9ff8699008 100644 --- a/homeassistant/components/smarttub/climate.py +++ b/homeassistant/components/smarttub/climate.py @@ -1,6 +1,8 @@ """Platform for climate integration.""" from __future__ import annotations +from typing import Any + from smarttub import Spa from homeassistant.components.climate import ClimateEntity @@ -72,7 +74,7 @@ class SmartTubThermostat(SmartTubEntity, ClimateEntity): """Return the current running hvac operation.""" return HVAC_ACTIONS.get(self.spa_status.heater) - async def async_set_hvac_mode(self, hvac_mode: HVACMode): + async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None: """Set new target hvac mode. As with hvac_mode, we don't really have an option here. @@ -113,13 +115,13 @@ class SmartTubThermostat(SmartTubEntity, ClimateEntity): """Return the target water temperature.""" return self.spa_status.set_temperature - async def async_set_temperature(self, **kwargs): + async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" temperature = kwargs[ATTR_TEMPERATURE] await self.spa.set_temperature(temperature) await self.coordinator.async_refresh() - async def async_set_preset_mode(self, preset_mode: str): + async def async_set_preset_mode(self, preset_mode: str) -> None: """Activate the specified preset mode.""" heat_mode = HEAT_MODES[preset_mode] await self.spa.set_heat_mode(heat_mode) diff --git a/homeassistant/components/smarttub/switch.py b/homeassistant/components/smarttub/switch.py index 9657444d9ad..b9afe94c06b 100644 --- a/homeassistant/components/smarttub/switch.py +++ b/homeassistant/components/smarttub/switch.py @@ -1,4 +1,6 @@ """Platform for switch integration.""" +from typing import Any + import async_timeout from smarttub import SpaPump @@ -62,21 +64,21 @@ class SmartTubPump(SmartTubEntity, SwitchEntity): """Return True if the pump is on.""" return self.pump.state != SpaPump.PumpState.OFF - async def async_turn_on(self, **kwargs) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the pump on.""" # the API only supports toggling if not self.is_on: await self.async_toggle() - async def async_turn_off(self, **kwargs) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the pump off.""" # the API only supports toggling if self.is_on: await self.async_toggle() - async def async_toggle(self, **kwargs) -> None: + async def async_toggle(self, **kwargs: Any) -> None: """Toggle the pump on or off.""" async with async_timeout.timeout(API_TIMEOUT): await self.pump.toggle() diff --git a/homeassistant/components/snapcast/media_player.py b/homeassistant/components/snapcast/media_player.py index 0e6524c8504..e7c4c9d8443 100644 --- a/homeassistant/components/snapcast/media_player.py +++ b/homeassistant/components/snapcast/media_player.py @@ -181,19 +181,19 @@ class SnapcastGroupDevice(MediaPlayerEntity): name = f"{self._group.friendly_name} {GROUP_SUFFIX}" return {"friendly_name": name} - async def async_select_source(self, source): + async def async_select_source(self, source: str) -> None: """Set input source.""" streams = self._group.streams_by_name() if source in streams: await self._group.set_stream(streams[source].identifier) self.async_write_ha_state() - async def async_mute_volume(self, mute): + async def async_mute_volume(self, mute: bool) -> None: """Send the mute command.""" await self._group.set_muted(mute) self.async_write_ha_state() - async def async_set_volume_level(self, volume): + async def async_set_volume_level(self, volume: float) -> None: """Set the volume level.""" await self._group.set_volume(round(volume * 100)) self.async_write_ha_state() @@ -292,19 +292,19 @@ class SnapcastClientDevice(MediaPlayerEntity): """Latency for Client.""" return self._client.latency - async def async_select_source(self, source): + async def async_select_source(self, source: str) -> None: """Set input source.""" streams = self._client.group.streams_by_name() if source in streams: await self._client.group.set_stream(streams[source].identifier) self.async_write_ha_state() - async def async_mute_volume(self, mute): + async def async_mute_volume(self, mute: bool) -> None: """Send the mute command.""" await self._client.set_muted(mute) self.async_write_ha_state() - async def async_set_volume_level(self, volume): + async def async_set_volume_level(self, volume: float) -> None: """Set the volume level.""" await self._client.set_volume(round(volume * 100)) self.async_write_ha_state() diff --git a/homeassistant/components/snmp/sensor.py b/homeassistant/components/snmp/sensor.py index 11f8c7d2f64..a582eef01fa 100644 --- a/homeassistant/components/snmp/sensor.py +++ b/homeassistant/components/snmp/sensor.py @@ -166,7 +166,7 @@ class SnmpSensor(TemplateSensor): """Return the state of the sensor.""" return self._state - async def async_update(self): + async def async_update(self) -> None: """Get the latest data and updates the states.""" await self.data.async_update() diff --git a/homeassistant/components/snmp/switch.py b/homeassistant/components/snmp/switch.py index b8370c4bba1..feb87e7e253 100644 --- a/homeassistant/components/snmp/switch.py +++ b/homeassistant/components/snmp/switch.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any import pysnmp.hlapi.asyncio as hlapi from pysnmp.hlapi.asyncio import ( @@ -235,12 +236,12 @@ class SnmpSwitch(SwitchEntity): ContextData(), ] - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn on the switch.""" # If vartype set, use it - http://snmplabs.com/pysnmp/docs/api-reference.html#pysnmp.smi.rfc1902.ObjectType await self._execute_command(self._command_payload_on) - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the switch.""" await self._execute_command(self._command_payload_off) @@ -256,7 +257,7 @@ class SnmpSwitch(SwitchEntity): else: await self._set(MAP_SNMP_VARTYPES.get(self._vartype, Integer)(command)) - async def async_update(self): + async def async_update(self) -> None: """Update the state.""" errindication, errstatus, errindex, restable = await getCmd( *self._request_args, ObjectType(ObjectIdentity(self._baseoid))