mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Use DhcpServiceInfo in powerwall (#60051)
This commit is contained in:
parent
8ec30aa9ad
commit
c3e9c1a7e8
@ -10,8 +10,9 @@ from tesla_powerwall import (
|
||||
import voluptuous as vol
|
||||
|
||||
from homeassistant import config_entries, core, exceptions
|
||||
from homeassistant.components.dhcp import IP_ADDRESS
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD
|
||||
from homeassistant.data_entry_flow import FlowResult
|
||||
|
||||
from .const import DOMAIN
|
||||
|
||||
@ -57,11 +58,10 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
"""Initialize the powerwall flow."""
|
||||
self.ip_address = None
|
||||
|
||||
async def async_step_dhcp(self, discovery_info):
|
||||
async def async_step_dhcp(self, discovery_info: dhcp.DhcpServiceInfo) -> FlowResult:
|
||||
"""Handle dhcp discovery."""
|
||||
self.ip_address = discovery_info[IP_ADDRESS]
|
||||
self.ip_address = discovery_info[dhcp.IP_ADDRESS]
|
||||
self._async_abort_entries_match({CONF_IP_ADDRESS: self.ip_address})
|
||||
self.ip_address = discovery_info[IP_ADDRESS]
|
||||
self.context["title_placeholders"] = {CONF_IP_ADDRESS: self.ip_address}
|
||||
return await self.async_step_user()
|
||||
|
||||
|
@ -9,7 +9,7 @@ from tesla_powerwall import (
|
||||
)
|
||||
|
||||
from homeassistant import config_entries
|
||||
from homeassistant.components.dhcp import HOSTNAME, IP_ADDRESS, MAC_ADDRESS
|
||||
from homeassistant.components import dhcp
|
||||
from homeassistant.components.powerwall.const import DOMAIN
|
||||
from homeassistant.const import CONF_IP_ADDRESS, CONF_PASSWORD
|
||||
|
||||
@ -144,11 +144,11 @@ async def test_already_configured(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data={
|
||||
IP_ADDRESS: "1.1.1.1",
|
||||
MAC_ADDRESS: "AA:BB:CC:DD:EE:FF",
|
||||
HOSTNAME: "any",
|
||||
},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
ip="1.1.1.1",
|
||||
macaddress="AA:BB:CC:DD:EE:FF",
|
||||
hostname="any",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "abort"
|
||||
assert result["reason"] == "already_configured"
|
||||
@ -165,11 +165,11 @@ async def test_already_configured_with_ignored(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data={
|
||||
IP_ADDRESS: "1.1.1.1",
|
||||
MAC_ADDRESS: "AA:BB:CC:DD:EE:FF",
|
||||
HOSTNAME: "any",
|
||||
},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
ip="1.1.1.1",
|
||||
macaddress="AA:BB:CC:DD:EE:FF",
|
||||
hostname="any",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
|
||||
@ -180,11 +180,11 @@ async def test_dhcp_discovery(hass):
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": config_entries.SOURCE_DHCP},
|
||||
data={
|
||||
IP_ADDRESS: "1.1.1.1",
|
||||
MAC_ADDRESS: "AA:BB:CC:DD:EE:FF",
|
||||
HOSTNAME: "any",
|
||||
},
|
||||
data=dhcp.DhcpServiceInfo(
|
||||
ip="1.1.1.1",
|
||||
macaddress="AA:BB:CC:DD:EE:FF",
|
||||
hostname="any",
|
||||
),
|
||||
)
|
||||
assert result["type"] == "form"
|
||||
assert result["errors"] == {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user