Merge pull request #350 from danaues/missing_light_fix

Fix missing light entities in options list
This commit is contained in:
Bas Nijholt 2022-10-27 20:48:31 -07:00 committed by GitHub
commit 1efbbe3bb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -14,7 +14,7 @@ from .const import ( # pylint: disable=unused-import
NONE_STR,
VALIDATION_TUPLES,
)
from .switch import _supported_features
from .switch import _supported_features, validate
_LOGGER = logging.getLogger(__name__)
@ -82,6 +82,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_init(self, user_input=None):
"""Handle options flow."""
conf = self.config_entry
data = validate(conf)
if conf.source == config_entries.SOURCE_IMPORT:
return self.async_show_form(step_id="init", data_schema=None)
errors = {}
@ -95,6 +96,9 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
for light in self.hass.states.async_entity_ids("light")
if _supported_features(self.hass, light)
]
for configured_light in data[CONF_LIGHTS]:
if not configured_light in all_lights:
all_lights.append(configured_light)
to_replace = {CONF_LIGHTS: cv.multi_select(sorted(all_lights))}
options_schema = {}