From f6800e6968c22837fbebbde28c804e892974789d Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Fri, 31 May 2024 21:35:42 +0200 Subject: [PATCH] Improve typing in Zengge (#118547) --- homeassistant/components/zengge/light.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/homeassistant/components/zengge/light.py b/homeassistant/components/zengge/light.py index 5de4f3fdce3..6657bfb9edd 100644 --- a/homeassistant/components/zengge/light.py +++ b/homeassistant/components/zengge/light.py @@ -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