From 1d4f319896b5dc4539f73311a8c9b829a62fc8b8 Mon Sep 17 00:00:00 2001 From: Jack Powell Date: Fri, 4 Oct 2024 19:36:33 -0400 Subject: [PATCH 1/4] Sign --- custom_components/unfoldedcircle/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/unfoldedcircle/manifest.json b/custom_components/unfoldedcircle/manifest.json index eab3be5..2858d22 100644 --- a/custom_components/unfoldedcircle/manifest.json +++ b/custom_components/unfoldedcircle/manifest.json @@ -15,6 +15,6 @@ "wakeonlan==3.1.0" ], "ssdp": [], - "version": "0.12.0", + "version": "0.13.0", "zeroconf": ["_uc-remote._tcp.local."] } From dadb8b0ca7dec9ca59511fa926f33c896e9813cb Mon Sep 17 00:00:00 2001 From: Jack Powell Date: Fri, 4 Oct 2024 19:53:37 -0400 Subject: [PATCH 2/4] Do not create create if WOL is unavailable --- custom_components/unfoldedcircle/switch.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/custom_components/unfoldedcircle/switch.py b/custom_components/unfoldedcircle/switch.py index 3074bdf..181a20f 100644 --- a/custom_components/unfoldedcircle/switch.py +++ b/custom_components/unfoldedcircle/switch.py @@ -141,9 +141,17 @@ async def async_setup_entry( for switch in filter(lambda a: a not in activities, coordinator.api.activities) ) + # Remove WOL switch if it is not available on the remote + switches: list = [] + if not coordinator.api._wake_on_lan_available: + for item in UNFOLDED_CIRCLE_SWITCH: + if item.key != "wake_on_lan": + switches.append(item) + else: + switches = UNFOLDED_CIRCLE_SWITCH + async_add_entities( - UCRemoteConfigSwitch(coordinator, configSwitch) - for configSwitch in UNFOLDED_CIRCLE_SWITCH + UCRemoteConfigSwitch(coordinator, configSwitch) for configSwitch in switches ) @service.verify_domain_control(hass, DOMAIN) @@ -229,8 +237,6 @@ def _handle_coordinator_update(self) -> None: class UCRemoteConfigSwitch(UnfoldedCircleEntity, SwitchEntity): """Class representing an unfolded circle setting.""" - entity_description = UNFOLDED_CIRCLE_SWITCH - def __init__( self, coordinator, description: UnfoldedCircleSwitchEntityDescription ) -> None: From 7583b84ce73cf070892fb15e092ea88bb25438aa Mon Sep 17 00:00:00 2001 From: Jack Powell Date: Fri, 4 Oct 2024 19:54:21 -0400 Subject: [PATCH 3/4] handle firmware < 2.0.0 --- .../pyUnfoldedCircleRemote/remote.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/custom_components/unfoldedcircle/pyUnfoldedCircleRemote/remote.py b/custom_components/unfoldedcircle/pyUnfoldedCircleRemote/remote.py index 7849662..0a678b1 100644 --- a/custom_components/unfoldedcircle/pyUnfoldedCircleRemote/remote.py +++ b/custom_components/unfoldedcircle/pyUnfoldedCircleRemote/remote.py @@ -176,10 +176,11 @@ def __init__( self._is_simulator = None self._docks: list[Dock] = [] self._wake_if_asleep = wake_if_asleep - self._wake_on_lan: bool = True - self._wake_on_lan_retries = 3 - self._bt_enabled: bool = True - self._wifi_enabled: bool = True + self._wake_on_lan: bool = False + self._wake_on_lan_retries = 2 + self._wake_on_lan_available: bool = False + self._bt_enabled: bool = False + self._wifi_enabled: bool = False @property def name(self): @@ -1289,9 +1290,15 @@ async def get_remote_network_settings(self) -> str: ): await self.raise_on_error(response) settings = await response.json() - self._wake_on_lan = settings.get("wake_on_wlan").get("enabled") + self._bt_enabled = settings.get("bt_enabled") self._wifi_enabled = settings.get("wifi_enabled") + + try: + self._wake_on_lan = settings.get("wake_on_wlan").get("enabled") + self._wake_on_lan_available = True + except AttributeError: + self._wake_on_lan = False return settings async def patch_remote_network_settings( @@ -1310,7 +1317,7 @@ async def patch_remote_network_settings( network_settings["bt_enabled"] = bt_enabled if wifi_enabled is not None: network_settings["wifi_enabled"] = wifi_enabled - if wake_on_lan is not None: + if wake_on_lan is not None and self._sw_version >= 2: network_settings["wake_on_wlan"]["enabled"] = wake_on_lan async with ( From 66b4973041d90d8b27b09c82e5098cb277a3cc03 Mon Sep 17 00:00:00 2001 From: Jack Powell Date: Fri, 4 Oct 2024 20:08:42 -0400 Subject: [PATCH 4/4] bump dependency --- custom_components/unfoldedcircle/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom_components/unfoldedcircle/manifest.json b/custom_components/unfoldedcircle/manifest.json index 2858d22..8c9e358 100644 --- a/custom_components/unfoldedcircle/manifest.json +++ b/custom_components/unfoldedcircle/manifest.json @@ -11,7 +11,7 @@ "issue_tracker": "https://github.com/JackJPowell/hass-unfoldedcircle/issues", "requirements": [ "websockets==12.0", - "pyUnfoldedCircleRemote==0.11.10", + "pyUnfoldedCircleRemote==0.11.11", "wakeonlan==3.1.0" ], "ssdp": [],