mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 10:17:09 +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."""
|
||||
lights = []
|
||||
for address, device_config in config[CONF_DEVICES].items():
|
||||
device = {}
|
||||
device["name"] = device_config[CONF_NAME]
|
||||
device["address"] = address
|
||||
light = ZenggeLight(device)
|
||||
light = ZenggeLight(device_config[CONF_NAME], address)
|
||||
if light.is_valid:
|
||||
lights.append(light)
|
||||
|
||||
@ -56,22 +53,20 @@ class ZenggeLight(LightEntity):
|
||||
|
||||
_attr_supported_color_modes = {ColorMode.HS, ColorMode.WHITE}
|
||||
|
||||
def __init__(self, device):
|
||||
def __init__(self, name: str, address: str) -> None:
|
||||
"""Initialize the light."""
|
||||
|
||||
self._attr_name = device["name"]
|
||||
self._attr_unique_id = device["address"]
|
||||
self._attr_name = name
|
||||
self._attr_unique_id = address
|
||||
self.is_valid = True
|
||||
self._bulb = zengge(device["address"])
|
||||
self._bulb = zengge(address)
|
||||
self._white = 0
|
||||
self._attr_brightness = 0
|
||||
self._attr_hs_color = (0, 0)
|
||||
self._attr_is_on = False
|
||||
if self._bulb.connect() is False:
|
||||
self.is_valid = False
|
||||
_LOGGER.error(
|
||||
"Failed to connect to bulb %s, %s", device["address"], device["name"]
|
||||
)
|
||||
_LOGGER.error("Failed to connect to bulb %s, %s", address, name)
|
||||
return
|
||||
|
||||
@property
|
||||
|
Loading…
x
Reference in New Issue
Block a user