Skip to content
This repository has been archived by the owner on Jun 20, 2022. It is now read-only.

Commit

Permalink
Fix using wrong method for accessing discovery data
Browse files Browse the repository at this point in the history
  • Loading branch information
DCSBL committed Dec 12, 2021
1 parent 5651596 commit 13fb956
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions custom_components/homewizard_energy/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,33 @@ async def async_step_user(

return await self.async_step_check(entry_info)

async def async_step_zeroconf(self, discovery_info):
async def async_step_zeroconf(
self, discovery_info: zeroconf.ZeroconfServiceInfo
) -> FlowResult:
"""Handle zeroconf discovery."""

_LOGGER.debug("config_flow async_step_zeroconf")

# Validate doscovery entry
if (
"host" not in discovery_info
or "api_enabled" not in discovery_info["properties"]
or "path" not in discovery_info["properties"]
or "product_name" not in discovery_info["properties"]
or "product_type" not in discovery_info["properties"]
or "serial" not in discovery_info["properties"]
"api_enabled" not in discovery_info.properties
or "path" not in discovery_info.properties
or "product_name" not in discovery_info.properties
or "product_type" not in discovery_info.properties
or "serial" not in discovery_info.properties
):
return self.async_abort(reason="invalid_discovery_parameters")

if (discovery_info["properties"]["path"]) != "/api/v1":
if (discovery_info.properties["path"]) != "/api/v1":
return self.async_abort(reason="unsupported_api_version")

if (discovery_info["properties"]["api_enabled"]) != "1":
if (discovery_info.properties["api_enabled"]) != "1":
return self.async_abort(reason="api_not_enabled")

# Pass parameters
entry_info = {
CONF_IP_ADDRESS: discovery_info["host"],
CONF_PORT: discovery_info["port"],
CONF_IP_ADDRESS: discovery_info.host,
CONF_PORT: discovery_info.port,
}

return await self.async_step_check(entry_info)
Expand Down

0 comments on commit 13fb956

Please sign in to comment.