Add local_ip unique_id & icon and single_instance_allowed (#33483)
* Add config flow + sensor unique_id & icon to local_ip * single_instance_allowed * Fix test * Martin's review * Name deprecated
This commit is contained in:
parent
dd7fbef948
commit
45b28b8b00
8 changed files with 66 additions and 37 deletions
|
@ -1,9 +1,8 @@
|
|||
"""Config flow for local_ip."""
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
|
||||
from . import DOMAIN
|
||||
from .const import DOMAIN
|
||||
|
||||
|
||||
class SimpleConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
|
@ -14,20 +13,14 @@ class SimpleConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
|
||||
async def async_step_user(self, user_input=None):
|
||||
"""Handle the initial step."""
|
||||
if user_input is not None:
|
||||
if any(
|
||||
user_input["name"] == entry.data["name"]
|
||||
for entry in self._async_current_entries()
|
||||
):
|
||||
return self.async_abort(reason="already_configured")
|
||||
|
||||
return self.async_create_entry(title=user_input["name"], data=user_input)
|
||||
if self._async_current_entries():
|
||||
return self.async_abort(reason="single_instance_allowed")
|
||||
|
||||
return self.async_show_form(
|
||||
step_id="user",
|
||||
data_schema=vol.Schema({vol.Required("name", default=DOMAIN): str}),
|
||||
errors={},
|
||||
)
|
||||
if user_input is None:
|
||||
return self.async_show_form(step_id="user")
|
||||
|
||||
return self.async_create_entry(title=DOMAIN, data=user_input)
|
||||
|
||||
async def async_step_import(self, import_info):
|
||||
"""Handle import from config file."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue