From 1aa6f8f3455b2a90c77f7eb423552f32062c50a9 Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Fri, 25 Sep 2020 00:00:35 +0200 Subject: [PATCH] set name correctly --- custom_components/adaptive_lighting/switch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index c5e8f1b8..36ad2c5b 100755 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -129,8 +129,6 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): def __init__(self, hass, config_entry): """Initialize the Adaptive Lighting switch.""" self.hass = hass - self._entity_id = f"switch.{DOMAIN}_{slugify(name)}" - self._icon = ICON data = validate(config_entry) self._name = data[CONF_NAME] @@ -155,6 +153,10 @@ class AdaptiveSwitch(SwitchEntity, RestoreEntity): self._sunset_time = data[CONF_SUNSET_TIME] self._transition = data[CONF_TRANSITION] + # Set other attributes + self._icon = ICON + self._entity_id = f"switch.{DOMAIN}_{slugify(self._name)}" + # Initialize attributes that will be set in self._update_attrs self._percent = None self._brightness = None