diff --git a/homeassistant/components/yeelight/__init__.py b/homeassistant/components/yeelight/__init__.py index b45bee87c626..dc9f359f8cd3 100644 --- a/homeassistant/components/yeelight/__init__.py +++ b/homeassistant/components/yeelight/__init__.py @@ -37,7 +37,7 @@ from .const import ( CONF_NIGHTLIGHT_SWITCH_TYPE, CONF_SAVE_ON_CHANGE, CONF_TRANSITION, - DATA_CUSTOM_EFFECTS, + DATA_CUSTOM_EFFECTS_KEY, DEFAULT_MODE_MUSIC, DEFAULT_NAME, DEFAULT_NIGHTLIGHT_SWITCH, @@ -116,10 +116,7 @@ CONFIG_SCHEMA = vol.Schema( async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the Yeelight bulbs.""" conf = config.get(DOMAIN, {}) - # pylint: disable-next=hass-use-runtime-data - hass.data[DOMAIN] = { - DATA_CUSTOM_EFFECTS: conf.get(CONF_CUSTOM_EFFECTS, {}), - } + hass.data[DATA_CUSTOM_EFFECTS_KEY] = conf.get(CONF_CUSTOM_EFFECTS, []) # Make sure the scanner is always started in case we are # going to retry via ConfigEntryNotReady and the bulb has changed # ip diff --git a/homeassistant/components/yeelight/const.py b/homeassistant/components/yeelight/const.py index f93c78bec33c..2ef3c2471fc2 100644 --- a/homeassistant/components/yeelight/const.py +++ b/homeassistant/components/yeelight/const.py @@ -1,10 +1,13 @@ """Support for Xiaomi Yeelight WiFi color bulb.""" from datetime import timedelta +from typing import Any from homeassistant.const import Platform +from homeassistant.util.hass_dict import HassKey DOMAIN = "yeelight" +DATA_CUSTOM_EFFECTS_KEY: HassKey[list[dict[str, Any]]] = HassKey(DOMAIN) STATE_CHANGE_TIME = 0.40 # seconds @@ -43,8 +46,6 @@ CONF_CUSTOM_EFFECTS = "custom_effects" CONF_NIGHTLIGHT_SWITCH_TYPE = "nightlight_switch_type" CONF_NIGHTLIGHT_SWITCH = "nightlight_switch" -DATA_CUSTOM_EFFECTS = "custom_effects" - ATTR_COUNT = "count" ATTR_ACTION = "action" ATTR_TRANSITIONS = "transitions" diff --git a/homeassistant/components/yeelight/light.py b/homeassistant/components/yeelight/light.py index 30c0a4a949c1..eb1ef7881dd5 100644 --- a/homeassistant/components/yeelight/light.py +++ b/homeassistant/components/yeelight/light.py @@ -51,9 +51,8 @@ from .const import ( CONF_NIGHTLIGHT_SWITCH, CONF_SAVE_ON_CHANGE, CONF_TRANSITION, - DATA_CUSTOM_EFFECTS, + DATA_CUSTOM_EFFECTS_KEY, DATA_UPDATED, - DOMAIN, MODELS_WITH_DELAYED_ON_TRANSITION, POWER_STATE_CHANGE_TIME, ) @@ -218,7 +217,9 @@ def _transitions_config_parser(transitions): @callback -def _parse_custom_effects(effects_config) -> dict[str, dict[str, Any]]: +def _parse_custom_effects( + effects_config: list[dict[str, Any]], +) -> dict[str, dict[str, Any]]: effects = {} for config in effects_config: params = config[CONF_FLOW_PARAMS] @@ -280,8 +281,7 @@ async def async_setup_entry( async_add_entities: AddConfigEntryEntitiesCallback, ) -> None: """Set up Yeelight from a config entry.""" - # pylint: disable-next=hass-use-runtime-data - custom_effects = _parse_custom_effects(hass.data[DOMAIN][DATA_CUSTOM_EFFECTS]) + custom_effects = _parse_custom_effects(hass.data[DATA_CUSTOM_EFFECTS_KEY]) device = config_entry.runtime_data _LOGGER.debug("Adding %s", device.name)