register service after async_add_entities

This commit is contained in:
Bas Nijholt 2020-10-05 12:17:06 +02:00
commit 91735ebd58

View file

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