diff --git a/homeassistant/components/fritz/coordinator.py b/homeassistant/components/fritz/coordinator.py index 6ddd0eff51f..4d5d743560e 100644 --- a/homeassistant/components/fritz/coordinator.py +++ b/homeassistant/components/fritz/coordinator.py @@ -826,6 +826,21 @@ class AvmWrapper(FritzBoxTools): NewDisallow="0" if turn_on else "1", ) + async def async_get_current_user_rights(self) -> dict[str, Any]: + """Call X_AVM-DE_GetCurrentUser service.""" + + result = await self._async_service_call( + "LANConfigSecurity", + "1", + "X_AVM-DE_GetCurrentUser", + ) + + user_rights = xmltodict.parse(result["NewX_AVM-DE_CurrentUserRights"])["rights"] + + return { + k: user_rights["access"][idx] for idx, k in enumerate(user_rights["path"]) + } + async def async_wake_on_lan(self, mac_address: str) -> dict[str, Any]: """Call X_AVM-DE_WakeOnLANByMACAddress service.""" diff --git a/homeassistant/components/fritz/diagnostics.py b/homeassistant/components/fritz/diagnostics.py index e8cad15ec3b..bfeb22e2721 100644 --- a/homeassistant/components/fritz/diagnostics.py +++ b/homeassistant/components/fritz/diagnostics.py @@ -35,6 +35,7 @@ async def async_get_config_entry_diagnostics( "last_update success": avm_wrapper.last_update_success, "last_exception": avm_wrapper.last_exception, "discovered_services": list(avm_wrapper.connection.services), + "current_user_rights": await avm_wrapper.async_get_current_user_rights(), "client_devices": [ { "connected_to": device.connected_to, diff --git a/tests/components/fritz/const.py b/tests/components/fritz/const.py index c1908c12a14..8154162000a 100644 --- a/tests/components/fritz/const.py +++ b/tests/components/fritz/const.py @@ -72,6 +72,12 @@ MOCK_FB_SERVICES: dict[str, dict] = { "NewBytesReceived": 12045, }, }, + "LANConfigSecurity1": { + "X_AVM-DE_GetCurrentUser": { + "NewX_AVM-DE_CurrentUsername": "fake_user", + "NewX_AVM-DE_CurrentUserRights": "BoxAdminreadwritePhonereadwriteDialreadwriteNASnoneHomeAutoreadwriteAppreadwrite", + } + }, "Layer3Forwarding1": { "GetDefaultConnectionService": { "NewDefaultConnectionService": "1.WANPPPConnection.1" diff --git a/tests/components/fritz/snapshots/test_diagnostics.ambr b/tests/components/fritz/snapshots/test_diagnostics.ambr index dead09cae4a..aba450ba784 100644 --- a/tests/components/fritz/snapshots/test_diagnostics.ambr +++ b/tests/components/fritz/snapshots/test_diagnostics.ambr @@ -18,10 +18,19 @@ 67, ]), 'current_firmware': '7.29', + 'current_user_rights': dict({ + 'App': 'readwrite', + 'BoxAdmin': 'readwrite', + 'Dial': 'readwrite', + 'HomeAuto': 'readwrite', + 'NAS': 'none', + 'Phone': 'readwrite', + }), 'discovered_services': list([ 'DeviceInfo1', 'Hosts1', 'LANEthernetInterfaceConfig1', + 'LANConfigSecurity1', 'Layer3Forwarding1', 'UserInterface1', 'WANCommonIFC1',