set name correctly

This commit is contained in:
Bas Nijholt 2020-09-25 00:00:35 +02:00
commit 1aa6f8f345

View file

@ -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