mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Improve type hints in light [i-r] (#75943)
This commit is contained in:
parent
11a19c2612
commit
7b1463e03d
@ -1,4 +1,6 @@
|
||||
"""Support for Insteon lights via PowerLinc Modem."""
|
||||
from typing import Any
|
||||
|
||||
from pyinsteon.config import ON_LEVEL
|
||||
|
||||
from homeassistant.components.light import (
|
||||
@ -50,11 +52,11 @@ class InsteonDimmerEntity(InsteonEntity, LightEntity):
|
||||
return self._insteon_device_group.value
|
||||
|
||||
@property
|
||||
def is_on(self):
|
||||
def is_on(self) -> bool:
|
||||
"""Return the boolean response if the node is on."""
|
||||
return bool(self.brightness)
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn light on."""
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
brightness = int(kwargs[ATTR_BRIGHTNESS])
|
||||
@ -67,6 +69,6 @@ class InsteonDimmerEntity(InsteonEntity, LightEntity):
|
||||
else:
|
||||
await self._insteon_device.async_on(group=self._insteon_device_group.group)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn light off."""
|
||||
await self._insteon_device.async_off(self._insteon_device_group.group)
|
||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import pykulersky
|
||||
|
||||
@ -116,7 +117,7 @@ class KulerskyLight(LightEntity):
|
||||
"""Return True if entity is available."""
|
||||
return self._available
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Instruct the light to turn on."""
|
||||
default_rgbw = (255,) * 4 if self.rgbw_color is None else self.rgbw_color
|
||||
rgbw = kwargs.get(ATTR_RGBW_COLOR, default_rgbw)
|
||||
@ -134,7 +135,7 @@ class KulerskyLight(LightEntity):
|
||||
|
||||
await self._light.set_color(*rgbw_scaled)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Instruct the light to turn off."""
|
||||
await self._light.set_color(0, 0, 0, 0)
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for LightwaveRF lights."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
|
||||
from homeassistant.const import CONF_NAME
|
||||
from homeassistant.core import HomeAssistant
|
||||
@ -46,7 +48,7 @@ class LWRFLight(LightEntity):
|
||||
self._attr_brightness = MAX_BRIGHTNESS
|
||||
self._lwlink = lwlink
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the LightWave light on."""
|
||||
self._attr_is_on = True
|
||||
|
||||
@ -62,7 +64,7 @@ class LWRFLight(LightEntity):
|
||||
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the LightWave light off."""
|
||||
self._attr_is_on = False
|
||||
self._lwlink.turn_off(self._device_id, self._attr_name)
|
||||
|
@ -240,7 +240,7 @@ class LimitlessLEDGroup(LightEntity, RestoreEntity):
|
||||
self._color = None
|
||||
self._effect = None
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Handle entity about to be added to hass event."""
|
||||
await super().async_added_to_hass()
|
||||
if last_state := await self.async_get_last_state():
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Support for LiteJet lights."""
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
@ -53,12 +54,12 @@ class LiteJetLight(LightEntity):
|
||||
self._brightness = 0
|
||||
self._name = name
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Run when this Entity has been added to HA."""
|
||||
self._lj.on_load_activated(self._index, self._on_load_changed)
|
||||
self._lj.on_load_deactivated(self._index, self._on_load_changed)
|
||||
|
||||
async def async_will_remove_from_hass(self):
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Entity being removed from hass."""
|
||||
self._lj.unsubscribe(self._on_load_changed)
|
||||
|
||||
@ -97,7 +98,7 @@ class LiteJetLight(LightEntity):
|
||||
"""Return the device state attributes."""
|
||||
return {ATTR_NUMBER: self._index}
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on the light."""
|
||||
|
||||
# If neither attribute is specified then the simple activate load
|
||||
@ -115,7 +116,7 @@ class LiteJetLight(LightEntity):
|
||||
|
||||
self._lj.activate_load_at(self._index, brightness, int(transition))
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off the light."""
|
||||
if ATTR_TRANSITION in kwargs:
|
||||
self._lj.activate_load_at(self._index, 0, kwargs[ATTR_TRANSITION])
|
||||
@ -126,6 +127,6 @@ class LiteJetLight(LightEntity):
|
||||
# transition value programmed in the LiteJet system.
|
||||
self._lj.deactivate_load(self._index)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Retrieve the light's brightness from the LiteJet system."""
|
||||
self._brightness = int(self._lj.get_load_level(self._index) / 99 * 255)
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for Lutron lights."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.light import ATTR_BRIGHTNESS, ColorMode, LightEntity
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
||||
@ -53,7 +55,7 @@ class LutronLight(LutronDevice, LightEntity):
|
||||
self._prev_brightness = new_brightness
|
||||
return new_brightness
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the light on."""
|
||||
if ATTR_BRIGHTNESS in kwargs and self._lutron_device.is_dimmable:
|
||||
brightness = kwargs[ATTR_BRIGHTNESS]
|
||||
@ -64,7 +66,7 @@ class LutronLight(LutronDevice, LightEntity):
|
||||
self._prev_brightness = brightness
|
||||
self._lutron_device.level = to_lutron_level(brightness)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the light off."""
|
||||
self._lutron_device.level = 0
|
||||
|
||||
@ -78,7 +80,7 @@ class LutronLight(LutronDevice, LightEntity):
|
||||
"""Return true if device is on."""
|
||||
return self._lutron_device.last_level() > 0
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Call when forcing a refresh of the device."""
|
||||
if self._prev_brightness is None:
|
||||
self._prev_brightness = to_hass_level(self._lutron_device.level)
|
||||
|
@ -1,5 +1,6 @@
|
||||
"""Support for Lutron Caseta lights."""
|
||||
from datetime import timedelta
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.light import (
|
||||
ATTR_BRIGHTNESS,
|
||||
@ -69,13 +70,13 @@ class LutronCasetaLight(LutronCasetaDeviceUpdatableEntity, LightEntity):
|
||||
self.device_id, to_lutron_level(brightness), **args
|
||||
)
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the light on."""
|
||||
brightness = kwargs.pop(ATTR_BRIGHTNESS, 255)
|
||||
|
||||
await self._set_brightness(brightness, **kwargs)
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the light off."""
|
||||
await self._set_brightness(0, **kwargs)
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import lw12
|
||||
import voluptuous as vol
|
||||
@ -146,7 +147,7 @@ class LW12WiFi(LightEntity):
|
||||
self._light.set_light_option(lw12.LW12_LIGHT.FLASH, transition_speed)
|
||||
self._state = True
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Instruct the light to turn off."""
|
||||
self._light.light_off()
|
||||
self._state = False
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pymochad import device
|
||||
from pymochad.exceptions import MochadException
|
||||
@ -112,7 +113,7 @@ class MochadLight(LightEntity):
|
||||
self.light.send_cmd(f"bright {mochad_brightness}")
|
||||
self._controller.read_data()
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Send the command to turn the light on."""
|
||||
_LOGGER.debug("Reconnect %s:%s", self._controller.server, self._controller.port)
|
||||
brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
|
||||
@ -137,7 +138,7 @@ class MochadLight(LightEntity):
|
||||
except (MochadException, OSError) as exc:
|
||||
_LOGGER.error("Error with mochad communication: %s", exc)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Send the command to turn the light on."""
|
||||
_LOGGER.debug("Reconnect %s:%s", self._controller.server, self._controller.port)
|
||||
with REQ_LOCK:
|
||||
|
@ -1,4 +1,6 @@
|
||||
"""Support for MyQ-Enabled lights."""
|
||||
from typing import Any
|
||||
|
||||
from pymyq.errors import MyQError
|
||||
|
||||
from homeassistant.components.light import ColorMode, LightEntity
|
||||
@ -43,7 +45,7 @@ class MyQLight(MyQEntity, LightEntity):
|
||||
"""Return true if the light is off, else False."""
|
||||
return MYQ_TO_HASS.get(self._device.state) == STATE_OFF
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Issue on command to light."""
|
||||
if self.is_on:
|
||||
return
|
||||
@ -58,7 +60,7 @@ class MyQLight(MyQEntity, LightEntity):
|
||||
# Write new state to HASS
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Issue off command to light."""
|
||||
if self.is_off:
|
||||
return
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pymystrom.bulb import MyStromBulb
|
||||
from pymystrom.exceptions import MyStromConnectionError
|
||||
@ -120,7 +121,7 @@ class MyStromLight(LightEntity):
|
||||
"""Return true if light is on."""
|
||||
return self._state
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn on the light."""
|
||||
brightness = kwargs.get(ATTR_BRIGHTNESS, 255)
|
||||
effect = kwargs.get(ATTR_EFFECT)
|
||||
@ -147,14 +148,14 @@ class MyStromLight(LightEntity):
|
||||
except MyStromConnectionError:
|
||||
_LOGGER.warning("No route to myStrom bulb")
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn off the bulb."""
|
||||
try:
|
||||
await self._bulb.set_off()
|
||||
except MyStromConnectionError:
|
||||
_LOGGER.warning("The myStrom bulb not online")
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Fetch new state data for this light."""
|
||||
try:
|
||||
await self._bulb.get_state()
|
||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import nikohomecontrol
|
||||
import voluptuous as vol
|
||||
@ -77,17 +78,17 @@ class NikoHomeControlLight(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."""
|
||||
_LOGGER.debug("Turn on: %s", self.name)
|
||||
self._light.turn_on()
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Instruct the light to turn off."""
|
||||
_LOGGER.debug("Turn off: %s", self.name)
|
||||
self._light.turn_off()
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Get the latest data from NikoHomeControl API."""
|
||||
await self._data.async_update()
|
||||
self._state = self._data.get_state(self._light.id)
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
from pyoppleio.OppleLightDevice import OppleLightDevice
|
||||
import voluptuous as vol
|
||||
@ -107,7 +108,7 @@ class OppleLight(LightEntity):
|
||||
"""Return maximum supported color temperature."""
|
||||
return 333
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Instruct the light to turn on."""
|
||||
_LOGGER.debug("Turn on light %s %s", self._device.ip, kwargs)
|
||||
if not self.is_on:
|
||||
@ -120,12 +121,12 @@ class OppleLight(LightEntity):
|
||||
color_temp = mired_to_kelvin(kwargs[ATTR_COLOR_TEMP])
|
||||
self._device.color_temperature = color_temp
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Instruct the light to turn off."""
|
||||
self._device.power_on = False
|
||||
_LOGGER.debug("Turn off light %s", self._device.ip)
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Synchronize state with light."""
|
||||
prev_available = self.available
|
||||
self._device.update()
|
||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import random
|
||||
from typing import Any
|
||||
|
||||
from lightify import Lightify
|
||||
import voluptuous as vol
|
||||
@ -306,7 +307,7 @@ class Luminary(LightEntity):
|
||||
|
||||
return False
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
transition = int(kwargs.get(ATTR_TRANSITION, 0) * 10)
|
||||
if ATTR_EFFECT in kwargs:
|
||||
@ -331,7 +332,7 @@ class Luminary(LightEntity):
|
||||
else:
|
||||
self._luminary.set_onoff(True)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
self._is_on = False
|
||||
if ATTR_TRANSITION in kwargs:
|
||||
@ -374,7 +375,7 @@ class Luminary(LightEntity):
|
||||
if self._supported_features & SUPPORT_COLOR:
|
||||
self._rgb_color = self._luminary.rgb()
|
||||
|
||||
def update(self):
|
||||
def update(self) -> None:
|
||||
"""Synchronize state with bridge."""
|
||||
changed = self.update_func()
|
||||
if changed > self._changed:
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any
|
||||
|
||||
from haphilipsjs import PhilipsTV
|
||||
from haphilipsjs.typing import AmbilightCurrentConfiguration
|
||||
@ -337,7 +338,7 @@ class PhilipsTVLightEntity(
|
||||
if await self._tv.setAmbilightCurrentConfiguration(config) is False:
|
||||
raise Exception("Failed to set ambilight 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, self.brightness)
|
||||
hs_color = kwargs.get(ATTR_HS_COLOR, self.hs_color)
|
||||
@ -378,7 +379,7 @@ class PhilipsTVLightEntity(
|
||||
self._update_from_coordinator()
|
||||
self.async_write_ha_state()
|
||||
|
||||
async def async_turn_off(self, **kwargs) -> None:
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn of ambilight."""
|
||||
|
||||
if not self._tv.on:
|
||||
|
@ -1,6 +1,8 @@
|
||||
"""Support for switching devices via Pilight to on and off."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant.components.light import (
|
||||
@ -63,7 +65,7 @@ class PilightLight(PilightBaseDevice, LightEntity):
|
||||
"""Return the brightness."""
|
||||
return self._brightness
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the switch on by calling pilight.send service with on code."""
|
||||
# Update brightness only if provided as an argument.
|
||||
# This will allow the switch to keep its previous brightness level.
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from typing import Any
|
||||
|
||||
from plumlightpad import Plum
|
||||
|
||||
@ -69,7 +70,7 @@ class PlumLight(LightEntity):
|
||||
self._load = load
|
||||
self._brightness = load.level
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Subscribe to dimmerchange events."""
|
||||
self._load.add_event_listener("dimmerchange", self.dimmerchange)
|
||||
|
||||
@ -125,14 +126,14 @@ class PlumLight(LightEntity):
|
||||
"""Flag supported color modes."""
|
||||
return {self.color_mode}
|
||||
|
||||
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:
|
||||
await self._load.turn_on(kwargs[ATTR_BRIGHTNESS])
|
||||
else:
|
||||
await self._load.turn_on()
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the light off."""
|
||||
await self._load.turn_off()
|
||||
|
||||
@ -155,7 +156,7 @@ class GlowRing(LightEntity):
|
||||
self._green = lightpad.glow_color["green"]
|
||||
self._blue = lightpad.glow_color["blue"]
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Subscribe to configchange events."""
|
||||
self._lightpad.add_event_listener("configchange", self.configchange_event)
|
||||
|
||||
@ -222,7 +223,7 @@ class GlowRing(LightEntity):
|
||||
"""Return the crop-portrait icon representing the glow ring."""
|
||||
return "mdi:crop-portrait"
|
||||
|
||||
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_pct = kwargs[ATTR_BRIGHTNESS] / 255.0
|
||||
@ -234,7 +235,7 @@ class GlowRing(LightEntity):
|
||||
else:
|
||||
await self._lightpad.set_config({"glowEnabled": True})
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the light off."""
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
brightness_pct = kwargs[ATTR_BRIGHTNESS] / 255.0
|
||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import re
|
||||
from typing import Any
|
||||
|
||||
import voluptuous as vol
|
||||
|
||||
@ -184,7 +185,7 @@ class DimmableRflinkLight(SwitchableRflinkDevice, LightEntity):
|
||||
_attr_supported_color_modes = {ColorMode.BRIGHTNESS}
|
||||
_brightness = 255
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Restore RFLink light brightness attribute."""
|
||||
await super().async_added_to_hass()
|
||||
|
||||
@ -196,7 +197,7 @@ class DimmableRflinkLight(SwitchableRflinkDevice, LightEntity):
|
||||
# restore also brightness in dimmables devices
|
||||
self._brightness = int(old_state.attributes[ATTR_BRIGHTNESS])
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
if ATTR_BRIGHTNESS in kwargs:
|
||||
# rflink only support 16 brightness levels
|
||||
@ -242,7 +243,7 @@ class HybridRflinkLight(DimmableRflinkLight):
|
||||
Which results in a nice house disco :)
|
||||
"""
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on and set dim level."""
|
||||
await super().async_turn_on(**kwargs)
|
||||
# if the receiving device does not support dimlevel this
|
||||
@ -269,10 +270,10 @@ class ToggleRflinkLight(RflinkLight):
|
||||
# if the state is true, it gets set as false
|
||||
self._state = self._state in [None, False]
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
await self._async_handle_command("toggle")
|
||||
|
||||
async def async_turn_off(self, **kwargs):
|
||||
async def async_turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the device off."""
|
||||
await self._async_handle_command("toggle")
|
||||
|
@ -2,6 +2,7 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import RFXtrx as rfxtrxmod
|
||||
|
||||
@ -59,7 +60,7 @@ class RfxtrxLight(RfxtrxCommandEntity, LightEntity):
|
||||
_attr_brightness: int = 0
|
||||
_device: rfxtrxmod.LightingDevice
|
||||
|
||||
async def async_added_to_hass(self):
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Restore RFXtrx device state (ON/OFF)."""
|
||||
await super().async_added_to_hass()
|
||||
|
||||
@ -70,7 +71,7 @@ class RfxtrxLight(RfxtrxCommandEntity, LightEntity):
|
||||
if brightness := old_state.attributes.get(ATTR_BRIGHTNESS):
|
||||
self._attr_brightness = int(brightness)
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the device on."""
|
||||
brightness = kwargs.get(ATTR_BRIGHTNESS)
|
||||
self._attr_is_on = True
|
||||
@ -83,7 +84,7 @@ class RfxtrxLight(RfxtrxCommandEntity, LightEntity):
|
||||
|
||||
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."""
|
||||
await self._async_send(self._device.send_off)
|
||||
self._attr_is_on = False
|
||||
|
@ -1,6 +1,7 @@
|
||||
"""This component provides HA switch support for Ring Door Bell/Chimes."""
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any
|
||||
|
||||
import requests
|
||||
|
||||
@ -93,10 +94,10 @@ class RingLight(RingEntityMixin, LightEntity):
|
||||
self._no_updates_until = dt_util.utcnow() + SKIP_UPDATES_DELAY
|
||||
self.async_write_ha_state()
|
||||
|
||||
def turn_on(self, **kwargs):
|
||||
def turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the light on for 30 seconds."""
|
||||
self._set_light(ON_STATE)
|
||||
|
||||
def turn_off(self, **kwargs):
|
||||
def turn_off(self, **kwargs: Any) -> None:
|
||||
"""Turn the light off."""
|
||||
self._set_light(OFF_STATE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user