Skip to content

Commit

Permalink
Fix discovery unique_id
Browse files Browse the repository at this point in the history
  • Loading branch information
Dmitry Mamontov committed Apr 6, 2022
1 parent e17e7d3 commit fd0d15a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions custom_components/miwifi/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ async def async_step_discovery_confirm(
errors: dict[str, str] = {}

if user_input is not None:
if self._discovered_device is None:
await self.async_set_unique_id(user_input[CONF_IP_ADDRESS])
self._abort_if_unique_id_configured()

code: codes = await async_verify_access(
self.hass, user_input[CONF_IP_ADDRESS], user_input[CONF_PASSWORD]
)
Expand Down
4 changes: 2 additions & 2 deletions custom_components/miwifi/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def async_discover_devices(client: AsyncClient) -> list:
):
return []

devices = [response["graph"]["ip"]]
devices = [response["graph"]["ip"].strip()]

if "leafs" in response["graph"]:
devices = parse_leafs(devices, response["graph"]["leafs"])
Expand Down Expand Up @@ -121,7 +121,7 @@ def parse_leafs(devices: list, leafs: list) -> list:
if "ip" not in leaf or len(leaf["ip"]) == 0:
continue

devices.append(leaf["ip"])
devices.append(leaf["ip"].strip())

if "leafs" in leaf:
devices = parse_leafs(devices, leaf["leafs"])
Expand Down
2 changes: 1 addition & 1 deletion custom_components/miwifi/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"domain": "miwifi",
"name": "MiWiFi",
"version": "2.0.8",
"version": "2.0.9",
"documentation": "https://github.com/dmamontov/hass-miwifi",
"issue_tracker": "https://github.com/dmamontov/hass-miwifi/issues",
"config_flow": true,
Expand Down

0 comments on commit fd0d15a

Please sign in to comment.