ESPHome component to use zeroconf discovery (#24043)
* Move ESPHome component to use zeroconf discovery * Remove esphome from discovery component
This commit is contained in:
parent
9ac6f906ff
commit
085303c349
6 changed files with 11 additions and 8 deletions
|
@ -52,7 +52,6 @@ SERVICE_XIAOMI_GW = 'xiaomi_gw'
|
|||
CONFIG_ENTRY_HANDLERS = {
|
||||
SERVICE_DAIKIN: 'daikin',
|
||||
SERVICE_DECONZ: 'deconz',
|
||||
'esphome': 'esphome',
|
||||
'google_cast': 'cast',
|
||||
SERVICE_HEOS: 'heos',
|
||||
SERVICE_HUE: 'hue',
|
||||
|
|
|
@ -69,8 +69,8 @@ class EsphomeFlowHandler(config_entries.ConfigFlow):
|
|||
description_placeholders={'name': self._name},
|
||||
)
|
||||
|
||||
async def async_step_discovery(self, user_input: ConfigType):
|
||||
"""Handle discovery."""
|
||||
async def async_step_zeroconf(self, user_input: ConfigType):
|
||||
"""Handle zeroconf discovery."""
|
||||
address = user_input['properties'].get(
|
||||
'address', user_input['hostname'][:-1])
|
||||
for entry in self._async_current_entries():
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
"aioesphomeapi==2.0.1"
|
||||
],
|
||||
"dependencies": [],
|
||||
"zeroconf": ["_esphomelib._tcp.local."],
|
||||
"codeowners": [
|
||||
"@OttoWinter"
|
||||
]
|
||||
|
|
|
@ -7,5 +7,8 @@ To update, run python3 -m hassfest
|
|||
SERVICE_TYPES = {
|
||||
"_axis-video._tcp.local.": [
|
||||
"axis"
|
||||
],
|
||||
"_esphomelib._tcp.local.": [
|
||||
"esphome"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ async def test_discovery_initiation(hass, mock_client):
|
|||
mock_client.device_info.return_value = mock_coro(
|
||||
MockDeviceInfo(False, "test8266"))
|
||||
|
||||
result = await flow.async_step_discovery(user_input=service_info)
|
||||
result = await flow.async_step_zeroconf(user_input=service_info)
|
||||
assert result['type'] == 'form'
|
||||
assert result['step_id'] == 'discovery_confirm'
|
||||
assert result['description_placeholders']['name'] == 'test8266'
|
||||
|
@ -229,7 +229,7 @@ async def test_discovery_already_configured_hostname(hass, mock_client):
|
|||
'hostname': 'test8266.local.',
|
||||
'properties': {}
|
||||
}
|
||||
result = await flow.async_step_discovery(user_input=service_info)
|
||||
result = await flow.async_step_zeroconf(user_input=service_info)
|
||||
assert result['type'] == 'abort'
|
||||
assert result['reason'] == 'already_configured'
|
||||
|
||||
|
@ -251,6 +251,6 @@ async def test_discovery_already_configured_ip(hass, mock_client):
|
|||
"address": "192.168.43.183"
|
||||
}
|
||||
}
|
||||
result = await flow.async_step_discovery(user_input=service_info)
|
||||
result = await flow.async_step_zeroconf(user_input=service_info)
|
||||
assert result['type'] == 'abort'
|
||||
assert result['reason'] == 'already_configured'
|
||||
|
|
|
@ -36,5 +36,5 @@ async def test_setup(hass):
|
|||
hass, zeroconf.DOMAIN, {zeroconf.DOMAIN: {}})
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert len(MockServiceBrowser.mock_calls) == 1
|
||||
assert len(mock_config_flow.mock_calls) == 1
|
||||
assert len(MockServiceBrowser.mock_calls) == 2
|
||||
assert len(mock_config_flow.mock_calls) == 2
|
||||
|
|
Loading…
Add table
Reference in a new issue