diff --git a/homeassistant/components/oasa_telematics/sensor.py b/homeassistant/components/oasa_telematics/sensor.py index 47bdd24d192..3cb624190e7 100644 --- a/homeassistant/components/oasa_telematics/sensor.py +++ b/homeassistant/components/oasa_telematics/sensor.py @@ -127,7 +127,7 @@ class OASATelematicsSensor(SensorEntity): """Icon to use in the frontend, if any.""" return ICON - def update(self): + def update(self) -> None: """Get the latest data from OASA API and update the states.""" self.data.update() self._times = self.data.info diff --git a/homeassistant/components/obihai/sensor.py b/homeassistant/components/obihai/sensor.py index 1b1dc339af1..cff4e6232e7 100644 --- a/homeassistant/components/obihai/sensor.py +++ b/homeassistant/components/obihai/sensor.py @@ -146,7 +146,7 @@ class ObihaiServiceSensors(SensorEntity): return "mdi:restart-alert" return "mdi:phone" - def update(self): + def update(self) -> None: """Update the sensor.""" services = self._pyobihai.get_state() diff --git a/homeassistant/components/oem/climate.py b/homeassistant/components/oem/climate.py index 298ae965e17..3f0110699eb 100644 --- a/homeassistant/components/oem/climate.py +++ b/homeassistant/components/oem/climate.py @@ -1,6 +1,8 @@ """OpenEnergyMonitor Thermostat Support.""" from __future__ import annotations +from typing import Any + from oemthermostat import Thermostat import requests import voluptuous as vol @@ -122,12 +124,12 @@ class ThermostatDevice(ClimateEntity): elif hvac_mode == HVACMode.OFF: self.thermostat.mode = 0 - def set_temperature(self, **kwargs): + def set_temperature(self, **kwargs: Any) -> None: """Set the temperature.""" temp = kwargs.get(ATTR_TEMPERATURE) self.thermostat.setpoint = temp - def update(self): + def update(self) -> None: """Update local state.""" self._setpoint = self.thermostat.setpoint self._temperature = self.thermostat.temperature diff --git a/homeassistant/components/ohmconnect/sensor.py b/homeassistant/components/ohmconnect/sensor.py index 09105984a31..3d9dbd78419 100644 --- a/homeassistant/components/ohmconnect/sensor.py +++ b/homeassistant/components/ohmconnect/sensor.py @@ -70,7 +70,7 @@ class OhmconnectSensor(SensorEntity): return {"Address": self._data.get("address"), "ID": self._ohmid} @Throttle(MIN_TIME_BETWEEN_UPDATES) - def update(self): + def update(self) -> None: """Get the latest data from OhmConnect.""" try: url = f"https://login.ohmconnect.com/verify-ohm-hour/{self._ohmid}" diff --git a/homeassistant/components/ombi/sensor.py b/homeassistant/components/ombi/sensor.py index 9152af0f1bf..90410ea8da2 100644 --- a/homeassistant/components/ombi/sensor.py +++ b/homeassistant/components/ombi/sensor.py @@ -45,7 +45,7 @@ class OmbiSensor(SensorEntity): self._attr_name = f"Ombi {description.name}" - def update(self): + def update(self) -> None: """Update the sensor.""" try: sensor_type = self.entity_description.key diff --git a/homeassistant/components/onkyo/media_player.py b/homeassistant/components/onkyo/media_player.py index 381f48b0b16..82f662e1bad 100644 --- a/homeassistant/components/onkyo/media_player.py +++ b/homeassistant/components/onkyo/media_player.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any import eiscp from eiscp import eISCP @@ -295,7 +296,7 @@ class OnkyoDevice(MediaPlayerEntity): _LOGGER.debug("Result for %s: %s", command, result) return result - def update(self): + def update(self) -> None: """Get the latest state from the device.""" status = self.command("system-power query") @@ -396,11 +397,11 @@ class OnkyoDevice(MediaPlayerEntity): """Return device specific state attributes.""" return self._attributes - def turn_off(self): + def turn_off(self) -> None: """Turn the media player off.""" self.command("system-power standby") - def set_volume_level(self, volume): + def set_volume_level(self, volume: float) -> None: """ Set volume level, input is range 0..1. @@ -414,32 +415,32 @@ class OnkyoDevice(MediaPlayerEntity): f"volume {int(volume * (self._max_volume / 100) * self._receiver_max_volume)}" ) - def volume_up(self): + def volume_up(self) -> None: """Increase volume by 1 step.""" self.command("volume level-up") - def volume_down(self): + def volume_down(self) -> None: """Decrease volume by 1 step.""" self.command("volume level-down") - def mute_volume(self, mute): + def mute_volume(self, mute: bool) -> None: """Mute (true) or unmute (false) media player.""" if mute: self.command("audio-muting on") else: self.command("audio-muting off") - def turn_on(self): + def turn_on(self) -> None: """Turn the media player on.""" self.command("system-power on") - def select_source(self, source): + def select_source(self, source: str) -> None: """Set the input source.""" if source in self._source_list: source = self._reverse_mapping[source] self.command(f"input-selector {source}") - def play_media(self, media_type, media_id, **kwargs): + def play_media(self, media_type: str, media_id: str, **kwargs: Any) -> None: """Play radio station by preset number.""" source = self._reverse_mapping[self._current_source] if media_type.lower() == "radio" and source in DEFAULT_PLAYABLE_SOURCES: @@ -506,7 +507,7 @@ class OnkyoDeviceZone(OnkyoDevice): self._supports_volume = True super().__init__(receiver, sources, name, max_volume, receiver_max_volume) - def update(self): + def update(self) -> None: """Get the latest state from the device.""" status = self.command(f"zone{self._zone}.power=query") @@ -563,11 +564,11 @@ class OnkyoDeviceZone(OnkyoDevice): return SUPPORT_ONKYO return SUPPORT_ONKYO_WO_VOLUME - def turn_off(self): + def turn_off(self) -> None: """Turn the media player off.""" self.command(f"zone{self._zone}.power=standby") - def set_volume_level(self, volume): + def set_volume_level(self, volume: float) -> None: """ Set volume level, input is range 0..1. @@ -581,26 +582,26 @@ class OnkyoDeviceZone(OnkyoDevice): f"zone{self._zone}.volume={int(volume * (self._max_volume / 100) * self._receiver_max_volume)}" ) - def volume_up(self): + def volume_up(self) -> None: """Increase volume by 1 step.""" self.command(f"zone{self._zone}.volume=level-up") - def volume_down(self): + def volume_down(self) -> None: """Decrease volume by 1 step.""" self.command(f"zone{self._zone}.volume=level-down") - def mute_volume(self, mute): + def mute_volume(self, mute: bool) -> None: """Mute (true) or unmute (false) media player.""" if mute: self.command(f"zone{self._zone}.muting=on") else: self.command(f"zone{self._zone}.muting=off") - def turn_on(self): + def turn_on(self) -> None: """Turn the media player on.""" self.command(f"zone{self._zone}.power=on") - def select_source(self, source): + def select_source(self, source: str) -> None: """Set the input source.""" if source in self._source_list: source = self._reverse_mapping[source] diff --git a/homeassistant/components/onvif/binary_sensor.py b/homeassistant/components/onvif/binary_sensor.py index cd9af1d83b5..2a7f23c61ee 100644 --- a/homeassistant/components/onvif/binary_sensor.py +++ b/homeassistant/components/onvif/binary_sensor.py @@ -82,7 +82,7 @@ class ONVIFBinarySensor(ONVIFBaseEntity, RestoreEntity, BinarySensorEntity): return event.value return self._attr_is_on - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Connect to dispatcher listening for entity data notifications.""" self.async_on_remove( self.device.events.async_add_listener(self.async_write_ha_state) diff --git a/homeassistant/components/onvif/sensor.py b/homeassistant/components/onvif/sensor.py index b662dca1d5d..4ad4c11f175 100644 --- a/homeassistant/components/onvif/sensor.py +++ b/homeassistant/components/onvif/sensor.py @@ -81,7 +81,7 @@ class ONVIFSensor(ONVIFBaseEntity, RestoreSensor): return event.value return self._attr_native_value - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Connect to dispatcher listening for entity data notifications.""" self.async_on_remove( self.device.events.async_add_listener(self.async_write_ha_state) diff --git a/homeassistant/components/openerz/sensor.py b/homeassistant/components/openerz/sensor.py index c83611a303c..4bfe11ee264 100644 --- a/homeassistant/components/openerz/sensor.py +++ b/homeassistant/components/openerz/sensor.py @@ -58,7 +58,7 @@ class OpenERZSensor(SensorEntity): """Return the state of the sensor.""" return self._state - def update(self): + def update(self) -> None: """Fetch new state data for the sensor. This is the only method that should fetch new data for Home Assistant. diff --git a/homeassistant/components/openevse/sensor.py b/homeassistant/components/openevse/sensor.py index 3dcea4d0126..5bb469a3d99 100644 --- a/homeassistant/components/openevse/sensor.py +++ b/homeassistant/components/openevse/sensor.py @@ -118,7 +118,7 @@ class OpenEVSESensor(SensorEntity): self.entity_description = description self.charger = charger - def update(self): + def update(self) -> None: """Get the monitored data from the charger.""" try: sensor_type = self.entity_description.key diff --git a/homeassistant/components/openhardwaremonitor/sensor.py b/homeassistant/components/openhardwaremonitor/sensor.py index f21126d01a0..70dbbd38fc8 100644 --- a/homeassistant/components/openhardwaremonitor/sensor.py +++ b/homeassistant/components/openhardwaremonitor/sensor.py @@ -91,7 +91,7 @@ class OpenHardwareMonitorDevice(SensorEntity): """In some locales a decimal numbers uses ',' instead of '.'.""" return string.replace(",", ".") - def update(self): + def update(self) -> None: """Update the device from a new JSON object.""" self._data.update() diff --git a/homeassistant/components/openhome/media_player.py b/homeassistant/components/openhome/media_player.py index b6a0b549c40..d528bb8dad4 100644 --- a/homeassistant/components/openhome/media_player.py +++ b/homeassistant/components/openhome/media_player.py @@ -19,6 +19,7 @@ from homeassistant.components.media_player import ( MediaPlayerEntityFeature, ) from homeassistant.components.media_player.browse_media import ( + BrowseMedia, async_process_play_media_url, ) from homeassistant.components.media_player.const import MEDIA_TYPE_MUSIC @@ -133,7 +134,7 @@ class OpenhomeDevice(MediaPlayerEntity): """Device is available.""" return self._available - async def async_update(self): + async def async_update(self) -> None: """Update state of device.""" try: self._in_standby = await self._device.is_in_standby() @@ -195,17 +196,19 @@ class OpenhomeDevice(MediaPlayerEntity): self._available = False @catch_request_errors() - async def async_turn_on(self): + async def async_turn_on(self) -> None: """Bring device out of standby.""" await self._device.set_standby(False) @catch_request_errors() - async def async_turn_off(self): + async def async_turn_off(self) -> None: """Put device in standby.""" await self._device.set_standby(True) @catch_request_errors() - 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: """Send the play_media command to the media player.""" if media_source.is_media_source_id(media_id): media_type = MEDIA_TYPE_MUSIC @@ -228,32 +231,32 @@ class OpenhomeDevice(MediaPlayerEntity): await self._device.play_media(track_details) @catch_request_errors() - async def async_media_pause(self): + async def async_media_pause(self) -> None: """Send pause command.""" await self._device.pause() @catch_request_errors() - async def async_media_stop(self): + async def async_media_stop(self) -> None: """Send stop command.""" await self._device.stop() @catch_request_errors() - async def async_media_play(self): + async def async_media_play(self) -> None: """Send play command.""" await self._device.play() @catch_request_errors() - async def async_media_next_track(self): + async def async_media_next_track(self) -> None: """Send next track command.""" await self._device.skip(1) @catch_request_errors() - async def async_media_previous_track(self): + async def async_media_previous_track(self) -> None: """Send previous track command.""" await self._device.skip(-1) @catch_request_errors() - async def async_select_source(self, source): + async def async_select_source(self, source: str) -> None: """Select input source.""" await self._device.set_source(self._source_index[source]) @@ -325,26 +328,28 @@ class OpenhomeDevice(MediaPlayerEntity): return self._volume_muted @catch_request_errors() - async def async_volume_up(self): + async def async_volume_up(self) -> None: """Volume up media player.""" await self._device.increase_volume() @catch_request_errors() - async def async_volume_down(self): + async def async_volume_down(self) -> None: """Volume down media player.""" await self._device.decrease_volume() @catch_request_errors() - async def async_set_volume_level(self, volume): + async def async_set_volume_level(self, volume: float) -> None: """Set volume level, range 0..1.""" await self._device.set_volume(int(volume * 100)) @catch_request_errors() - async def async_mute_volume(self, mute): + async def async_mute_volume(self, mute: bool) -> None: """Mute (true) or unmute (false) media player.""" await self._device.set_mute(mute) - async def async_browse_media(self, media_content_type=None, media_content_id=None): + async def async_browse_media( + 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( self.hass, diff --git a/homeassistant/components/opentherm_gw/binary_sensor.py b/homeassistant/components/opentherm_gw/binary_sensor.py index 083fb103481..194e047e50e 100644 --- a/homeassistant/components/opentherm_gw/binary_sensor.py +++ b/homeassistant/components/opentherm_gw/binary_sensor.py @@ -102,14 +102,14 @@ class OpenThermBinarySensor(BinarySensorEntity): self._friendly_name = friendly_name_format.format(gw_dev.name) self._unsub_updates = None - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Subscribe to updates from the component.""" _LOGGER.debug("Added OpenTherm Gateway binary sensor %s", self._friendly_name) self._unsub_updates = async_dispatcher_connect( self.hass, self._gateway.update_signal, self.receive_report ) - async def async_will_remove_from_hass(self): + async def async_will_remove_from_hass(self) -> None: """Unsubscribe from updates from the component.""" _LOGGER.debug( "Removing OpenTherm Gateway binary sensor %s", self._friendly_name diff --git a/homeassistant/components/opentherm_gw/climate.py b/homeassistant/components/opentherm_gw/climate.py index a805cbacba0..fba28138f42 100644 --- a/homeassistant/components/opentherm_gw/climate.py +++ b/homeassistant/components/opentherm_gw/climate.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from pyotgw import vars as gw_vars @@ -101,7 +102,7 @@ class OpenThermClimate(ClimateEntity): self.temporary_ovrd_mode = entry.options[CONF_TEMPORARY_OVRD_MODE] self.async_write_ha_state() - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Connect to the OpenTherm Gateway device.""" _LOGGER.debug("Added OpenTherm Gateway climate device %s", self.friendly_name) self._unsub_updates = async_dispatcher_connect( @@ -111,7 +112,7 @@ class OpenThermClimate(ClimateEntity): self.hass, self._gateway.options_update_signal, self.update_options ) - async def async_will_remove_from_hass(self): + async def async_will_remove_from_hass(self) -> None: """Unsubscribe from updates from the component.""" _LOGGER.debug("Removing OpenTherm Gateway climate %s", self.friendly_name) self._unsub_options() @@ -261,11 +262,11 @@ class OpenThermClimate(ClimateEntity): """Available preset modes to set.""" return [] - def set_preset_mode(self, preset_mode): + def set_preset_mode(self, preset_mode: str) -> None: """Set the preset mode.""" _LOGGER.warning("Changing preset mode is not supported") - async def async_set_temperature(self, **kwargs): + async def async_set_temperature(self, **kwargs: Any) -> None: """Set new target temperature.""" if ATTR_TEMPERATURE in kwargs: temp = float(kwargs[ATTR_TEMPERATURE]) diff --git a/homeassistant/components/opentherm_gw/sensor.py b/homeassistant/components/opentherm_gw/sensor.py index 5eea4fca099..67b4eb138dd 100644 --- a/homeassistant/components/opentherm_gw/sensor.py +++ b/homeassistant/components/opentherm_gw/sensor.py @@ -106,14 +106,14 @@ class OpenThermSensor(SensorEntity): self._friendly_name = friendly_name_format.format(gw_dev.name) self._unsub_updates = None - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Subscribe to updates from the component.""" _LOGGER.debug("Added OpenTherm Gateway sensor %s", self._friendly_name) self._unsub_updates = async_dispatcher_connect( self.hass, self._gateway.update_signal, self.receive_report ) - async def async_will_remove_from_hass(self): + async def async_will_remove_from_hass(self) -> None: """Unsubscribe from updates from the component.""" _LOGGER.debug("Removing OpenTherm Gateway sensor %s", self._friendly_name) self._unsub_updates() diff --git a/homeassistant/components/opple/light.py b/homeassistant/components/opple/light.py index 25bcf821fc9..80d0f8630dc 100644 --- a/homeassistant/components/opple/light.py +++ b/homeassistant/components/opple/light.py @@ -69,7 +69,7 @@ class OppleLight(LightEntity): self._color_temp = None @property - def available(self): + def available(self) -> bool: """Return True if light is available.""" return self._device.is_online diff --git a/homeassistant/components/oru/sensor.py b/homeassistant/components/oru/sensor.py index b31defd7171..5d99e782fdd 100644 --- a/homeassistant/components/oru/sensor.py +++ b/homeassistant/components/oru/sensor.py @@ -75,7 +75,7 @@ class CurrentEnergyUsageSensor(SensorEntity): """Return the state of the sensor.""" return self._state - def update(self): + def update(self) -> None: """Fetch new state data for the sensor.""" try: last_read = self.meter.last_read() diff --git a/homeassistant/components/orvibo/switch.py b/homeassistant/components/orvibo/switch.py index b526b9057bd..9e86d3787af 100644 --- a/homeassistant/components/orvibo/switch.py +++ b/homeassistant/components/orvibo/switch.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from orvibo.s20 import S20, S20Exception, discover import voluptuous as vol @@ -93,21 +94,21 @@ class S20Switch(SwitchEntity): """Return true if device is on.""" return self._state - def update(self): + def update(self) -> None: """Update device state.""" try: self._state = self._s20.on except self._exc: _LOGGER.exception("Error while fetching S20 state") - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" try: self._s20.on = True except self._exc: _LOGGER.exception("Error while turning on S20") - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the device off.""" try: self._s20.on = False diff --git a/homeassistant/components/otp/sensor.py b/homeassistant/components/otp/sensor.py index ff5a2965795..499c9b129f1 100644 --- a/homeassistant/components/otp/sensor.py +++ b/homeassistant/components/otp/sensor.py @@ -53,7 +53,7 @@ class TOTPSensor(SensorEntity): self._state = None self._next_expiration = 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._call_loop() diff --git a/homeassistant/components/owntracks/device_tracker.py b/homeassistant/components/owntracks/device_tracker.py index 5119168e7ae..70b8bde6de1 100644 --- a/homeassistant/components/owntracks/device_tracker.py +++ b/homeassistant/components/owntracks/device_tracker.py @@ -124,7 +124,7 @@ class OwnTracksEntity(TrackerEntity, RestoreEntity): """Return the device info.""" return DeviceInfo(identifiers={(OT_DOMAIN, self._dev_id)}, name=self.name) - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Call when entity about to be added to Home Assistant.""" await super().async_added_to_hass()