Implemented multi page config to accommodate more options #68

This commit is contained in:
tomaae 2020-12-10 06:10:00 +01:00
parent 5aa6652301
commit bbd29aad48
2 changed files with 42 additions and 26 deletions

View file

@ -149,16 +149,16 @@ class MikrotikControllerOptionsFlowHandler(OptionsFlow):
async def async_step_init(self, user_input=None):
"""Manage the options."""
return await self.async_step_device_tracker(user_input)
return await self.async_step_basic_options(user_input)
async def async_step_device_tracker(self, user_input=None):
"""Manage the device tracker options."""
async def async_step_basic_options(self, user_input=None):
"""Manage the basic options options."""
if user_input is not None:
self.options.update(user_input)
return self.async_create_entry(title="", data=self.options)
return await self.async_step_device_tracker()
return self.async_show_form(
step_id="device_tracker",
step_id="basic_options",
data_schema=vol.Schema(
{
vol.Optional(
@ -179,6 +179,20 @@ class MikrotikControllerOptionsFlowHandler(OptionsFlow):
CONF_TRACK_IFACE_CLIENTS, DEFAULT_TRACK_IFACE_CLIENTS
),
): bool,
}
),
)
async def async_step_device_tracker(self, user_input=None):
"""Manage the device tracker options."""
if user_input is not None:
self.options.update(user_input)
return self.async_create_entry(title="", data=self.options)
return self.async_show_form(
step_id="device_tracker",
data_schema=vol.Schema(
{
vol.Optional(
CONF_TRACK_HOSTS,
default=self.config_entry.options.get(

View file

@ -1,41 +1,43 @@
{
"config": {
"title": "Mikrotik Router",
"error": {
"cannot_connect": "Cannot connect to Mikrotik.",
"connection_timeout": "Mikrotik connection timeout.",
"name_exists": "Name already exists.",
"ssl_handshake_failure": "SSL handshake failure",
"wrong_login": "Invalid user name or password."
},
"step": {
"user": {
"title": "Mikrotik Router",
"description": "Set up Mikrotik Router integration.",
"data": {
"name": "Name of the integration",
"host": "Host",
"port": "Port",
"username": "Username",
"name": "Name of the integration",
"password": "Password",
"ssl": "Use SSL"
}
}
"port": "Port",
"ssl": "Use SSL",
"username": "Username"
},
"error": {
"name_exists": "Name already exists.",
"cannot_connect": "Cannot connect to Mikrotik.",
"ssl_handshake_failure": "SSL handshake failure",
"connection_timeout": "Mikrotik connection timeout.",
"wrong_login": "Invalid user name or password."
"description": "Set up Mikrotik Router integration.",
"title": "Mikrotik Router"
}
}
},
"options": {
"step": {
"init": {
"data": {}
},
"device_tracker": {
"basic_options": {
"data": {
"scan_interval": "Scan interval (requires HA restart)",
"track_iface_clients": "Show client MAC and IP on interfaces",
"unit_of_measurement": "Unit of measurement",
"unit_of_measurement": "Unit of measurement"
},
"title": "Basic options"
},
"device_tracker": {
"data": {
"track_network_hosts": "Track network devices",
"track_network_hosts_timeout": "Track network devices timeout (seconds)"
}
},
"title": "Device tracking options"
}
}
}