From f67fb9985e378467cc5d8aac07ebd636c1e76bda Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Sun, 16 Feb 2025 15:12:16 +0100 Subject: [PATCH] Allow wifi switches for mesh repeaters in AVM Fritz!Box Tools (#135456) * create wifi switches for mesh slaves, but disable them by default * check if mesh isbased on wifi uplink * fix --- homeassistant/components/fritz/coordinator.py | 7 +++++++ homeassistant/components/fritz/switch.py | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/fritz/coordinator.py b/homeassistant/components/fritz/coordinator.py index 38d76c92871..d60232ec8ad 100644 --- a/homeassistant/components/fritz/coordinator.py +++ b/homeassistant/components/fritz/coordinator.py @@ -196,6 +196,7 @@ class FritzBoxTools(DataUpdateCoordinator[UpdateCoordinatorDataType]): self.hass = hass self.host = host self.mesh_role = MeshRoles.NONE + self.mesh_wifi_uplink = False self.device_conn_type: str | None = None self.device_is_router: bool = False self.password = password @@ -610,6 +611,12 @@ class FritzBoxTools(DataUpdateCoordinator[UpdateCoordinatorDataType]): ssid=interf.get("ssid", ""), type=interf["type"], ) + + if interf["type"].lower() == "wlan" and interf[ + "name" + ].lower().startswith("uplink"): + self.mesh_wifi_uplink = True + if dr.format_mac(int_mac) == self.mac: self.mesh_role = MeshRoles(node["mesh_role"]) diff --git a/homeassistant/components/fritz/switch.py b/homeassistant/components/fritz/switch.py index 1548f8fc755..8b4816f7451 100644 --- a/homeassistant/components/fritz/switch.py +++ b/homeassistant/components/fritz/switch.py @@ -207,8 +207,9 @@ async def async_all_entities_list( local_ip: str, ) -> list[Entity]: """Get a list of all entities.""" - if avm_wrapper.mesh_role == MeshRoles.SLAVE: + if not avm_wrapper.mesh_wifi_uplink: + return [*await _async_wifi_entities_list(avm_wrapper, device_friendly_name)] return [] return [ @@ -565,6 +566,9 @@ class FritzBoxWifiSwitch(FritzBoxBaseSwitch): self._attributes = {} self._attr_entity_category = EntityCategory.CONFIG + self._attr_entity_registry_enabled_default = ( + avm_wrapper.mesh_role is not MeshRoles.SLAVE + ) self._network_num = network_num switch_info = SwitchInfo(