From b87bbd15297554ac68377fd4595dc405536f5b03 Mon Sep 17 00:00:00 2001 From: YogevBokobza Date: Wed, 10 Jan 2024 21:41:16 +0200 Subject: [PATCH] Bump aioswitcher to 3.4.1 (#107730) * switcher: added support for device_key logic included in aioswitcher==3.4.1 * switcher: small fix * switcher: after lint * switcher: fix missing device_key in tests * remove device_key function * fix missing device_key in tests --- homeassistant/components/switcher_kis/__init__.py | 3 ++- homeassistant/components/switcher_kis/button.py | 4 +++- homeassistant/components/switcher_kis/climate.py | 4 +++- homeassistant/components/switcher_kis/cover.py | 4 +++- homeassistant/components/switcher_kis/diagnostics.py | 2 +- homeassistant/components/switcher_kis/manifest.json | 2 +- homeassistant/components/switcher_kis/switch.py | 4 +++- requirements_all.txt | 2 +- requirements_test_all.txt | 2 +- tests/components/switcher_kis/consts.py | 8 ++++++++ tests/components/switcher_kis/test_diagnostics.py | 1 + 11 files changed, 27 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/switcher_kis/__init__.py b/homeassistant/components/switcher_kis/__init__.py index fb6ded99346..051c5d2b72a 100644 --- a/homeassistant/components/switcher_kis/__init__.py +++ b/homeassistant/components/switcher_kis/__init__.py @@ -89,8 +89,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: # New device - create device _LOGGER.info( - "Discovered Switcher device - id: %s, name: %s, type: %s (%s)", + "Discovered Switcher device - id: %s, key: %s, name: %s, type: %s (%s)", device.device_id, + device.device_key, device.name, device.device_type.value, device.device_type.hex_rep, diff --git a/homeassistant/components/switcher_kis/button.py b/homeassistant/components/switcher_kis/button.py index 5a1b7c821d2..2085398232f 100644 --- a/homeassistant/components/switcher_kis/button.py +++ b/homeassistant/components/switcher_kis/button.py @@ -142,7 +142,9 @@ class SwitcherThermostatButtonEntity( try: async with SwitcherType2Api( - self.coordinator.data.ip_address, self.coordinator.data.device_id + self.coordinator.data.ip_address, + self.coordinator.data.device_id, + self.coordinator.data.device_key, ) as swapi: response = await self.entity_description.press_fn(swapi, self._remote) except (asyncio.TimeoutError, OSError, RuntimeError) as err: diff --git a/homeassistant/components/switcher_kis/climate.py b/homeassistant/components/switcher_kis/climate.py index 809e3d6a3ad..272d3ccf6ef 100644 --- a/homeassistant/components/switcher_kis/climate.py +++ b/homeassistant/components/switcher_kis/climate.py @@ -162,7 +162,9 @@ class SwitcherClimateEntity( try: async with SwitcherType2Api( - self.coordinator.data.ip_address, self.coordinator.data.device_id + self.coordinator.data.ip_address, + self.coordinator.data.device_id, + self.coordinator.data.device_key, ) as swapi: response = await swapi.control_breeze_device(self._remote, **kwargs) except (asyncio.TimeoutError, OSError, RuntimeError) as err: diff --git a/homeassistant/components/switcher_kis/cover.py b/homeassistant/components/switcher_kis/cover.py index c627f361d7d..1e34ddd2325 100644 --- a/homeassistant/components/switcher_kis/cover.py +++ b/homeassistant/components/switcher_kis/cover.py @@ -98,7 +98,9 @@ class SwitcherCoverEntity( try: async with SwitcherType2Api( - self.coordinator.data.ip_address, self.coordinator.data.device_id + self.coordinator.data.ip_address, + self.coordinator.data.device_id, + self.coordinator.data.device_key, ) as swapi: response = await getattr(swapi, api)(*args) except (asyncio.TimeoutError, OSError, RuntimeError) as err: diff --git a/homeassistant/components/switcher_kis/diagnostics.py b/homeassistant/components/switcher_kis/diagnostics.py index 93b3c36bd21..765a3dde9e7 100644 --- a/homeassistant/components/switcher_kis/diagnostics.py +++ b/homeassistant/components/switcher_kis/diagnostics.py @@ -10,7 +10,7 @@ from homeassistant.core import HomeAssistant from .const import DATA_DEVICE, DOMAIN -TO_REDACT = {"device_id", "ip_address", "mac_address"} +TO_REDACT = {"device_id", "device_key", "ip_address", "mac_address"} async def async_get_config_entry_diagnostics( diff --git a/homeassistant/components/switcher_kis/manifest.json b/homeassistant/components/switcher_kis/manifest.json index 9accda95912..055c92cc2fa 100644 --- a/homeassistant/components/switcher_kis/manifest.json +++ b/homeassistant/components/switcher_kis/manifest.json @@ -7,5 +7,5 @@ "iot_class": "local_push", "loggers": ["aioswitcher"], "quality_scale": "platinum", - "requirements": ["aioswitcher==3.3.0"] + "requirements": ["aioswitcher==3.4.1"] } diff --git a/homeassistant/components/switcher_kis/switch.py b/homeassistant/components/switcher_kis/switch.py index ef8564b3770..f37e16aa513 100644 --- a/homeassistant/components/switcher_kis/switch.py +++ b/homeassistant/components/switcher_kis/switch.py @@ -111,7 +111,9 @@ class SwitcherBaseSwitchEntity( try: async with SwitcherType1Api( - self.coordinator.data.ip_address, self.coordinator.data.device_id + self.coordinator.data.ip_address, + self.coordinator.data.device_id, + self.coordinator.data.device_key, ) as swapi: response = await getattr(swapi, api)(*args) except (asyncio.TimeoutError, OSError, RuntimeError) as err: diff --git a/requirements_all.txt b/requirements_all.txt index 15fcfc91155..4bc66778cb9 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -368,7 +368,7 @@ aioslimproto==2.3.3 aiosteamist==0.3.2 # homeassistant.components.switcher_kis -aioswitcher==3.3.0 +aioswitcher==3.4.1 # homeassistant.components.syncthing aiosyncthing==0.5.1 diff --git a/requirements_test_all.txt b/requirements_test_all.txt index e2f0c7b040e..5b43cfa28c8 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -341,7 +341,7 @@ aioslimproto==2.3.3 aiosteamist==0.3.2 # homeassistant.components.switcher_kis -aioswitcher==3.3.0 +aioswitcher==3.4.1 # homeassistant.components.syncthing aiosyncthing==0.5.1 diff --git a/tests/components/switcher_kis/consts.py b/tests/components/switcher_kis/consts.py index eaf6a69cb3d..aa0370bd347 100644 --- a/tests/components/switcher_kis/consts.py +++ b/tests/components/switcher_kis/consts.py @@ -26,6 +26,10 @@ DUMMY_DEVICE_ID1 = "a123bc" DUMMY_DEVICE_ID2 = "cafe12" DUMMY_DEVICE_ID3 = "bada77" DUMMY_DEVICE_ID4 = "bbd164" +DUMMY_DEVICE_KEY1 = "18" +DUMMY_DEVICE_KEY2 = "01" +DUMMY_DEVICE_KEY3 = "12" +DUMMY_DEVICE_KEY4 = "07" DUMMY_DEVICE_NAME1 = "Plug 23BC" DUMMY_DEVICE_NAME2 = "Heater FE12" DUMMY_DEVICE_NAME3 = "Breeze AB39" @@ -67,6 +71,7 @@ DUMMY_PLUG_DEVICE = SwitcherPowerPlug( DeviceType.POWER_PLUG, DeviceState.ON, DUMMY_DEVICE_ID1, + DUMMY_DEVICE_KEY1, DUMMY_IP_ADDRESS1, DUMMY_MAC_ADDRESS1, DUMMY_DEVICE_NAME1, @@ -78,6 +83,7 @@ DUMMY_WATER_HEATER_DEVICE = SwitcherWaterHeater( DeviceType.V4, DeviceState.ON, DUMMY_DEVICE_ID2, + DUMMY_DEVICE_KEY2, DUMMY_IP_ADDRESS2, DUMMY_MAC_ADDRESS2, DUMMY_DEVICE_NAME2, @@ -91,6 +97,7 @@ DUMMY_SHUTTER_DEVICE = SwitcherShutter( DeviceType.RUNNER, DeviceState.ON, DUMMY_DEVICE_ID4, + DUMMY_DEVICE_KEY4, DUMMY_IP_ADDRESS4, DUMMY_MAC_ADDRESS4, DUMMY_DEVICE_NAME4, @@ -102,6 +109,7 @@ DUMMY_THERMOSTAT_DEVICE = SwitcherThermostat( DeviceType.BREEZE, DeviceState.ON, DUMMY_DEVICE_ID3, + DUMMY_DEVICE_KEY3, DUMMY_IP_ADDRESS3, DUMMY_MAC_ADDRESS3, DUMMY_DEVICE_NAME3, diff --git a/tests/components/switcher_kis/test_diagnostics.py b/tests/components/switcher_kis/test_diagnostics.py index f238bceb39e..f49ab99ba6c 100644 --- a/tests/components/switcher_kis/test_diagnostics.py +++ b/tests/components/switcher_kis/test_diagnostics.py @@ -25,6 +25,7 @@ async def test_diagnostics( { "auto_shutdown": "02:00:00", "device_id": REDACTED, + "device_key": REDACTED, "device_state": { "__type": "", "repr": "",