mirror of
https://github.com/home-assistant/core
synced 2024-08-02 23:40:32 +02:00
Improve type hint in blebox light entity (#77013)
* Improve type hint in blebox light entity * Adjust * Adjust supported_features * Adjust effect_list property * Improve base class
This commit is contained in:
parent
cbeaea98d1
commit
61af82223f
@ -3,6 +3,7 @@ import logging
|
||||
|
||||
from blebox_uniapi.box import Box
|
||||
from blebox_uniapi.error import Error
|
||||
from blebox_uniapi.feature import Feature
|
||||
from blebox_uniapi.session import ApiHost
|
||||
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
@ -83,7 +84,7 @@ def create_blebox_entities(
|
||||
class BleBoxEntity(Entity):
|
||||
"""Implements a common class for entities representing a BleBox feature."""
|
||||
|
||||
def __init__(self, feature):
|
||||
def __init__(self, feature: Feature) -> None:
|
||||
"""Initialize a BleBox entity."""
|
||||
self._feature = feature
|
||||
self._attr_name = feature.full_name
|
||||
@ -97,7 +98,7 @@ class BleBoxEntity(Entity):
|
||||
sw_version=product.firmware_version,
|
||||
)
|
||||
|
||||
async def async_update(self):
|
||||
async def async_update(self) -> None:
|
||||
"""Update the entity state."""
|
||||
try:
|
||||
await self._feature.async_update()
|
||||
|
@ -56,11 +56,14 @@ COLOR_MODE_MAP = {
|
||||
class BleBoxLightEntity(BleBoxEntity, LightEntity):
|
||||
"""Representation of BleBox lights."""
|
||||
|
||||
def __init__(self, feature):
|
||||
_feature: blebox_uniapi.light.Light
|
||||
|
||||
def __init__(self, feature: blebox_uniapi.light.Light) -> None:
|
||||
"""Initialize a BleBox light."""
|
||||
super().__init__(feature)
|
||||
self._attr_supported_color_modes = {self.color_mode}
|
||||
self._attr_supported_features = LightEntityFeature.EFFECT
|
||||
if feature.effect_list:
|
||||
self._attr_supported_features = LightEntityFeature.EFFECT
|
||||
|
||||
@property
|
||||
def is_on(self) -> bool:
|
||||
@ -91,7 +94,7 @@ class BleBoxLightEntity(BleBoxEntity, LightEntity):
|
||||
return color_mode_tmp
|
||||
|
||||
@property
|
||||
def effect_list(self) -> list[str] | None:
|
||||
def effect_list(self) -> list[str]:
|
||||
"""Return the list of supported effects."""
|
||||
return self._feature.effect_list
|
||||
|
||||
@ -125,7 +128,7 @@ class BleBoxLightEntity(BleBoxEntity, LightEntity):
|
||||
return None
|
||||
return tuple(blebox_uniapi.light.Light.rgb_hex_to_rgb_list(rgbww_hex))
|
||||
|
||||
async def async_turn_on(self, **kwargs):
|
||||
async def async_turn_on(self, **kwargs: Any) -> None:
|
||||
"""Turn the light on."""
|
||||
|
||||
rgbw = kwargs.get(ATTR_RGBW_COLOR)
|
||||
|
Loading…
Reference in New Issue
Block a user