mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Use DhcpServiceInfo in screenlogic (#60103)
This commit is contained in:
parent
4555820987
commit
8f7f32d844
@ -7,9 +7,10 @@ from screenlogicpy.requests import login
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PORT, CONF_SCAN_INTERVAL
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
import homeassistant.helpers.config_validation as cv
|
||||
from homeassistant.helpers.device_registry import format_mac
|
||||
|
||||
@ -88,15 +89,15 @@ class ScreenlogicConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
self.discovered_gateways = await async_discover_gateways_by_unique_id(self.hass)
|
||||
return await self.async_step_gateway_select()
|
||||
|
||||
async def async_step_dhcp(self, discovery_info):
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
"""Handle dhcp discovery."""
|
||||
mac = _extract_mac_from_name(discovery_info[HOSTNAME])
|
||||
mac = _extract_mac_from_name(discovery_info[dhcp.HOSTNAME])
|
||||
await self.async_set_unique_id(mac)
|
||||
self._abort_if_unique_id_configured(
|
||||
updates={CONF_IP_ADDRESS: discovery_info[IP_ADDRESS]}
|
||||
updates={CONF_IP_ADDRESS: discovery_info[dhcp.IP_ADDRESS]}
|
||||
)
|
||||
self.discovered_ip = discovery_info[IP_ADDRESS]
|
||||
self.context["title_placeholders"] = {"name": discovery_info[HOSTNAME]}
|
||||
self.discovered_ip = discovery_info[dhcp.IP_ADDRESS]
|
||||
self.context["title_placeholders"] = {"name": discovery_info[dhcp.HOSTNAME]}
|
||||
return await self.async_step_gateway_entry()
|
||||
|
||||
async def async_step_gateway_select(self, user_input=None):
|
||||
|
@ -11,7 +11,7 @@ from screenlogicpy.const import (
|
||||
)
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.screenlogic.config_flow import (
|
||||
GATEWAY_MANUAL_ENTRY,
|
||||
GATEWAY_SELECT_KEY,
|
||||
@ -138,10 +138,10 @@ async def test_dhcp(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data={
|
||||
HOSTNAME: "Pentair: 01-01-01",
|
||||
IP_ADDRESS: "1.1.1.1",
|
||||
},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
hostname="Pentair: 01-01-01",
|
||||
ip="1.1.1.1",
|
||||
),
|
||||
)
|
||||
|
||||
assert result["type"] == "form"
|
||||
|
Loading…
x
Reference in New Issue
Block a user