Use DhcpServiceInfo in nuki (#60046)
This commit is contained in:
parent
36a67d060b
commit
95075448bd
2 changed files with 8 additions and 7 deletions
|
@ -7,8 +7,9 @@ from requests.exceptions import RequestException
|
|||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, exceptions
|
||||
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.const import CONF_HOST, CONF_PORT, CONF_TOKEN
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DEFAULT_PORT, DEFAULT_TIMEOUT, DOMAIN
|
||||
|
||||
|
@ -66,15 +67,15 @@ class NukiConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
"""Handle a flow initiated by the user."""
|
||||
return await self.async_step_validate(user_input)
|
||||
|
||||
async def async_step_dhcp(self, discovery_info: dict):
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
"""Prepare configuration for a DHCP discovered Nuki bridge."""
|
||||
await self.async_set_unique_id(int(discovery_info.get(HOSTNAME)[12:], 16))
|
||||
await self.async_set_unique_id(int(discovery_info[dhcp.HOSTNAME][12:], 16))
|
||||
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
self.discovery_schema = vol.Schema(
|
||||
{
|
||||
vol.Required(CONF_HOST, default=discovery_info[IP_ADDRESS]): str,
|
||||
vol.Required(CONF_HOST, default=discovery_info[dhcp.IP_ADDRESS]): str,
|
||||
vol.Required(CONF_PORT, default=DEFAULT_PORT): int,
|
||||
vol.Required(CONF_TOKEN): str,
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ from pynuki.bridge import InvalidCredentialsException
|
|||
from requests.exceptions import RequestException
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow
|
||||
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS, MAC_ADDRESS
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.nuki.const import DOMAIN
|
||||
from homeassistant.const import CONF_TOKEN
|
||||
|
||||
|
@ -178,7 +178,7 @@ async def test_dhcp_flow(hass):
|
|||
"""Test that DHCP discovery for new bridge works."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
data={HOSTNAME: NAME, IP_ADDRESS: HOST, MAC_ADDRESS: MAC},
|
||||
data=dhcp.DhcpServiceInfo(hostname=NAME, ip=HOST, macaddress=MAC),
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
)
|
||||
|
||||
|
@ -221,7 +221,7 @@ async def test_dhcp_flow_already_configured(hass):
|
|||
await setup_nuki_integration(hass)
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
data={HOSTNAME: NAME, IP_ADDRESS: HOST, MAC_ADDRESS: MAC},
|
||||
data=dhcp.DhcpServiceInfo(hostname=NAME, ip=HOST, macaddress=MAC),
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue