Skip to content

Commit

Permalink
Allow wifi switches for mesh repeaters in AVM Fritz!Box Tools (home-a…
Browse files Browse the repository at this point in the history
…ssistant#135456)

* create wifi switches for mesh slaves, but disable them by default

* check if mesh isbased on wifi uplink

* fix
  • Loading branch information
mib1185 authored Feb 16, 2025
1 parent 2d5e920 commit f67fb99
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions homeassistant/components/fritz/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def __init__(
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
Expand Down Expand Up @@ -610,6 +611,12 @@ async def async_scan_devices(self, now: datetime | None = None) -> None:
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"])

Expand Down
6 changes: 5 additions & 1 deletion homeassistant/components/fritz/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
Expand Down Expand Up @@ -565,6 +566,9 @@ def __init__(

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(
Expand Down

0 comments on commit f67fb99

Please sign in to comment.