Skip to content

Commit

Permalink
config flow updates and allowing to update connection details
Browse files Browse the repository at this point in the history
  • Loading branch information
hikirsch committed Jan 7, 2025
1 parent 6b003b0 commit 47c99a6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 57 deletions.
26 changes: 10 additions & 16 deletions custom_components/htd/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,10 @@ async def async_step_options(self, user_input=None):
CONF_UNIQUE_ID: self.unique_id,
}

options = {
**user_input,
}

return self.async_create_entry(
title=user_input[CONF_DEVICE_NAME],
data=config_entry,
options=options
options={}
)

model_info = get_model_info(self.host, self.port)
Expand All @@ -148,25 +144,23 @@ class HtdOptionsFlowHandler(OptionsFlowWithConfigEntry):
async def async_step_init(self, user_input: dict[str, Any] | None = None):
if user_input is not None:
options = {
**self.options, **user_input,
**self.config_entry.data,
**user_input
}

return self.async_create_entry(
title=options[CONF_DEVICE_NAME], data=options
self.hass.config_entries.async_update_entry(
self.config_entry,
data=options
)

friendly_name = self.config_entry.title
return self.async_create_entry(title=self.config_entry.title, data={})

return self.async_show_form(
step_id='options',
data_schema=get_options_schema(
friendly_name=friendly_name,
)
step_id='init',
data_schema=get_connection_settings_schema(self.config_entry)
)

def get_options_schema(
friendly_name: str,
):
def get_options_schema(friendly_name: str):
return vol.Schema(
{
vol.Required(
Expand Down
2 changes: 1 addition & 1 deletion custom_components/htd/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"@hikirsch"
],
"name": "Home Theater Direct",
"version": "2.0.0-alpha.4",
"version": "2.0.0-alpha.5",
"iot_class": "local_push",
"integration_type": "hub",
"dependencies": [],
Expand Down
56 changes: 16 additions & 40 deletions custom_components/htd/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,41 @@
"config": {
"step": {
"user": {
"title": "HTD Device Setup"
"title": "Home Theater Direct",
"data": {
"device_kind": "Type of device",
"mca": "MC/MCA66",
"lync": "Lync 6/12",
"host": "Host name or IP Address",
"port": "Port (default is 10006)"
}
},
"options": {
"title": "HTD MC/MCA-66 Setup",
"title": "Home Theater Direct",
"description": "Setup the gateway",
"data": {
"device_name": "Device name",
"active_zones": "Number of active zones",
"update_volume_on_change": "Show incremental volume updates on change when setting volume"
"device_name": "Device name"
}
}
},
"error": {
"no_connection": "Could not connect",
"missing_input": "Please fill in required fields"
},
"abort": {
"no_home": "No home coordinates are set in the Home Assistant configuration"
}
},
"options": {
"step": {
"init": {
"title": "Configure Device",
"menu_options": {
"options": "User Options",
"sources": "Source Names",
"advanced": "Advanced Options"
}
},
"options": {
"title": "HTD MC/MCA-66 Setup",
"description": "Setup the gateway",
"data": {
"device_name": "Device name",
"active_zones": "Number of active zones",
"update_volume_on_change": "Show incremental volume updates on change when setting volume"
"device_kind": "Type of device",
"host": "Host name or IP Address",
"port": "Port (default is 10006)"
}
},
"sources": {
"title": "Source Names/Aliases",
"description": "Set an name/alias for any input source",
"data": {
"source_1": "Source 1",
"source_2": "Source 2",
"source_3": "Source 3",
"source_4": "Source 4",
"source_5": "Source 5",
"source_6": "Source 6"
}
},
"advanced": {
"title": "Advanced Options",
"description": "Please use with caution",
"data": {
"retry_attempts": "Number of retries to re-attempt if a bad response.",
"socket_timeout": "Connection timeout (in milliseconds)",
"command_delay": "Delay in between commands (in milliseconds)"
}
"options": {
"title": "Home Theater Direct",
"description": "Choose a name for this gateway."
}
}
}
Expand Down

0 comments on commit 47c99a6

Please sign in to comment.