ESPHome component to use zeroconf discovery (#24043)

* Move ESPHome component to use zeroconf discovery

* Remove esphome from discovery component
This commit is contained in:
Robert Svensson 2019-05-23 08:55:08 +02:00 committed by Pascal Vizeli
parent 9ac6f906ff
commit 085303c349
6 changed files with 11 additions and 8 deletions

View file

@ -52,7 +52,6 @@ SERVICE_XIAOMI_GW = 'xiaomi_gw'
CONFIG_ENTRY_HANDLERS = { CONFIG_ENTRY_HANDLERS = {
SERVICE_DAIKIN: 'daikin', SERVICE_DAIKIN: 'daikin',
SERVICE_DECONZ: 'deconz', SERVICE_DECONZ: 'deconz',
'esphome': 'esphome',
'google_cast': 'cast', 'google_cast': 'cast',
SERVICE_HEOS: 'heos', SERVICE_HEOS: 'heos',
SERVICE_HUE: 'hue', SERVICE_HUE: 'hue',

View file

@ -69,8 +69,8 @@ class EsphomeFlowHandler(config_entries.ConfigFlow):
description_placeholders={'name': self._name}, description_placeholders={'name': self._name},
) )
async def async_step_discovery(self, user_input: ConfigType): async def async_step_zeroconf(self, user_input: ConfigType):
"""Handle discovery.""" """Handle zeroconf discovery."""
address = user_input['properties'].get( address = user_input['properties'].get(
'address', user_input['hostname'][:-1]) 'address', user_input['hostname'][:-1])
for entry in self._async_current_entries(): for entry in self._async_current_entries():

View file

@ -7,6 +7,7 @@
"aioesphomeapi==2.0.1" "aioesphomeapi==2.0.1"
], ],
"dependencies": [], "dependencies": [],
"zeroconf": ["_esphomelib._tcp.local."],
"codeowners": [ "codeowners": [
"@OttoWinter" "@OttoWinter"
] ]

View file

@ -7,5 +7,8 @@ To update, run python3 -m hassfest
SERVICE_TYPES = { SERVICE_TYPES = {
"_axis-video._tcp.local.": [ "_axis-video._tcp.local.": [
"axis" "axis"
],
"_esphomelib._tcp.local.": [
"esphome"
] ]
} }

View file

@ -202,7 +202,7 @@ async def test_discovery_initiation(hass, mock_client):
mock_client.device_info.return_value = mock_coro( mock_client.device_info.return_value = mock_coro(
MockDeviceInfo(False, "test8266")) 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['type'] == 'form'
assert result['step_id'] == 'discovery_confirm' assert result['step_id'] == 'discovery_confirm'
assert result['description_placeholders']['name'] == 'test8266' assert result['description_placeholders']['name'] == 'test8266'
@ -229,7 +229,7 @@ async def test_discovery_already_configured_hostname(hass, mock_client):
'hostname': 'test8266.local.', 'hostname': 'test8266.local.',
'properties': {} '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['type'] == 'abort'
assert result['reason'] == 'already_configured' assert result['reason'] == 'already_configured'
@ -251,6 +251,6 @@ async def test_discovery_already_configured_ip(hass, mock_client):
"address": "192.168.43.183" "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['type'] == 'abort'
assert result['reason'] == 'already_configured' assert result['reason'] == 'already_configured'

View file

@ -36,5 +36,5 @@ async def test_setup(hass):
hass, zeroconf.DOMAIN, {zeroconf.DOMAIN: {}}) hass, zeroconf.DOMAIN, {zeroconf.DOMAIN: {}})
await hass.async_block_till_done() await hass.async_block_till_done()
assert len(MockServiceBrowser.mock_calls) == 1 assert len(MockServiceBrowser.mock_calls) == 2
assert len(mock_config_flow.mock_calls) == 1 assert len(mock_config_flow.mock_calls) == 2