From a4d86155a3b9ecba8ae9a9b9cbad9dc02e676fc3 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 10 Sep 2020 20:15:53 +0200 Subject: [PATCH 01/10] Add port configuration by appending to ip address --- homeassistant/components/plugwise/__init__.py | 15 +++++++++-- .../components/plugwise/config_flow.py | 14 +++++++++-- tests/components/plugwise/test_config_flow.py | 25 +++++++++++++++++-- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/plugwise/__init__.py b/homeassistant/components/plugwise/__init__.py index 0e55c3e715c013..fc549087cdce82 100644 --- a/homeassistant/components/plugwise/__init__.py +++ b/homeassistant/components/plugwise/__init__.py @@ -39,9 +39,20 @@ async def async_setup(hass: HomeAssistant, config: dict): async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Plugwise Smiles from a config entry.""" websession = async_get_clientsession(hass, verify_ssl=False) + + port = 80 + host = (entry.data[CONF_HOST],) + password = (entry.data[CONF_PASSWORD],) + + if ":" in host: + port = int(host.split(":")[1]) + host = host.split(":")[0] + api = Smile( - host=entry.data[CONF_HOST], - password=entry.data[CONF_PASSWORD], + host=host, + password=password, + port=port, + timeout=30, websession=websession, ) diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 689bfb68f22a8e..138a0580fb5770 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -40,9 +40,19 @@ async def validate_input(hass: core.HomeAssistant, data): Data has the keys from _base_schema() with values provided by the user. """ websession = async_get_clientsession(hass, verify_ssl=False) + + port = 80 + host = data[CONF_HOST] + password = data[CONF_PASSWORD] + + if ":" in host: + port = int(host.split(":")[1]) + host = host.split(":")[0] + api = Smile( - host=data[CONF_HOST], - password=data[CONF_PASSWORD], + host=host, + password=password, + port=port, timeout=30, websession=websession, ) diff --git a/tests/components/plugwise/test_config_flow.py b/tests/components/plugwise/test_config_flow.py index e0f4993df55c54..4b5116efb6d86b 100644 --- a/tests/components/plugwise/test_config_flow.py +++ b/tests/components/plugwise/test_config_flow.py @@ -13,6 +13,9 @@ TEST_HOST = "1.1.1.1" TEST_HOSTNAME = "smileabcdef" TEST_PASSWORD = "test_password" +TEST_HOST_PORT = "1.1.1.1:80" +TEST_HOST_FPORT = "1.1.1.1:81" + TEST_DISCOVERY = { "host": TEST_HOST, "hostname": f"{TEST_HOSTNAME}.local.", @@ -59,14 +62,14 @@ async def test_form(hass): ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], - {"host": TEST_HOST, "password": TEST_PASSWORD}, + {"host": TEST_HOST_PORT, "password": TEST_PASSWORD}, ) await hass.async_block_till_done() assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result2["data"] == { - "host": TEST_HOST, + "host": TEST_HOST_PORT, "password": TEST_PASSWORD, } @@ -176,6 +179,24 @@ async def test_form_cannot_connect(hass, mock_smile): assert result2["errors"] == {"base": "cannot_connect"} +async def test_form_cannot_connect_port(hass, mock_smile): + """Test we handle cannot connect to port error.""" + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": config_entries.SOURCE_USER} + ) + + mock_smile.connect.side_effect = Smile.ConnectionFailedError + mock_smile.gateway_id = "0a636a4fc1704ab4a24e4f7e37fb187a" + + result2 = await hass.config_entries.flow.async_configure( + result["flow_id"], + {"host": TEST_HOST_FPORT, "password": TEST_PASSWORD}, + ) + + assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result2["errors"] == {"base": "cannot_connect"} + + async def test_form_other_problem(hass, mock_smile): """Test we handle cannot connect error.""" result = await hass.config_entries.flow.async_init( From b0c2d4e2e1468694d3bf82e97775e314593b14d5 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Fri, 11 Sep 2020 09:30:12 +0200 Subject: [PATCH 02/10] Add missing strings change --- homeassistant/components/plugwise/strings.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/plugwise/strings.json b/homeassistant/components/plugwise/strings.json index 7dc8542698bca6..76ea4313d29df6 100644 --- a/homeassistant/components/plugwise/strings.json +++ b/homeassistant/components/plugwise/strings.json @@ -13,9 +13,9 @@ "step": { "user": { "title": "Connect to the Smile", - "description": "Details", + "description": "Please enter:", "data": { - "host": "Smile IP address", + "host": "Smile IP address(:port)", "password": "Smile ID" } } From 0e000ee5e6b85f888c64bb7ed31e74cc2c81ef91 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sun, 13 Sep 2020 11:45:35 +0200 Subject: [PATCH 03/10] Remove unwanted tuple definition (wrong code copy) --- homeassistant/components/plugwise/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/plugwise/__init__.py b/homeassistant/components/plugwise/__init__.py index fc549087cdce82..7815fc5261d31a 100644 --- a/homeassistant/components/plugwise/__init__.py +++ b/homeassistant/components/plugwise/__init__.py @@ -41,8 +41,8 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: websession = async_get_clientsession(hass, verify_ssl=False) port = 80 - host = (entry.data[CONF_HOST],) - password = (entry.data[CONF_PASSWORD],) + host = entry.data[CONF_HOST] + password = entry.data[CONF_PASSWORD] if ":" in host: port = int(host.split(":")[1]) From 58148f8858a27e068d29ff9940744e1481558698 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 17 Sep 2020 08:32:56 +0200 Subject: [PATCH 04/10] Revert to #38276 approach of @jeroen84 - docs need updating --- homeassistant/components/plugwise/__init__.py | 24 +++++++++---------- .../components/plugwise/config_flow.py | 23 ++++++++---------- .../components/plugwise/strings.json | 5 ++-- tests/components/plugwise/test_config_flow.py | 17 ++++++++----- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/homeassistant/components/plugwise/__init__.py b/homeassistant/components/plugwise/__init__.py index 7815fc5261d31a..f7986f915401c6 100644 --- a/homeassistant/components/plugwise/__init__.py +++ b/homeassistant/components/plugwise/__init__.py @@ -10,7 +10,7 @@ import voluptuous as vol from homeassistant.config_entries import ConfigEntry -from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_SCAN_INTERVAL +from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_SCAN_INTERVAL from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import ConfigEntryNotReady from homeassistant.helpers import device_registry as dr @@ -21,7 +21,13 @@ UpdateFailed, ) -from .const import COORDINATOR, DEFAULT_SCAN_INTERVAL, DOMAIN, UNDO_UPDATE_LISTENER +from .const import ( + COORDINATOR, + DEFAULT_PORT, + DEFAULT_SCAN_INTERVAL, + DOMAIN, + UNDO_UPDATE_LISTENER, +) CONFIG_SCHEMA = vol.Schema({DOMAIN: vol.Schema({})}, extra=vol.ALLOW_EXTRA) @@ -40,18 +46,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: """Set up Plugwise Smiles from a config entry.""" websession = async_get_clientsession(hass, verify_ssl=False) - port = 80 - host = entry.data[CONF_HOST] - password = entry.data[CONF_PASSWORD] - - if ":" in host: - port = int(host.split(":")[1]) - host = host.split(":")[0] - api = Smile( - host=host, - password=password, - port=port, + host=entry.data[CONF_HOST], + password=entry.data[CONF_PASSWORD], + port=entry.data.get(CONF_PORT, DEFAULT_PORT), timeout=30, websession=websession, ) diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 138a0580fb5770..c08c6fb2e75a84 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -5,12 +5,16 @@ import voluptuous as vol from homeassistant import config_entries, core, exceptions -from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_SCAN_INTERVAL +from homeassistant.const import CONF_HOST, CONF_PASSWORD, CONF_PORT, CONF_SCAN_INTERVAL from homeassistant.core import callback from homeassistant.helpers.aiohttp_client import async_get_clientsession from homeassistant.helpers.typing import DiscoveryInfoType -from .const import DEFAULT_SCAN_INTERVAL, DOMAIN # pylint:disable=unused-import +from .const import ( # pylint:disable=unused-import + DEFAULT_PORT, + DEFAULT_SCAN_INTERVAL, + DOMAIN, +) _LOGGER = logging.getLogger(__name__) @@ -29,6 +33,7 @@ def _base_schema(discovery_info): base_schema[vol.Required(CONF_HOST)] = str base_schema[vol.Required(CONF_PASSWORD)] = str + base_schema[vol.Optional(CONF_PORT, default=DEFAULT_PORT)] = int return vol.Schema(base_schema) @@ -41,18 +46,10 @@ async def validate_input(hass: core.HomeAssistant, data): """ websession = async_get_clientsession(hass, verify_ssl=False) - port = 80 - host = data[CONF_HOST] - password = data[CONF_PASSWORD] - - if ":" in host: - port = int(host.split(":")[1]) - host = host.split(":")[0] - api = Smile( - host=host, - password=password, - port=port, + host=data[CONF_HOST], + password=data[CONF_PASSWORD], + port=data[CONF_PORT], timeout=30, websession=websession, ) diff --git a/homeassistant/components/plugwise/strings.json b/homeassistant/components/plugwise/strings.json index 76ea4313d29df6..0abcd7802558d4 100644 --- a/homeassistant/components/plugwise/strings.json +++ b/homeassistant/components/plugwise/strings.json @@ -15,8 +15,9 @@ "title": "Connect to the Smile", "description": "Please enter:", "data": { - "host": "Smile IP address(:port)", - "password": "Smile ID" + "password": "Smile ID", + "host": "Smile IP address", + "port": "Smile port number" } } }, diff --git a/tests/components/plugwise/test_config_flow.py b/tests/components/plugwise/test_config_flow.py index 4b5116efb6d86b..30dd4391893342 100644 --- a/tests/components/plugwise/test_config_flow.py +++ b/tests/components/plugwise/test_config_flow.py @@ -3,7 +3,11 @@ import pytest from homeassistant import config_entries, data_entry_flow, setup -from homeassistant.components.plugwise.const import DEFAULT_SCAN_INTERVAL, DOMAIN +from homeassistant.components.plugwise.const import ( + DEFAULT_PORT, + DEFAULT_SCAN_INTERVAL, + DOMAIN, +) from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_SCAN_INTERVAL @@ -13,8 +17,7 @@ TEST_HOST = "1.1.1.1" TEST_HOSTNAME = "smileabcdef" TEST_PASSWORD = "test_password" -TEST_HOST_PORT = "1.1.1.1:80" -TEST_HOST_FPORT = "1.1.1.1:81" +TEST_PORT = 81 TEST_DISCOVERY = { "host": TEST_HOST, @@ -62,15 +65,16 @@ async def test_form(hass): ) as mock_setup_entry: result2 = await hass.config_entries.flow.async_configure( result["flow_id"], - {"host": TEST_HOST_PORT, "password": TEST_PASSWORD}, + {"host": TEST_HOST, "password": TEST_PASSWORD}, ) await hass.async_block_till_done() assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY assert result2["data"] == { - "host": TEST_HOST_PORT, + "host": TEST_HOST, "password": TEST_PASSWORD, + "port": DEFAULT_PORT, } assert len(mock_setup.mock_calls) == 1 @@ -109,6 +113,7 @@ async def test_zeroconf_form(hass): assert result2["data"] == { "host": TEST_HOST, "password": TEST_PASSWORD, + "port": DEFAULT_PORT, } assert len(mock_setup.mock_calls) == 1 @@ -190,7 +195,7 @@ async def test_form_cannot_connect_port(hass, mock_smile): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], - {"host": TEST_HOST_FPORT, "password": TEST_PASSWORD}, + {"host": TEST_HOST, "password": TEST_PASSWORD, "port": TEST_PORT}, ) assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM From 570bec90b652c28bbb2ddaad64cee1ad0069b810 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 17 Sep 2020 20:12:19 +0200 Subject: [PATCH 05/10] Commit suggestion (good one!) --- homeassistant/components/plugwise/config_flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index c08c6fb2e75a84..87a2afdf52fb83 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -31,9 +31,9 @@ def _base_schema(discovery_info): if not discovery_info: base_schema[vol.Required(CONF_HOST)] = str + base_schema[vol.Optional(CONF_PORT, default=DEFAULT_PORT)] = int base_schema[vol.Required(CONF_PASSWORD)] = str - base_schema[vol.Optional(CONF_PORT, default=DEFAULT_PORT)] = int return vol.Schema(base_schema) From 074599a5e32e48fc4b0ea34cbfc286fdb9178ad7 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 17 Sep 2020 20:39:34 +0200 Subject: [PATCH 06/10] Fix PORT handling through zeroconf correctly --- homeassistant/components/plugwise/config_flow.py | 2 ++ tests/components/plugwise/test_config_flow.py | 1 + 2 files changed, 3 insertions(+) diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 87a2afdf52fb83..edde66c0fe1498 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -90,6 +90,7 @@ async def async_step_zeroconf(self, discovery_info: DiscoveryInfoType): # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167 self.context["title_placeholders"] = { CONF_HOST: discovery_info[CONF_HOST], + CONF_PORT: discovery_info[CONF_PORT], "name": _name, } return await self.async_step_user() @@ -102,6 +103,7 @@ async def async_step_user(self, user_input=None): if self.discovery_info: user_input[CONF_HOST] = self.discovery_info[CONF_HOST] + user_input[CONF_PORT] = self.discovery_info[CONF_PORT] for entry in self._async_current_entries(): if entry.data.get(CONF_HOST) == user_input[CONF_HOST]: diff --git a/tests/components/plugwise/test_config_flow.py b/tests/components/plugwise/test_config_flow.py index 30dd4391893342..9b67f06e469001 100644 --- a/tests/components/plugwise/test_config_flow.py +++ b/tests/components/plugwise/test_config_flow.py @@ -21,6 +21,7 @@ TEST_DISCOVERY = { "host": TEST_HOST, + "port": DEFAULT_PORT, "hostname": f"{TEST_HOSTNAME}.local.", "server": f"{TEST_HOSTNAME}.local.", "properties": { From f2d1df7b3caef0c2d77aae7afd3fbce82fe5b8e0 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Thu, 17 Sep 2020 20:55:13 +0200 Subject: [PATCH 07/10] Retrigger faulty tests because of google_assistant test_smart-home From 5a0492a58b9f8ee463d16bc21b9b295d997b40fe Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 19 Sep 2020 11:01:01 +0200 Subject: [PATCH 08/10] Add potential missing port from zeroconf handling --- .../components/plugwise/config_flow.py | 3 ++ tests/components/plugwise/test_config_flow.py | 46 ++++++++++++++++++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index edde66c0fe1498..1ef3934372548e 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -79,6 +79,9 @@ async def async_step_zeroconf(self, discovery_info: DiscoveryInfoType): self.discovery_info = discovery_info _properties = self.discovery_info.get("properties") + if not self.discovery_info.get(CONF_PORT): + self.discovery_info[CONF_PORT] = DEFAULT_PORT + unique_id = self.discovery_info.get("hostname").split(".")[0] await self.async_set_unique_id(unique_id) self._abort_if_unique_id_configured() diff --git a/tests/components/plugwise/test_config_flow.py b/tests/components/plugwise/test_config_flow.py index 9b67f06e469001..72de7d4640f90e 100644 --- a/tests/components/plugwise/test_config_flow.py +++ b/tests/components/plugwise/test_config_flow.py @@ -9,7 +9,13 @@ DOMAIN, ) from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF -from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_SCAN_INTERVAL +from homeassistant.const import ( + CONF_HOST, + CONF_NAME, + CONF_PASSWORD, + CONF_PORT, + CONF_SCAN_INTERVAL, +) from tests.async_mock import MagicMock, patch from tests.common import MockConfigEntry @@ -149,6 +155,44 @@ async def test_zeroconf_form(hass): assert result4["reason"] == "already_configured" +async def test_zeroconf_missing_port_form(hass): + """Test we get the form when port is absent from discovery.""" + missing_port = TEST_DISCOVERY + missing_port.pop(CONF_PORT) + result = await hass.config_entries.flow.async_init( + DOMAIN, context={"source": SOURCE_ZEROCONF}, data=missing_port + ) + assert result["type"] == data_entry_flow.RESULT_TYPE_FORM + assert result["errors"] == {} + + with patch( + "homeassistant.components.plugwise.config_flow.Smile.connect", + return_value=True, + ), patch( + "homeassistant.components.plugwise.async_setup", + return_value=True, + ) as mock_setup, patch( + "homeassistant.components.plugwise.async_setup_entry", + return_value=True, + ) as mock_setup_entry: + result2 = await hass.config_entries.flow.async_configure( + result["flow_id"], + {"password": TEST_PASSWORD}, + ) + + await hass.async_block_till_done() + + assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY + assert result2["data"] == { + "host": TEST_HOST, + "password": TEST_PASSWORD, + "port": DEFAULT_PORT, + } + + assert len(mock_setup.mock_calls) == 1 + assert len(mock_setup_entry.mock_calls) == 1 + + async def test_form_invalid_auth(hass, mock_smile): """Test we handle invalid auth.""" result = await hass.config_entries.flow.async_init( From d1ec20864d55e4749c96f27f56092ada5801bc27 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 19 Sep 2020 11:26:53 +0200 Subject: [PATCH 09/10] Commit @ludaeus suggestion --- .../components/plugwise/config_flow.py | 5 +- tests/components/plugwise/test_config_flow.py | 46 +------------------ 2 files changed, 2 insertions(+), 49 deletions(-) diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 1ef3934372548e..467e369917841d 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -79,9 +79,6 @@ async def async_step_zeroconf(self, discovery_info: DiscoveryInfoType): self.discovery_info = discovery_info _properties = self.discovery_info.get("properties") - if not self.discovery_info.get(CONF_PORT): - self.discovery_info[CONF_PORT] = DEFAULT_PORT - unique_id = self.discovery_info.get("hostname").split(".")[0] await self.async_set_unique_id(unique_id) self._abort_if_unique_id_configured() @@ -93,7 +90,7 @@ async def async_step_zeroconf(self, discovery_info: DiscoveryInfoType): # pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167 self.context["title_placeholders"] = { CONF_HOST: discovery_info[CONF_HOST], - CONF_PORT: discovery_info[CONF_PORT], + CONF_PORT: discovery_info.get(CONF_PORT, DEFAULT_PORT), "name": _name, } return await self.async_step_user() diff --git a/tests/components/plugwise/test_config_flow.py b/tests/components/plugwise/test_config_flow.py index 72de7d4640f90e..9b67f06e469001 100644 --- a/tests/components/plugwise/test_config_flow.py +++ b/tests/components/plugwise/test_config_flow.py @@ -9,13 +9,7 @@ DOMAIN, ) from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF -from homeassistant.const import ( - CONF_HOST, - CONF_NAME, - CONF_PASSWORD, - CONF_PORT, - CONF_SCAN_INTERVAL, -) +from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_SCAN_INTERVAL from tests.async_mock import MagicMock, patch from tests.common import MockConfigEntry @@ -155,44 +149,6 @@ async def test_zeroconf_form(hass): assert result4["reason"] == "already_configured" -async def test_zeroconf_missing_port_form(hass): - """Test we get the form when port is absent from discovery.""" - missing_port = TEST_DISCOVERY - missing_port.pop(CONF_PORT) - result = await hass.config_entries.flow.async_init( - DOMAIN, context={"source": SOURCE_ZEROCONF}, data=missing_port - ) - assert result["type"] == data_entry_flow.RESULT_TYPE_FORM - assert result["errors"] == {} - - with patch( - "homeassistant.components.plugwise.config_flow.Smile.connect", - return_value=True, - ), patch( - "homeassistant.components.plugwise.async_setup", - return_value=True, - ) as mock_setup, patch( - "homeassistant.components.plugwise.async_setup_entry", - return_value=True, - ) as mock_setup_entry: - result2 = await hass.config_entries.flow.async_configure( - result["flow_id"], - {"password": TEST_PASSWORD}, - ) - - await hass.async_block_till_done() - - assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY - assert result2["data"] == { - "host": TEST_HOST, - "password": TEST_PASSWORD, - "port": DEFAULT_PORT, - } - - assert len(mock_setup.mock_calls) == 1 - assert len(mock_setup_entry.mock_calls) == 1 - - async def test_form_invalid_auth(hass, mock_smile): """Test we handle invalid auth.""" result = await hass.config_entries.flow.async_init( From 840c5a944ddd8c931ed2996a6fc5f76ffc12eae6 Mon Sep 17 00:00:00 2001 From: Tom Scholten Date: Sat, 19 Sep 2020 11:29:37 +0200 Subject: [PATCH 10/10] Commit @ludaeus suggestion second part --- homeassistant/components/plugwise/config_flow.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/plugwise/config_flow.py b/homeassistant/components/plugwise/config_flow.py index 467e369917841d..14405062231cf2 100644 --- a/homeassistant/components/plugwise/config_flow.py +++ b/homeassistant/components/plugwise/config_flow.py @@ -103,7 +103,7 @@ async def async_step_user(self, user_input=None): if self.discovery_info: user_input[CONF_HOST] = self.discovery_info[CONF_HOST] - user_input[CONF_PORT] = self.discovery_info[CONF_PORT] + user_input[CONF_PORT] = self.discovery_info.get(CONF_PORT, DEFAULT_PORT) for entry in self._async_current_entries(): if entry.data.get(CONF_HOST) == user_input[CONF_HOST]: