Skip to content

Commit

Permalink
fix(confid): Fixed updating account information when SMETS1 isn't set…
Browse files Browse the repository at this point in the history
… in configuration

This can occur if users setup their account information before SMETS1 was introduced
  • Loading branch information
BottlecapDave committed Oct 17, 2021
1 parent 0504b69 commit 4b1eecd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/octopus_energy/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,18 +140,22 @@ async def async_step_init(self, user_input):
config = dict(self._entry.data)
if self._entry.options is not None:
config.update(self._entry.options)

isSmets1 = False
if CONFIG_SMETS1 in config:
isSmets1 = config[CONFIG_SMETS1]

return self.async_show_form(
step_id="user", data_schema=vol.Schema({
vol.Optional(CONFIG_SMETS1, default=config[CONFIG_SMETS1]): bool,
vol.Required(CONFIG_MAIN_API_KEY, default=config[CONFIG_MAIN_API_KEY]): str,
vol.Required(CONFIG_SMETS1, default=isSmets1): bool,
})
)

return self.async_abort(reason="not_supported")

async def async_step_user(self, user_input):
"""Manage the options for the custom component."""
errors = {}

if user_input is not None:
config = dict(self._entry.data)
Expand Down
1 change: 1 addition & 0 deletions custom_components/octopus_energy/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"title": "Update Account Info",
"description": "Update your basic account information. This can be found at https://octopus.energy/dashboard/developer/.",
"data": {
"Api key": "Api key",
"SMETS1": "Is SMETS1 Gas Meter"
}
}
Expand Down

0 comments on commit 4b1eecd

Please sign in to comment.