From 91735ebd58e41670c88a77a4ef04a610438b552c Mon Sep 17 00:00:00 2001 From: Bas Nijholt Date: Mon, 5 Oct 2020 12:17:06 +0200 Subject: [PATCH] register service after async_add_entities --- custom_components/adaptive_lighting/switch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/custom_components/adaptive_lighting/switch.py b/custom_components/adaptive_lighting/switch.py index 4fa0627f..9272413b 100755 --- a/custom_components/adaptive_lighting/switch.py +++ b/custom_components/adaptive_lighting/switch.py @@ -150,6 +150,8 @@ async def async_setup_entry(hass, config_entry: ConfigEntry, async_add_entities: data[config_entry.entry_id]["sleep_mode_switch"] = sleep_mode_switch data[config_entry.entry_id][SWITCH_DOMAIN] = switch + async_add_entities([switch, sleep_mode_switch], update_before_add=True) + # Register `apply` service platform = entity_platform.current_platform.get() platform.async_register_entity_service( @@ -167,7 +169,6 @@ async def async_setup_entry(hass, config_entry: ConfigEntry, async_add_entities: }, handle_apply, ) - async_add_entities([switch, sleep_mode_switch], update_before_add=True) def validate(config_entry):