mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Change detection of router devices for Fritz (#65965)
This commit is contained in:
parent
339fc0a2af
commit
bebdaacf47
@ -155,7 +155,8 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator):
|
|||||||
self.hass = hass
|
self.hass = hass
|
||||||
self.host = host
|
self.host = host
|
||||||
self.mesh_role = MeshRoles.NONE
|
self.mesh_role = MeshRoles.NONE
|
||||||
self.device_is_router: bool = True
|
self.device_conn_type: str | None = None
|
||||||
|
self.device_is_router: bool = False
|
||||||
self.password = password
|
self.password = password
|
||||||
self.port = port
|
self.port = port
|
||||||
self.username = username
|
self.username = username
|
||||||
@ -213,7 +214,15 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator):
|
|||||||
self._current_firmware = info.get("NewSoftwareVersion")
|
self._current_firmware = info.get("NewSoftwareVersion")
|
||||||
|
|
||||||
self._update_available, self._latest_firmware = self._update_device_info()
|
self._update_available, self._latest_firmware = self._update_device_info()
|
||||||
self.device_is_router = "WANIPConn1" in self.connection.services
|
if "Layer3Forwarding1" in self.connection.services:
|
||||||
|
if connection_type := self.connection.call_action(
|
||||||
|
"Layer3Forwarding1", "GetDefaultConnectionService"
|
||||||
|
).get("NewDefaultConnectionService"):
|
||||||
|
# Return NewDefaultConnectionService sample: "1.WANPPPConnection.1"
|
||||||
|
self.device_conn_type = connection_type[2:][:-2]
|
||||||
|
self.device_is_router = self.connection.call_action(
|
||||||
|
self.device_conn_type, "GetInfo"
|
||||||
|
).get("NewEnable")
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
async def _async_update_data(self) -> None:
|
async def _async_update_data(self) -> None:
|
||||||
|
@ -25,6 +25,7 @@ async def async_get_config_entry_diagnostics(
|
|||||||
"current_firmware": avm_wrapper.current_firmware,
|
"current_firmware": avm_wrapper.current_firmware,
|
||||||
"latest_firmware": avm_wrapper.latest_firmware,
|
"latest_firmware": avm_wrapper.latest_firmware,
|
||||||
"update_available": avm_wrapper.update_available,
|
"update_available": avm_wrapper.update_available,
|
||||||
|
"connection_type": avm_wrapper.device_conn_type,
|
||||||
"is_router": avm_wrapper.device_is_router,
|
"is_router": avm_wrapper.device_is_router,
|
||||||
"mesh_role": avm_wrapper.mesh_role,
|
"mesh_role": avm_wrapper.mesh_role,
|
||||||
"last_update success": avm_wrapper.last_update_success,
|
"last_update success": avm_wrapper.last_update_success,
|
||||||
|
@ -81,16 +81,12 @@ def port_entities_list(
|
|||||||
|
|
||||||
_LOGGER.debug("Setting up %s switches", SWITCH_TYPE_PORTFORWARD)
|
_LOGGER.debug("Setting up %s switches", SWITCH_TYPE_PORTFORWARD)
|
||||||
entities_list: list[FritzBoxPortSwitch] = []
|
entities_list: list[FritzBoxPortSwitch] = []
|
||||||
connection_type = avm_wrapper.get_default_connection()
|
if not avm_wrapper.device_conn_type:
|
||||||
if not connection_type:
|
|
||||||
_LOGGER.debug("The FRITZ!Box has no %s options", SWITCH_TYPE_PORTFORWARD)
|
_LOGGER.debug("The FRITZ!Box has no %s options", SWITCH_TYPE_PORTFORWARD)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
# Return NewDefaultConnectionService sample: "1.WANPPPConnection.1"
|
|
||||||
con_type: str = connection_type["NewDefaultConnectionService"][2:][:-2]
|
|
||||||
|
|
||||||
# Query port forwardings and setup a switch for each forward for the current device
|
# Query port forwardings and setup a switch for each forward for the current device
|
||||||
resp = avm_wrapper.get_num_port_mapping(con_type)
|
resp = avm_wrapper.get_num_port_mapping(avm_wrapper.device_conn_type)
|
||||||
if not resp:
|
if not resp:
|
||||||
_LOGGER.debug("The FRITZ!Box has no %s options", SWITCH_TYPE_DEFLECTION)
|
_LOGGER.debug("The FRITZ!Box has no %s options", SWITCH_TYPE_DEFLECTION)
|
||||||
return []
|
return []
|
||||||
@ -107,7 +103,7 @@ def port_entities_list(
|
|||||||
|
|
||||||
for i in range(port_forwards_count):
|
for i in range(port_forwards_count):
|
||||||
|
|
||||||
portmap = avm_wrapper.get_port_mapping(con_type, i)
|
portmap = avm_wrapper.get_port_mapping(avm_wrapper.device_conn_type, i)
|
||||||
if not portmap:
|
if not portmap:
|
||||||
_LOGGER.debug("The FRITZ!Box has no %s options", SWITCH_TYPE_DEFLECTION)
|
_LOGGER.debug("The FRITZ!Box has no %s options", SWITCH_TYPE_DEFLECTION)
|
||||||
continue
|
continue
|
||||||
@ -133,7 +129,7 @@ def port_entities_list(
|
|||||||
portmap,
|
portmap,
|
||||||
port_name,
|
port_name,
|
||||||
i,
|
i,
|
||||||
con_type,
|
avm_wrapper.device_conn_type,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user