Procházet zdrojové kódy

Use config_id rather than entity in config flow.

This is in preparation to allow multiple entities of the same type.
Jason Rumney před 4 roky
rodič
revize
00e88b0b3f
1 změnil soubory, kde provedl 6 přidání a 4 odebrání
  1. 6 4
      custom_components/tuya_local/config_flow.py

+ 6 - 4
custom_components/tuya_local/config_flow.py

@@ -97,9 +97,9 @@ class ConfigFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
         config = get_config(self.data[CONF_TYPE])
         schema = {vol.Required(CONF_NAME, default=config.name): str}
         e = config.primary_entity
-        schema[vol.Optional(e.entity, default=True)] = bool
+        schema[vol.Optional(e.config_id, default=True)] = bool
         for e in config.secondary_entities():
-            schema[vol.Optional(e.entity, default=not e.deprecated)] = bool
+            schema[vol.Optional(e.config_id, default=not e.deprecated)] = bool
 
         return self.async_show_form(
             step_id="choose_entities",
@@ -141,9 +141,11 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
         if cfg is None:
             return self.async_abort(reason="not_supported")
         e = cfg.primary_entity
-        schema[vol.Optional(e.entity, default=config.get(e.entity, True))] = bool
+        schema[vol.Optional(e.config_id, default=config.get(e.config_id, True))] = bool
         for e in cfg.secondary_entities():
-            schema[vol.Optional(e.entity, default=config.get(e.entity, False))] = bool
+            schema[
+                vol.Optional(e.config_id, default=config.get(e.config_id, False))
+            ] = bool
         return self.async_show_form(
             step_id="user",
             data_schema=vol.Schema(schema),