From 4d71b42b38ba49504dcadda8b41a9281d037da39 Mon Sep 17 00:00:00 2001 From: Johan Isacsson Date: Mon, 13 Dec 2021 14:47:22 +0100 Subject: [PATCH] Fixed models dropdown menu bug --- custom_components/sunspec/config_flow.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/custom_components/sunspec/config_flow.py b/custom_components/sunspec/config_flow.py index aa75d78..540cbec 100644 --- a/custom_components/sunspec/config_flow.py +++ b/custom_components/sunspec/config_flow.py @@ -96,7 +96,8 @@ async def _show_config_form(self, user_input): # pylint: disable=unused-argumen async def _show_settings_form(self, user_input): # pylint: disable=unused-argument """Show the configuration form to edit settings data.""" models = set(await self.client.async_get_models()) - model_filter = {str(model): str(model) for model in sorted(models)} + model_filter = {str(model) for model in sorted(models)} + default_enabled = {str(model) for model in DEFAULT_MODELS if model in models} return self.async_show_form( step_id="settings", data_schema=vol.Schema( @@ -107,7 +108,7 @@ async def _show_settings_form(self, user_input): # pylint: disable=unused-argum ): int, vol.Optional( CONF_ENABLED_MODELS, - default=DEFAULT_MODELS, + default=default_enabled, ): cv.multi_select(model_filter), } ),