Skip to content

Commit

Permalink
Fixed options for old installations
Browse files Browse the repository at this point in the history
  • Loading branch information
kukulich committed Sep 30, 2022
1 parent bcd6db0 commit 25af8cf
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions custom_components/jablotron100/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,13 @@ async def async_step_settings(self, user_input: Dict[str, Any] | None = None):
else:
fields[vol.Optional(CONF_NUMBER_OF_DEVICES, default=self._config[CONF_NUMBER_OF_DEVICES])] = number_of_devices_validation

number_of_pg_outputs_validation = create_range_validation(self._config[CONF_NUMBER_OF_PG_OUTPUTS], MAX_PG_OUTPUTS)
configured_number_of_pg_outputs = self._config[CONF_NUMBER_OF_PG_OUTPUTS] if CONF_NUMBER_OF_PG_OUTPUTS in self._config else 0
number_of_pg_outputs_validation = create_range_validation(configured_number_of_pg_outputs, MAX_PG_OUTPUTS)

if self._config[CONF_NUMBER_OF_PG_OUTPUTS] > 0:
fields[vol.Required(CONF_NUMBER_OF_PG_OUTPUTS, default=self._config[CONF_NUMBER_OF_PG_OUTPUTS])] = number_of_pg_outputs_validation
if configured_number_of_pg_outputs > 0:
fields[vol.Required(CONF_NUMBER_OF_PG_OUTPUTS, default=configured_number_of_pg_outputs)] = number_of_pg_outputs_validation
else:
fields[vol.Optional(CONF_NUMBER_OF_PG_OUTPUTS, default=self._config[CONF_NUMBER_OF_PG_OUTPUTS])] = number_of_pg_outputs_validation
fields[vol.Optional(CONF_NUMBER_OF_PG_OUTPUTS, default=configured_number_of_pg_outputs)] = number_of_pg_outputs_validation

return self.async_show_form(
step_id="settings",
Expand Down

0 comments on commit 25af8cf

Please sign in to comment.