From 2f374abc586dedc95ecfb585aa502b8021d2224d Mon Sep 17 00:00:00 2001 From: Robert Svensson Date: Sat, 2 May 2020 23:16:18 +0200 Subject: [PATCH] UniFi - Add support for 2.4/5 GHz separated SSIDs (#35062) --- homeassistant/components/unifi/config_flow.py | 7 ++++++- homeassistant/components/unifi/controller.py | 2 +- homeassistant/components/unifi/manifest.json | 2 +- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/unifi/test_config_flow.py | 9 ++++++--- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/unifi/config_flow.py b/homeassistant/components/unifi/config_flow.py index d62df809c2e..38d37560952 100644 --- a/homeassistant/components/unifi/config_flow.py +++ b/homeassistant/components/unifi/config_flow.py @@ -199,7 +199,12 @@ class UnifiOptionsFlowHandler(config_entries.OptionsFlow): self.options.update(user_input) return await self.async_step_client_control() - ssid_filter = {wlan: wlan for wlan in self.controller.api.wlans} + ssids = list(self.controller.api.wlans) + [ + f"{wlan.name}{wlan.name_combine_suffix}" + for wlan in self.controller.api.wlans.values() + if not wlan.name_combine_enabled + ] + ssid_filter = {ssid: ssid for ssid in sorted(ssids)} return self.async_show_form( step_id="device_tracker", diff --git a/homeassistant/components/unifi/controller.py b/homeassistant/components/unifi/controller.py index 33e7fc3836b..2500d6b4106 100644 --- a/homeassistant/components/unifi/controller.py +++ b/homeassistant/components/unifi/controller.py @@ -188,7 +188,7 @@ class UniFiController: elif signal == SIGNAL_DATA and data: if DATA_EVENT in data: - if data[DATA_EVENT].event in ( + if next(iter(data[DATA_EVENT])).event in ( WIRELESS_CLIENT_CONNECTED, WIRELESS_GUEST_CONNECTED, ): diff --git a/homeassistant/components/unifi/manifest.json b/homeassistant/components/unifi/manifest.json index 0a5ba84cdb3..8c05d195316 100644 --- a/homeassistant/components/unifi/manifest.json +++ b/homeassistant/components/unifi/manifest.json @@ -3,7 +3,7 @@ "name": "Ubiquiti UniFi", "config_flow": true, "documentation": "https://www.home-assistant.io/integrations/unifi", - "requirements": ["aiounifi==18"], + "requirements": ["aiounifi==20"], "codeowners": ["@kane610"], "quality_scale": "platinum" } diff --git a/requirements_all.txt b/requirements_all.txt index 24b9a039f05..7396382957a 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -212,7 +212,7 @@ aiopylgtv==0.3.3 aioswitcher==1.1.0 # homeassistant.components.unifi -aiounifi==18 +aiounifi==20 # homeassistant.components.wwlln aiowwlln==2.0.2 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 662f92c03dc..25ab458ca9d 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -95,7 +95,7 @@ aiopylgtv==0.3.3 aioswitcher==1.1.0 # homeassistant.components.unifi -aiounifi==18 +aiounifi==20 # homeassistant.components.wwlln aiowwlln==2.0.2 diff --git a/tests/components/unifi/test_config_flow.py b/tests/components/unifi/test_config_flow.py index 6c675bce53c..4f29bd0a3d1 100644 --- a/tests/components/unifi/test_config_flow.py +++ b/tests/components/unifi/test_config_flow.py @@ -32,7 +32,10 @@ from tests.common import MockConfigEntry CLIENTS = [{"mac": "00:00:00:00:00:01"}] -WLANS = [{"name": "SSID 1"}, {"name": "SSID 2"}] +WLANS = [ + {"name": "SSID 1"}, + {"name": "SSID 2", "name_combine_enabled": False, "name_combine_suffix": "_IOT"}, +] async def test_flow_works(hass, aioclient_mock, mock_discovery): @@ -331,7 +334,7 @@ async def test_option_flow(hass): CONF_TRACK_CLIENTS: False, CONF_TRACK_WIRED_CLIENTS: False, CONF_TRACK_DEVICES: False, - CONF_SSID_FILTER: ["SSID 1"], + CONF_SSID_FILTER: ["SSID 1", "SSID 2_IOT"], CONF_DETECTION_TIME: 100, }, ) @@ -356,7 +359,7 @@ async def test_option_flow(hass): CONF_TRACK_CLIENTS: False, CONF_TRACK_WIRED_CLIENTS: False, CONF_TRACK_DEVICES: False, - CONF_SSID_FILTER: ["SSID 1"], + CONF_SSID_FILTER: ["SSID 1", "SSID 2_IOT"], CONF_DETECTION_TIME: 100, CONF_IGNORE_WIRED_BUG: False, CONF_POE_CLIENTS: False,