Add KEY_HOSTNAME for Daikin zeroconf (#36253)
* Add KEY_HOSTNAME for Daikin zeroconf * Update tests and use CONF_HOST as hostname
This commit is contained in:
parent
e1c6f01047
commit
efec62d98e
3 changed files with 10 additions and 5 deletions
|
@ -11,7 +11,7 @@ import voluptuous as vol
|
||||||
from homeassistant import config_entries
|
from homeassistant import config_entries
|
||||||
from homeassistant.const import CONF_HOST, CONF_PASSWORD
|
from homeassistant.const import CONF_HOST, CONF_PASSWORD
|
||||||
|
|
||||||
from .const import CONF_KEY, CONF_UUID, KEY_IP, KEY_MAC, TIMEOUT
|
from .const import CONF_KEY, CONF_UUID, KEY_HOSTNAME, KEY_IP, KEY_MAC, TIMEOUT
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -128,7 +128,7 @@ class FlowHandler(config_entries.ConfigFlow):
|
||||||
async def async_step_zeroconf(self, discovery_info):
|
async def async_step_zeroconf(self, discovery_info):
|
||||||
"""Prepare configuration for a discovered Daikin device."""
|
"""Prepare configuration for a discovered Daikin device."""
|
||||||
_LOGGER.debug("Zeroconf discovery_info: %s", discovery_info)
|
_LOGGER.debug("Zeroconf discovery_info: %s", discovery_info)
|
||||||
await self.async_set_unique_id(discovery_info.get(CONF_HOST))
|
await self.async_set_unique_id(discovery_info[KEY_HOSTNAME])
|
||||||
self._abort_if_unique_id_configured()
|
self._abort_if_unique_id_configured()
|
||||||
self.host = discovery_info.get(CONF_HOST)
|
self.host = discovery_info[CONF_HOST]
|
||||||
return await self.async_step_user()
|
return await self.async_step_user()
|
||||||
|
|
|
@ -64,5 +64,6 @@ CONF_UUID = "uuid"
|
||||||
|
|
||||||
KEY_MAC = "mac"
|
KEY_MAC = "mac"
|
||||||
KEY_IP = "ip"
|
KEY_IP = "ip"
|
||||||
|
KEY_HOSTNAME = "hostname"
|
||||||
|
|
||||||
TIMEOUT = 60
|
TIMEOUT = 60
|
||||||
|
|
|
@ -6,7 +6,7 @@ from aiohttp import ClientError
|
||||||
from aiohttp.web_exceptions import HTTPForbidden
|
from aiohttp.web_exceptions import HTTPForbidden
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from homeassistant.components.daikin.const import KEY_IP, KEY_MAC
|
from homeassistant.components.daikin.const import KEY_HOSTNAME, KEY_IP, KEY_MAC
|
||||||
from homeassistant.config_entries import (
|
from homeassistant.config_entries import (
|
||||||
SOURCE_DISCOVERY,
|
SOURCE_DISCOVERY,
|
||||||
SOURCE_IMPORT,
|
SOURCE_IMPORT,
|
||||||
|
@ -112,7 +112,11 @@ async def test_device_abort(hass, mock_daikin, s_effect, reason):
|
||||||
"source, data, unique_id",
|
"source, data, unique_id",
|
||||||
[
|
[
|
||||||
(SOURCE_DISCOVERY, {KEY_IP: HOST, KEY_MAC: MAC}, MAC),
|
(SOURCE_DISCOVERY, {KEY_IP: HOST, KEY_MAC: MAC}, MAC),
|
||||||
(SOURCE_ZEROCONF, {CONF_HOST: HOST}, HOST),
|
(
|
||||||
|
SOURCE_ZEROCONF,
|
||||||
|
{CONF_HOST: HOST, KEY_HOSTNAME: "DaikinUNIQE.local"},
|
||||||
|
"DaikinUNIQE.local",
|
||||||
|
),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
async def test_discovery_zeroconf(hass, mock_daikin, source, data, unique_id):
|
async def test_discovery_zeroconf(hass, mock_daikin, source, data, unique_id):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue