mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 12:47:08 +00:00
Fix wifi switches name for Fritz (#66529)
This commit is contained in:
parent
7e3d87a146
commit
4f2be58fe4
@ -64,3 +64,5 @@ FRITZ_EXCEPTIONS = (
|
|||||||
FritzServiceError,
|
FritzServiceError,
|
||||||
FritzLookUpError,
|
FritzLookUpError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
WIFI_STANDARD = {1: "2.4Ghz", 2: "5Ghz", 3: "5Ghz", 4: "Guest"}
|
||||||
|
@ -31,6 +31,7 @@ from .const import (
|
|||||||
SWITCH_TYPE_DEFLECTION,
|
SWITCH_TYPE_DEFLECTION,
|
||||||
SWITCH_TYPE_PORTFORWARD,
|
SWITCH_TYPE_PORTFORWARD,
|
||||||
SWITCH_TYPE_WIFINETWORK,
|
SWITCH_TYPE_WIFINETWORK,
|
||||||
|
WIFI_STANDARD,
|
||||||
MeshRoles,
|
MeshRoles,
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -141,31 +142,43 @@ def wifi_entities_list(
|
|||||||
) -> list[FritzBoxWifiSwitch]:
|
) -> list[FritzBoxWifiSwitch]:
|
||||||
"""Get list of wifi entities."""
|
"""Get list of wifi entities."""
|
||||||
_LOGGER.debug("Setting up %s switches", SWITCH_TYPE_WIFINETWORK)
|
_LOGGER.debug("Setting up %s switches", SWITCH_TYPE_WIFINETWORK)
|
||||||
std_table = {"ax": "Wifi6", "ac": "5Ghz", "n": "2.4Ghz"}
|
|
||||||
if avm_wrapper.model == "FRITZ!Box 7390":
|
|
||||||
std_table = {"n": "5Ghz"}
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# https://avm.de/fileadmin/user_upload/Global/Service/Schnittstellen/wlanconfigSCPD.pdf
|
||||||
|
#
|
||||||
|
wifi_count = len(
|
||||||
|
[
|
||||||
|
s
|
||||||
|
for s in avm_wrapper.connection.services
|
||||||
|
if s.startswith("WLANConfiguration")
|
||||||
|
]
|
||||||
|
)
|
||||||
|
_LOGGER.debug("WiFi networks count: %s", wifi_count)
|
||||||
networks: dict = {}
|
networks: dict = {}
|
||||||
for i in range(4):
|
for i in range(1, wifi_count + 1):
|
||||||
if not ("WLANConfiguration" + str(i)) in avm_wrapper.connection.services:
|
network_info = avm_wrapper.connection.call_action(
|
||||||
continue
|
f"WLANConfiguration{i}", "GetInfo"
|
||||||
|
)
|
||||||
network_info = avm_wrapper.get_wlan_configuration(i)
|
# Devices with 4 WLAN services, use the 2nd for internal communications
|
||||||
if network_info:
|
if not (wifi_count == 4 and i == 2):
|
||||||
ssid = network_info["NewSSID"]
|
networks[i] = {
|
||||||
_LOGGER.debug("SSID from device: <%s>", ssid)
|
"ssid": network_info["NewSSID"],
|
||||||
if slugify(
|
"bssid": network_info["NewBSSID"],
|
||||||
ssid,
|
"standard": network_info["NewStandard"],
|
||||||
) in [slugify(v) for v in networks.values()]:
|
"enabled": network_info["NewEnable"],
|
||||||
_LOGGER.debug("SSID duplicated, adding suffix")
|
"status": network_info["NewStatus"],
|
||||||
networks[i] = f'{ssid} {std_table[network_info["NewStandard"]]}'
|
}
|
||||||
else:
|
for i, network in networks.copy().items():
|
||||||
networks[i] = ssid
|
networks[i]["switch_name"] = network["ssid"]
|
||||||
_LOGGER.debug("SSID normalized: <%s>", networks[i])
|
if len([j for j, n in networks.items() if n["ssid"] == network["ssid"]]) > 1:
|
||||||
|
networks[i]["switch_name"] += f" ({WIFI_STANDARD[i]})"
|
||||||
|
|
||||||
|
_LOGGER.debug("WiFi networks list: %s", networks)
|
||||||
return [
|
return [
|
||||||
FritzBoxWifiSwitch(avm_wrapper, device_friendly_name, net, network_name)
|
FritzBoxWifiSwitch(
|
||||||
for net, network_name in networks.items()
|
avm_wrapper, device_friendly_name, index, data["switch_name"]
|
||||||
|
)
|
||||||
|
for index, data in networks.items()
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user