Add support for zeroconf for Daikin (#35769)
This commit is contained in:
parent
f9aff4fc41
commit
e1fd14e00a
4 changed files with 24 additions and 3 deletions
|
@ -124,3 +124,11 @@ class FlowHandler(config_entries.ConfigFlow):
|
|||
self._abort_if_unique_id_configured()
|
||||
self.host = discovery_info[KEY_IP]
|
||||
return await self.async_step_user()
|
||||
|
||||
async def async_step_zeroconf(self, discovery_info):
|
||||
"""Prepare configuration for a discovered Daikin device."""
|
||||
_LOGGER.debug("Zeroconf discovery_info: %s", discovery_info)
|
||||
await self.async_set_unique_id(discovery_info.get(CONF_HOST))
|
||||
self._abort_if_unique_id_configured()
|
||||
self.host = discovery_info.get(CONF_HOST)
|
||||
return await self.async_step_user()
|
||||
|
|
|
@ -5,5 +5,6 @@
|
|||
"documentation": "https://www.home-assistant.io/integrations/daikin",
|
||||
"requirements": ["pydaikin==2.1.0"],
|
||||
"codeowners": ["@fredrike"],
|
||||
"zeroconf": ["_dkapi._tcp.local."],
|
||||
"quality_scale": "platinum"
|
||||
}
|
||||
|
|
|
@ -16,6 +16,9 @@ ZEROCONF = {
|
|||
"_daap._tcp.local.": [
|
||||
"forked_daapd"
|
||||
],
|
||||
"_dkapi._tcp.local.": [
|
||||
"daikin"
|
||||
],
|
||||
"_elg._tcp.local.": [
|
||||
"elgato"
|
||||
],
|
||||
|
|
|
@ -7,7 +7,12 @@ from aiohttp.web_exceptions import HTTPForbidden
|
|||
import pytest
|
||||
|
||||
from homeassistant.components.daikin.const import KEY_IP, KEY_MAC
|
||||
from homeassistant.config_entries import SOURCE_DISCOVERY, SOURCE_IMPORT, SOURCE_USER
|
||||
from homeassistant.config_entries import (
|
||||
SOURCE_DISCOVERY,
|
||||
SOURCE_IMPORT,
|
||||
SOURCE_USER,
|
||||
SOURCE_ZEROCONF,
|
||||
)
|
||||
from homeassistant.const import CONF_HOST
|
||||
from homeassistant.data_entry_flow import (
|
||||
RESULT_TYPE_ABORT,
|
||||
|
@ -104,9 +109,13 @@ async def test_device_abort(hass, mock_daikin, s_effect, reason):
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"source, data, unique_id", [(SOURCE_DISCOVERY, {KEY_IP: HOST, KEY_MAC: MAC}, MAC)],
|
||||
"source, data, unique_id",
|
||||
[
|
||||
(SOURCE_DISCOVERY, {KEY_IP: HOST, KEY_MAC: MAC}, MAC),
|
||||
(SOURCE_ZEROCONF, {CONF_HOST: HOST}, HOST),
|
||||
],
|
||||
)
|
||||
async def test_discovery(hass, mock_daikin, source, data, unique_id):
|
||||
async def test_discovery_zeroconf(hass, mock_daikin, source, data, unique_id):
|
||||
"""Test discovery/zeroconf step."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
"daikin", context={"source": source}, data=data,
|
||||
|
|
Loading…
Add table
Reference in a new issue