mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Improve typing in Zengge (#118547)
This commit is contained in:
parent
41e852a01b
commit
f6800e6968
@ -41,10 +41,7 @@ def setup_platform(
|
|||||||
"""Set up the Zengge platform."""
|
"""Set up the Zengge platform."""
|
||||||
lights = []
|
lights = []
|
||||||
for address, device_config in config[CONF_DEVICES].items():
|
for address, device_config in config[CONF_DEVICES].items():
|
||||||
device = {}
|
light = ZenggeLight(device_config[CONF_NAME], address)
|
||||||
device["name"] = device_config[CONF_NAME]
|
|
||||||
device["address"] = address
|
|
||||||
light = ZenggeLight(device)
|
|
||||||
if light.is_valid:
|
if light.is_valid:
|
||||||
lights.append(light)
|
lights.append(light)
|
||||||
|
|
||||||
@ -56,22 +53,20 @@ class ZenggeLight(LightEntity):
|
|||||||
|
|
||||||
_attr_supported_color_modes = {ColorMode.HS, ColorMode.WHITE}
|
_attr_supported_color_modes = {ColorMode.HS, ColorMode.WHITE}
|
||||||
|
|
||||||
def __init__(self, device):
|
def __init__(self, name: str, address: str) -> None:
|
||||||
"""Initialize the light."""
|
"""Initialize the light."""
|
||||||
|
|
||||||
self._attr_name = device["name"]
|
self._attr_name = name
|
||||||
self._attr_unique_id = device["address"]
|
self._attr_unique_id = address
|
||||||
self.is_valid = True
|
self.is_valid = True
|
||||||
self._bulb = zengge(device["address"])
|
self._bulb = zengge(address)
|
||||||
self._white = 0
|
self._white = 0
|
||||||
self._attr_brightness = 0
|
self._attr_brightness = 0
|
||||||
self._attr_hs_color = (0, 0)
|
self._attr_hs_color = (0, 0)
|
||||||
self._attr_is_on = False
|
self._attr_is_on = False
|
||||||
if self._bulb.connect() is False:
|
if self._bulb.connect() is False:
|
||||||
self.is_valid = False
|
self.is_valid = False
|
||||||
_LOGGER.error(
|
_LOGGER.error("Failed to connect to bulb %s, %s", address, name)
|
||||||
"Failed to connect to bulb %s, %s", device["address"], device["name"]
|
|
||||||
)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
Loading…
x
Reference in New Issue
Block a user