From 11a19c2612f9704721c14ea4300c76257a75e468 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Sun, 31 Jul 2022 13:50:24 +0200 Subject: [PATCH] Improve type hints in light [s-z] (#75946) --- homeassistant/components/scsgate/light.py | 5 +-- homeassistant/components/sisyphus/light.py | 11 +++--- homeassistant/components/smartthings/light.py | 7 ++-- homeassistant/components/smarttub/light.py | 6 ++-- homeassistant/components/tellduslive/light.py | 5 +-- homeassistant/components/tikteck/light.py | 5 +-- homeassistant/components/twinkly/light.py | 4 +-- homeassistant/components/unifiled/light.py | 7 ++-- homeassistant/components/upb/light.py | 8 +++-- homeassistant/components/velux/light.py | 6 ++-- homeassistant/components/vera/light.py | 2 +- homeassistant/components/vesync/light.py | 3 +- homeassistant/components/x10/light.py | 7 ++-- .../components/xiaomi_aqara/light.py | 3 +- homeassistant/components/xiaomi_miio/light.py | 35 ++++++++++--------- homeassistant/components/yeelight/light.py | 9 ++--- .../components/yeelightsunflower/light.py | 7 ++-- homeassistant/components/zengge/light.py | 7 ++-- homeassistant/components/zwave_me/light.py | 2 +- 19 files changed, 79 insertions(+), 60 deletions(-) diff --git a/homeassistant/components/scsgate/light.py b/homeassistant/components/scsgate/light.py index 3957aa4cd95..df63bad49d4 100644 --- a/homeassistant/components/scsgate/light.py +++ b/homeassistant/components/scsgate/light.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from scsgate.tasks import ToggleStatusTask import voluptuous as vol @@ -76,7 +77,7 @@ class SCSGateLight(LightEntity): """Return true if light 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)) @@ -84,7 +85,7 @@ class SCSGateLight(LightEntity): 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/sisyphus/light.py b/homeassistant/components/sisyphus/light.py index 7601ccf7657..d0cd7597e58 100644 --- a/homeassistant/components/sisyphus/light.py +++ b/homeassistant/components/sisyphus/light.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any import aiohttp @@ -47,16 +48,16 @@ class SisyphusLight(LightEntity): self._name = name 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 the table state.""" await self._table.refresh() @property - def available(self): + def available(self) -> bool: """Return true if the table is responding to heartbeats.""" return self._table.is_connected @@ -80,12 +81,12 @@ class SisyphusLight(LightEntity): """Return the current brightness of the table's ring light.""" return self._table.brightness * 255 - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Put the table to sleep.""" await self._table.sleep() _LOGGER.debug("Sisyphus table %s: sleep") - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Wake up the table if necessary, optionally changes brightness.""" if not self.is_on: await self._table.wakeup() diff --git a/homeassistant/components/smartthings/light.py b/homeassistant/components/smartthings/light.py index 1b1738a94d4..918e8b4258c 100644 --- a/homeassistant/components/smartthings/light.py +++ b/homeassistant/components/smartthings/light.py @@ -3,6 +3,7 @@ from __future__ import annotations import asyncio from collections.abc import Sequence +from typing import Any from pysmartthings import Capability @@ -96,7 +97,7 @@ class SmartThingsLight(SmartThingsEntity, LightEntity): return features - async def async_turn_on(self, **kwargs) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the light on.""" tasks = [] # Color temperature @@ -121,7 +122,7 @@ class SmartThingsLight(SmartThingsEntity, LightEntity): # the entity state ahead of receiving the confirming push updates self.async_schedule_update_ha_state(True) - async def async_turn_off(self, **kwargs) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the light off.""" # Switch/transition if ( @@ -136,7 +137,7 @@ class SmartThingsLight(SmartThingsEntity, LightEntity): # 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 entity attributes when the device status has changed.""" # Brightness and transition if self._supported_features & SUPPORT_BRIGHTNESS: diff --git a/homeassistant/components/smarttub/light.py b/homeassistant/components/smarttub/light.py index b8750c50611..f7e229449e0 100644 --- a/homeassistant/components/smarttub/light.py +++ b/homeassistant/components/smarttub/light.py @@ -1,4 +1,6 @@ """Platform for light integration.""" +from typing import Any + from smarttub import SpaLight from homeassistant.components.light import ( @@ -125,7 +127,7 @@ class SmartTubLight(SmartTubEntity, LightEntity): return SpaLight.LightMode[effect.upper()] - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the light on.""" mode = self._effect_to_light_mode(kwargs.get(ATTR_EFFECT, DEFAULT_LIGHT_EFFECT)) @@ -136,7 +138,7 @@ class SmartTubLight(SmartTubEntity, LightEntity): await self.light.set_mode(mode, intensity) await self.coordinator.async_request_refresh() - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the light off.""" await self.light.set_mode(SpaLight.LightMode.OFF, 0) await self.coordinator.async_request_refresh() diff --git a/homeassistant/components/tellduslive/light.py b/homeassistant/components/tellduslive/light.py index 7609cc6adee..205fff840d6 100644 --- a/homeassistant/components/tellduslive/light.py +++ b/homeassistant/components/tellduslive/light.py @@ -1,5 +1,6 @@ """Support for Tellstick lights using Tellstick Net.""" import logging +from typing import Any from homeassistant.components import light, tellduslive from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity @@ -58,7 +59,7 @@ class TelldusLiveLight(TelldusLiveEntity, LightEntity): """Return true if light is on.""" return self.device.is_on - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the light on.""" brightness = kwargs.get(ATTR_BRIGHTNESS, self._last_brightness) if brightness == 0: @@ -70,7 +71,7 @@ class TelldusLiveLight(TelldusLiveEntity, LightEntity): self.device.dim(level=brightness) self.changed() - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the light off.""" self.device.turn_off() self.changed() diff --git a/homeassistant/components/tikteck/light.py b/homeassistant/components/tikteck/light.py index 0f810c434fb..28daf4baac1 100644 --- a/homeassistant/components/tikteck/light.py +++ b/homeassistant/components/tikteck/light.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any import tikteck import voluptuous as vol @@ -111,7 +112,7 @@ class TikteckLight(LightEntity): """Set the bulb state.""" return self._bulb.set_state(red, green, blue, brightness) - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the specified light on.""" self._state = True @@ -128,7 +129,7 @@ class TikteckLight(LightEntity): self.set_state(rgb[0], rgb[1], rgb[2], self.brightness) self.schedule_update_ha_state() - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the specified light off.""" self._state = False self.set_state(0, 0, 0, 0) diff --git a/homeassistant/components/twinkly/light.py b/homeassistant/components/twinkly/light.py index 9068c04e01b..ba6ac7cf492 100644 --- a/homeassistant/components/twinkly/light.py +++ b/homeassistant/components/twinkly/light.py @@ -140,7 +140,7 @@ class TwinklyLight(LightEntity): return attributes - async def async_turn_on(self, **kwargs) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn device on.""" if ATTR_BRIGHTNESS in kwargs: brightness = int(int(kwargs[ATTR_BRIGHTNESS]) / 2.55) @@ -183,7 +183,7 @@ class TwinklyLight(LightEntity): if not self._is_on: await self._client.turn_on() - async def async_turn_off(self, **kwargs) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn device off.""" await self._client.turn_off() diff --git a/homeassistant/components/unifiled/light.py b/homeassistant/components/unifiled/light.py index dd5a5b5290a..8ba9fc2b6f9 100644 --- a/homeassistant/components/unifiled/light.py +++ b/homeassistant/components/unifiled/light.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any from unifiled import unifiled import voluptuous as vol @@ -98,7 +99,7 @@ class UnifiLedLight(LightEntity): """Return true if light is on.""" return self._state - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Instruct the light to turn on.""" self._api.setdevicebrightness( self._unique_id, @@ -106,11 +107,11 @@ class UnifiLedLight(LightEntity): ) self._api.setdeviceoutput(self._unique_id, 1) - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Instruct the light to turn off.""" self._api.setdeviceoutput(self._unique_id, 0) - def update(self): + def update(self) -> None: """Update the light states.""" self._state = self._api.getlightstate(self._unique_id) self._brightness = self._api.convertfrom100to255( diff --git a/homeassistant/components/upb/light.py b/homeassistant/components/upb/light.py index 98a775c18ab..85cda1f0061 100644 --- a/homeassistant/components/upb/light.py +++ b/homeassistant/components/upb/light.py @@ -1,4 +1,6 @@ """Platform for UPB light integration.""" +from typing import Any + from homeassistant.components.light import ( ATTR_BRIGHTNESS, ATTR_FLASH, @@ -85,7 +87,7 @@ class UpbLight(UpbAttachedEntity, LightEntity): """Get the current brightness.""" return self._brightness != 0 - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn on the light.""" if flash := kwargs.get(ATTR_FLASH): await self.async_light_blink(0.5 if flash == "short" else 1.5) @@ -94,7 +96,7 @@ class UpbLight(UpbAttachedEntity, LightEntity): brightness = round(kwargs.get(ATTR_BRIGHTNESS, 255) / 2.55) self._element.turn_on(brightness, rate) - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn off the device.""" rate = kwargs.get(ATTR_TRANSITION, -1) self._element.turn_off(rate) @@ -114,7 +116,7 @@ class UpbLight(UpbAttachedEntity, LightEntity): blink_rate = int(blink_rate * 60) # Convert seconds to 60 hz pulses self._element.blink(blink_rate) - async def async_update(self): + async def async_update(self) -> None: """Request the device to update its status.""" self._element.update_status() diff --git a/homeassistant/components/velux/light.py b/homeassistant/components/velux/light.py index f8a52fc05c1..a600aceedd2 100644 --- a/homeassistant/components/velux/light.py +++ b/homeassistant/components/velux/light.py @@ -1,6 +1,8 @@ """Support for Velux lights.""" from __future__ import annotations +from typing import Any + from pyvlx import Intensity, LighteningDevice from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity @@ -43,7 +45,7 @@ class VeluxLight(VeluxEntity, LightEntity): """Return true if light is on.""" return not self.node.intensity.off and self.node.intensity.known - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Instruct the light to turn on.""" if ATTR_BRIGHTNESS in kwargs: intensity_percent = int(100 - kwargs[ATTR_BRIGHTNESS] / 255 * 100) @@ -54,6 +56,6 @@ class VeluxLight(VeluxEntity, LightEntity): else: await self.node.turn_on(wait_for_completion=True) - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Instruct the light to turn off.""" await self.node.turn_off(wait_for_completion=True) diff --git a/homeassistant/components/vera/light.py b/homeassistant/components/vera/light.py index e91492a934f..fa017be475e 100644 --- a/homeassistant/components/vera/light.py +++ b/homeassistant/components/vera/light.py @@ -88,7 +88,7 @@ class VeraLight(VeraDevice[veraApi.VeraDimmer], LightEntity): self._state = True self.schedule_update_ha_state(True) - def turn_off(self, **kwargs: Any): + def turn_off(self, **kwargs: Any) -> None: """Turn the light off.""" self.vera_device.switch_off() self._state = False diff --git a/homeassistant/components/vesync/light.py b/homeassistant/components/vesync/light.py index d01319ff0e7..8727a770112 100644 --- a/homeassistant/components/vesync/light.py +++ b/homeassistant/components/vesync/light.py @@ -1,5 +1,6 @@ """Support for VeSync bulbs and wall dimmers.""" import logging +from typing import Any from homeassistant.components.light import ( ATTR_BRIGHTNESS, @@ -83,7 +84,7 @@ class VeSyncBaseLight(VeSyncDevice, LightEntity): # convert percent brightness to ha expected range return round((max(1, brightness_value) / 100) * 255) - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" attribute_adjustment_only = False # set white temperature diff --git a/homeassistant/components/x10/light.py b/homeassistant/components/x10/light.py index 42a15a643bd..b7e331e2199 100644 --- a/homeassistant/components/x10/light.py +++ b/homeassistant/components/x10/light.py @@ -3,6 +3,7 @@ from __future__ import annotations import logging from subprocess import STDOUT, CalledProcessError, check_output +from typing import Any import voluptuous as vol @@ -87,7 +88,7 @@ class X10Light(LightEntity): """Return true if light is on.""" return self._state - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Instruct the light to turn on.""" if self._is_cm11a: x10_command(f"on {self._id}") @@ -96,7 +97,7 @@ class X10Light(LightEntity): self._brightness = kwargs.get(ATTR_BRIGHTNESS, 255) self._state = True - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Instruct the light to turn off.""" if self._is_cm11a: x10_command(f"off {self._id}") @@ -104,7 +105,7 @@ class X10Light(LightEntity): x10_command(f"foff {self._id}") self._state = False - def update(self): + def update(self) -> None: """Fetch update state.""" if self._is_cm11a: self._state = bool(get_unit_status(self._id)) diff --git a/homeassistant/components/xiaomi_aqara/light.py b/homeassistant/components/xiaomi_aqara/light.py index 812cd1c96b8..173ffe564fc 100644 --- a/homeassistant/components/xiaomi_aqara/light.py +++ b/homeassistant/components/xiaomi_aqara/light.py @@ -2,6 +2,7 @@ import binascii import logging import struct +from typing import Any from homeassistant.components.light import ( ATTR_BRIGHTNESS, @@ -113,7 +114,7 @@ class XiaomiGatewayLight(XiaomiDevice, LightEntity): self._state = True self.schedule_update_ha_state() - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the light off.""" if self._write_to_hub(self._sid, **{self._data_key: 0}): self._state = False diff --git a/homeassistant/components/xiaomi_miio/light.py b/homeassistant/components/xiaomi_miio/light.py index fd6af0d9560..2a7fce01442 100644 --- a/homeassistant/components/xiaomi_miio/light.py +++ b/homeassistant/components/xiaomi_miio/light.py @@ -7,6 +7,7 @@ from datetime import timedelta from functools import partial import logging from math import ceil +from typing import Any from miio import ( Ceil, @@ -292,7 +293,7 @@ class XiaomiPhilipsAbstractLight(XiaomiMiioEntity, LightEntity): return False - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the light on.""" if ATTR_BRIGHTNESS in kwargs: brightness = kwargs[ATTR_BRIGHTNESS] @@ -311,11 +312,11 @@ class XiaomiPhilipsAbstractLight(XiaomiMiioEntity, LightEntity): else: await self._try_command("Turning the light on failed.", self._device.on) - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the light off.""" await self._try_command("Turning the light off failed.", self._device.off) - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._device.status) @@ -341,7 +342,7 @@ class XiaomiPhilipsGenericLight(XiaomiPhilipsAbstractLight): self._state_attrs.update({ATTR_SCENE: None, ATTR_DELAYED_TURN_OFF: None}) - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._device.status) @@ -430,7 +431,7 @@ class XiaomiPhilipsBulb(XiaomiPhilipsGenericLight): """Return the warmest color_temp that this light supports.""" return 333 - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the light on.""" if ATTR_COLOR_TEMP in kwargs: color_temp = kwargs[ATTR_COLOR_TEMP] @@ -497,7 +498,7 @@ class XiaomiPhilipsBulb(XiaomiPhilipsGenericLight): else: await self._try_command("Turning the light on failed.", self._device.on) - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._device.status) @@ -556,7 +557,7 @@ class XiaomiPhilipsCeilingLamp(XiaomiPhilipsBulb): """Return the warmest color_temp that this light supports.""" return 370 - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._device.status) @@ -602,7 +603,7 @@ class XiaomiPhilipsEyecareLamp(XiaomiPhilipsGenericLight): {ATTR_REMINDER: None, ATTR_NIGHT_LIGHT_MODE: None, ATTR_EYECARE_MODE: None} ) - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._device.status) @@ -714,7 +715,7 @@ class XiaomiPhilipsEyecareLampAmbientLight(XiaomiPhilipsAbstractLight): unique_id = f"{unique_id}-ambient" super().__init__(name, device, entry, unique_id) - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the light on.""" if ATTR_BRIGHTNESS in kwargs: brightness = kwargs[ATTR_BRIGHTNESS] @@ -739,13 +740,13 @@ class XiaomiPhilipsEyecareLampAmbientLight(XiaomiPhilipsAbstractLight): "Turning the ambient light on failed.", self._device.ambient_on ) - async def async_turn_off(self, **kwargs): + async def async_turn_off(self, **kwargs: Any) -> None: """Turn the light off.""" await self._try_command( "Turning the ambient light off failed.", self._device.ambient_off ) - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._device.status) @@ -805,7 +806,7 @@ class XiaomiPhilipsMoonlightLamp(XiaomiPhilipsBulb): return ColorMode.HS return ColorMode.COLOR_TEMP - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the light on.""" if ATTR_COLOR_TEMP in kwargs: color_temp = kwargs[ATTR_COLOR_TEMP] @@ -905,7 +906,7 @@ class XiaomiPhilipsMoonlightLamp(XiaomiPhilipsBulb): else: await self._try_command("Turning the light on failed.", self._device.on) - async def async_update(self): + async def async_update(self) -> None: """Fetch state from the device.""" try: state = await self.hass.async_add_executor_job(self._device.status) @@ -996,7 +997,7 @@ class XiaomiGatewayLight(LightEntity): """Return the hs color value.""" return self._hs - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the light on.""" if ATTR_HS_COLOR in kwargs: rgb = color.color_hs_to_RGB(*kwargs[ATTR_HS_COLOR]) @@ -1012,7 +1013,7 @@ class XiaomiGatewayLight(LightEntity): self.schedule_update_ha_state() - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the light off.""" self._gateway.light.set_rgb(0, self._rgb) self.schedule_update_ha_state() @@ -1071,7 +1072,7 @@ class XiaomiGatewayBulb(XiaomiGatewayDevice, LightEntity): """Return max cct.""" return self._sub_device.status["cct_max"] - async def async_turn_on(self, **kwargs): + async def async_turn_on(self, **kwargs: Any) -> None: """Instruct the light to turn on.""" await self.hass.async_add_executor_job(self._sub_device.on) @@ -1087,6 +1088,6 @@ class XiaomiGatewayBulb(XiaomiGatewayDevice, LightEntity): self._sub_device.set_brightness, brightness ) - async def async_turn_off(self, **kwargsf): + async def async_turn_off(self, **kwargs: Any) -> None: """Instruct the light to turn off.""" await self.hass.async_add_executor_job(self._sub_device.off) diff --git a/homeassistant/components/yeelight/light.py b/homeassistant/components/yeelight/light.py index a368490e51e..9bb0ed21989 100644 --- a/homeassistant/components/yeelight/light.py +++ b/homeassistant/components/yeelight/light.py @@ -4,6 +4,7 @@ from __future__ import annotations import asyncio import logging import math +from typing import Any import voluptuous as vol import yeelight @@ -442,7 +443,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity): self._async_cancel_pending_state_check() self.async_write_ha_state() - async def async_added_to_hass(self): + async def async_added_to_hass(self) -> None: """Handle entity which will be added.""" self.async_on_remove( async_dispatcher_connect( @@ -585,7 +586,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity): """Return yeelight device.""" return self._device - async def async_update(self): + async def async_update(self) -> None: """Update light properties.""" await self.device.async_update(True) @@ -774,7 +775,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity): power_mode=self._turn_on_power_mode, ) - async def async_turn_on(self, **kwargs) -> None: + async def async_turn_on(self, **kwargs: Any) -> None: """Turn the bulb on.""" brightness = kwargs.get(ATTR_BRIGHTNESS) colortemp = kwargs.get(ATTR_COLOR_TEMP) @@ -836,7 +837,7 @@ class YeelightGenericLight(YeelightEntity, LightEntity): """Turn off with a given transition duration wrapped with _async_cmd.""" await self._bulb.async_turn_off(duration=duration, light_type=self.light_type) - async def async_turn_off(self, **kwargs) -> None: + async def async_turn_off(self, **kwargs: Any) -> None: """Turn off.""" if not self.is_on: return diff --git a/homeassistant/components/yeelightsunflower/light.py b/homeassistant/components/yeelightsunflower/light.py index 1b76aef1328..8b51dad40f7 100644 --- a/homeassistant/components/yeelightsunflower/light.py +++ b/homeassistant/components/yeelightsunflower/light.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any import voluptuous as vol import yeelightsunflower @@ -87,7 +88,7 @@ class SunflowerBulb(LightEntity): """Return the color property.""" return color_util.color_RGB_to_hs(*self._rgb_color) - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Instruct the light to turn on, optionally set colour/brightness.""" # when no arguments, just turn light on (full brightness) if not kwargs: @@ -104,11 +105,11 @@ class SunflowerBulb(LightEntity): bright = int(kwargs[ATTR_BRIGHTNESS] / 255 * 100) self._light.set_brightness(bright) - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Instruct the light to turn off.""" self._light.turn_off() - def update(self): + def update(self) -> None: """Fetch new state data for this light and update local values.""" self._light.update() self._available = self._light.available diff --git a/homeassistant/components/zengge/light.py b/homeassistant/components/zengge/light.py index 057b049eefd..6939ecb276b 100644 --- a/homeassistant/components/zengge/light.py +++ b/homeassistant/components/zengge/light.py @@ -2,6 +2,7 @@ from __future__ import annotations import logging +from typing import Any import voluptuous as vol from zengge import zengge @@ -123,7 +124,7 @@ class ZenggeLight(LightEntity): """Set the white state.""" return self._bulb.set_white(white) - def turn_on(self, **kwargs): + def turn_on(self, **kwargs: Any) -> None: """Turn the specified light on.""" self._state = True self._bulb.on() @@ -153,12 +154,12 @@ class ZenggeLight(LightEntity): ) self._set_rgb(*rgb) - def turn_off(self, **kwargs): + def turn_off(self, **kwargs: Any) -> None: """Turn the specified light off.""" self._state = False self._bulb.off() - def update(self): + def update(self) -> None: """Synchronise internal state with the actual light state.""" rgb = self._bulb.get_colour() hsv = color_util.color_RGB_to_hsv(*rgb) diff --git a/homeassistant/components/zwave_me/light.py b/homeassistant/components/zwave_me/light.py index fd4488b8dbf..5da0f955059 100644 --- a/homeassistant/components/zwave_me/light.py +++ b/homeassistant/components/zwave_me/light.py @@ -52,7 +52,7 @@ class ZWaveMeRGB(ZWaveMeEntity, LightEntity): """Turn the device on.""" self.controller.zwave_api.send_command(self.device.id, "off") - def turn_on(self, **kwargs: Any): + def turn_on(self, **kwargs: Any) -> None: """Turn the device on.""" color = kwargs.get(ATTR_RGB_COLOR)