do not show options if managed via YAML

This commit is contained in:
Bas Nijholt 2020-09-24 23:28:03 +02:00
commit 2c0ab9d929
3 changed files with 6 additions and 4 deletions

View file

@ -76,6 +76,9 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
async def async_step_init(self, user_input=None):
"""Handle options flow."""
conf = self.config_entry
if conf.source == config_entries.SOURCE_IMPORT:
return self.async_show_form(step_id="init", data_schema={})
errors = {}
if user_input is not None:
validate_options(user_input, errors)
@ -87,10 +90,9 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
lights_tuple = (*validation_tuples[0][:-1], all_lights)
validation_tuples[0] = lights_tuple
options = self.config_entry.options
options_schema = vol.Schema(
{
vol.Optional(key, default=options.get(key, default)): validation
vol.Optional(key, default=conf.options.get(key, default)): validation
for key, default, validation in validation_tuples
}
)

View file

@ -18,7 +18,7 @@
"step": {
"init": {
"title": "Adaptive Lighting options",
"description": "All settings for a Adaptive Lighting component. The option names correspond with the YAML settings.",
"description": "All settings for a Adaptive Lighting component. The option names correspond with the YAML settings. No options are shown if you have this entry defined in YAML.",
"data": {
"lights_brightness": "lights_brightness",
"lights_mired": "lights_mired",

View file

@ -18,7 +18,7 @@
"step": {
"init": {
"title": "Adaptive Lighting options",
"description": "All settings for a Adaptive Lighting component. The option names correspond with the YAML settings.",
"description": "All settings for a Adaptive Lighting component. The option names correspond with the YAML settings. No options are shown if you have this entry defined in YAML.",
"data": {
"lights_brightness": "lights_brightness",
"lights_mired": "lights_mired",