Skip to content

Commit efec62d

Browse files
authored
Add KEY_HOSTNAME for Daikin zeroconf (home-assistant#36253)
* Add KEY_HOSTNAME for Daikin zeroconf * Update tests and use CONF_HOST as hostname
1 parent e1c6f01 commit efec62d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

homeassistant/components/daikin/config_flow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from homeassistant import config_entries
1212
from homeassistant.const import CONF_HOST, CONF_PASSWORD
1313

14-
from .const import CONF_KEY, CONF_UUID, KEY_IP, KEY_MAC, TIMEOUT
14+
from .const import CONF_KEY, CONF_UUID, KEY_HOSTNAME, KEY_IP, KEY_MAC, TIMEOUT
1515

1616
_LOGGER = logging.getLogger(__name__)
1717

@@ -128,7 +128,7 @@ async def async_step_discovery(self, discovery_info):
128128
async def async_step_zeroconf(self, discovery_info):
129129
"""Prepare configuration for a discovered Daikin device."""
130130
_LOGGER.debug("Zeroconf discovery_info: %s", discovery_info)
131-
await self.async_set_unique_id(discovery_info.get(CONF_HOST))
131+
await self.async_set_unique_id(discovery_info[KEY_HOSTNAME])
132132
self._abort_if_unique_id_configured()
133-
self.host = discovery_info.get(CONF_HOST)
133+
self.host = discovery_info[CONF_HOST]
134134
return await self.async_step_user()

homeassistant/components/daikin/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,5 +64,6 @@
6464

6565
KEY_MAC = "mac"
6666
KEY_IP = "ip"
67+
KEY_HOSTNAME = "hostname"
6768

6869
TIMEOUT = 60

tests/components/daikin/test_config_flow.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from aiohttp.web_exceptions import HTTPForbidden
77
import pytest
88

9-
from homeassistant.components.daikin.const import KEY_IP, KEY_MAC
9+
from homeassistant.components.daikin.const import KEY_HOSTNAME, KEY_IP, KEY_MAC
1010
from homeassistant.config_entries import (
1111
SOURCE_DISCOVERY,
1212
SOURCE_IMPORT,
@@ -112,7 +112,11 @@ async def test_device_abort(hass, mock_daikin, s_effect, reason):
112112
"source, data, unique_id",
113113
[
114114
(SOURCE_DISCOVERY, {KEY_IP: HOST, KEY_MAC: MAC}, MAC),
115-
(SOURCE_ZEROCONF, {CONF_HOST: HOST}, HOST),
115+
(
116+
SOURCE_ZEROCONF,
117+
{CONF_HOST: HOST, KEY_HOSTNAME: "DaikinUNIQE.local"},
118+
"DaikinUNIQE.local",
119+
),
116120
],
117121
)
118122
async def test_discovery_zeroconf(hass, mock_daikin, source, data, unique_id):

0 commit comments

Comments
 (0)