Skip to content

Commit 5ba957c

Browse files
authored
Ensure input values are not lost in the event of an error (#182)
1 parent 3b82bde commit 5ba957c

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

custom_components/remote_homeassistant/config_flow.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,19 @@ async def async_step_connection_details(self, user_input=None):
129129
self._abort_if_unique_id_configured()
130130
return self.async_create_entry(title=info["title"], data=user_input)
131131

132-
host = self.prefill.get(CONF_HOST) or vol.UNDEFINED
133-
port = self.prefill.get(CONF_PORT) or vol.UNDEFINED
134-
secure = self.prefill.get(CONF_SECURE) or vol.UNDEFINED
132+
user_input = user_input or dict()
133+
host = user_input.get(CONF_HOST, self.prefill.get(CONF_HOST) or vol.UNDEFINED)
134+
port = user_input.get(CONF_PORT, self.prefill.get(CONF_PORT) or vol.UNDEFINED)
135+
secure = user_input.get(CONF_SECURE, self.prefill.get(CONF_SECURE) or vol.UNDEFINED)
135136
return self.async_show_form(
136137
step_id="connection_details",
137138
data_schema=vol.Schema(
138139
{
139140
vol.Required(CONF_HOST, default=host): str,
140141
vol.Required(CONF_PORT, default=port): int,
141-
vol.Required(CONF_ACCESS_TOKEN): str,
142+
vol.Required(CONF_ACCESS_TOKEN, default=user_input.get(CONF_ACCESS_TOKEN, vol.UNDEFINED)): str,
142143
vol.Optional(CONF_SECURE, default=secure): bool,
143-
vol.Optional(CONF_VERIFY_SSL, default=True): bool,
144+
vol.Optional(CONF_VERIFY_SSL, default=user_input.get(CONF_VERIFY_SSL, True)): bool,
144145
}
145146
),
146147
errors=errors,

0 commit comments

Comments
 (0)