mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Handle Fritz portmapping with same name (#56398)
This commit is contained in:
parent
fa716d92ad
commit
b9d81c3a7e
@ -167,7 +167,7 @@ def port_entities_list(
|
|||||||
"""Get list of port forwarding entities."""
|
"""Get list of port forwarding entities."""
|
||||||
|
|
||||||
_LOGGER.debug("Setting up %s switches", SWITCH_TYPE_PORTFORWARD)
|
_LOGGER.debug("Setting up %s switches", SWITCH_TYPE_PORTFORWARD)
|
||||||
entities_list: list = []
|
entities_list: list[FritzBoxPortSwitch] = []
|
||||||
service_name = "Layer3Forwarding"
|
service_name = "Layer3Forwarding"
|
||||||
connection_type = service_call_action(
|
connection_type = service_call_action(
|
||||||
fritzbox_tools, service_name, "1", "GetDefaultConnectionService"
|
fritzbox_tools, service_name, "1", "GetDefaultConnectionService"
|
||||||
@ -219,11 +219,18 @@ def port_entities_list(
|
|||||||
|
|
||||||
# We can only handle port forwards of the given device
|
# We can only handle port forwards of the given device
|
||||||
if portmap["NewInternalClient"] == local_ip:
|
if portmap["NewInternalClient"] == local_ip:
|
||||||
|
port_name = portmap["NewPortMappingDescription"]
|
||||||
|
for entity in entities_list:
|
||||||
|
if entity.port_mapping and (
|
||||||
|
port_name in entity.port_mapping["NewPortMappingDescription"]
|
||||||
|
):
|
||||||
|
port_name = f"{port_name} {portmap['NewExternalPort']}"
|
||||||
entities_list.append(
|
entities_list.append(
|
||||||
FritzBoxPortSwitch(
|
FritzBoxPortSwitch(
|
||||||
fritzbox_tools,
|
fritzbox_tools,
|
||||||
device_friendly_name,
|
device_friendly_name,
|
||||||
portmap,
|
portmap,
|
||||||
|
port_name,
|
||||||
i,
|
i,
|
||||||
con_type,
|
con_type,
|
||||||
)
|
)
|
||||||
@ -430,6 +437,7 @@ class FritzBoxPortSwitch(FritzBoxBaseSwitch, SwitchEntity):
|
|||||||
fritzbox_tools: FritzBoxTools,
|
fritzbox_tools: FritzBoxTools,
|
||||||
device_friendly_name: str,
|
device_friendly_name: str,
|
||||||
port_mapping: dict[str, Any] | None,
|
port_mapping: dict[str, Any] | None,
|
||||||
|
port_name: str,
|
||||||
idx: int,
|
idx: int,
|
||||||
connection_type: str,
|
connection_type: str,
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -445,7 +453,7 @@ class FritzBoxPortSwitch(FritzBoxBaseSwitch, SwitchEntity):
|
|||||||
return
|
return
|
||||||
|
|
||||||
switch_info = SwitchInfo(
|
switch_info = SwitchInfo(
|
||||||
description=f'Port forward {port_mapping["NewPortMappingDescription"]}',
|
description=f"Port forward {port_name}",
|
||||||
friendly_name=device_friendly_name,
|
friendly_name=device_friendly_name,
|
||||||
icon="mdi:check-network",
|
icon="mdi:check-network",
|
||||||
type=SWITCH_TYPE_PORTFORWARD,
|
type=SWITCH_TYPE_PORTFORWARD,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user