Skip to content

Commit

Permalink
Use menu to select between device types
Browse files Browse the repository at this point in the history
  • Loading branch information
rrooggiieerr committed Jul 6, 2024
1 parent 1ca8e7a commit 46419a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
23 changes: 3 additions & 20 deletions custom_components/homeduino/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,27 +66,10 @@ async def async_step_user(
if not HomeduinoCoordinator.instance(self.hass).has_transceiver():
return await self.async_step_setup_transceiver(user_input)

if user_input is not None:
user_selection = user_input[CONF_TYPE]
if user_selection == "transceiver":
return await self.async_step_setup_transceiver()
if user_selection == "rf_device":
return await self.async_step_setup_rf_device()

device_types = ["transceiver", "rf_device"]

schema = vol.Schema(
{
vol.Required(CONF_TYPE): SelectSelector(
SelectSelectorConfig(
options=device_types,
mode=SelectSelectorMode.LIST,
translation_key="device_types",
)
)
}
return self.async_show_menu(
step_id="user",
menu_options=["setup_transceiver", "setup_rf_device"],
)
return self.async_show_form(step_id="user", data_schema=schema)

async def async_step_setup_transceiver(
self, user_input: dict[str, Any] | None = None
Expand Down
8 changes: 7 additions & 1 deletion custom_components/homeduino/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
"unknown": "Unexpected error"
},
"step": {
"user": {
"menu_options": {
"setup_transceiver": "Homeduino Transceiver",
"setup_rf_device": "RF Device"
}
},
"setup_serial": {
"title": "Homeduino Transceiver",
"data": {
Expand Down Expand Up @@ -41,7 +47,7 @@
}
},
"setup_rf_device": {
"title": "Homeduino RF Device",
"title": "RF Device",
"data": {
"rf_id": "Device ID",
"rf_protocol": "Protocol",
Expand Down

0 comments on commit 46419a2

Please sign in to comment.