From dc65c621edf0e0a7914fd69c0439fce22367235f Mon Sep 17 00:00:00 2001 From: Michael <35783820+mib1185@users.noreply.github.com> Date: Sun, 6 Feb 2022 23:17:10 +0100 Subject: [PATCH] check wan access type (#65389) --- homeassistant/components/fritz/common.py | 14 ++++++++------ homeassistant/components/fritz/sensor.py | 12 ++++++++---- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/homeassistant/components/fritz/common.py b/homeassistant/components/fritz/common.py index 667d94695d3..8786a09b215 100644 --- a/homeassistant/components/fritz/common.py +++ b/homeassistant/components/fritz/common.py @@ -586,11 +586,11 @@ class AvmWrapper(FritzBoxTools): ) return {} - async def async_get_wan_dsl_interface_config(self) -> dict[str, Any]: - """Call WANDSLInterfaceConfig service.""" + async def async_get_wan_link_properties(self) -> dict[str, Any]: + """Call WANCommonInterfaceConfig service.""" return await self.hass.async_add_executor_job( - partial(self.get_wan_dsl_interface_config) + partial(self.get_wan_link_properties) ) async def async_get_wan_link_properties(self) -> dict[str, Any]: @@ -697,10 +697,12 @@ class AvmWrapper(FritzBoxTools): return self._service_call_action("WLANConfiguration", str(index), "GetInfo") - def get_wan_dsl_interface_config(self) -> dict[str, Any]: - """Call WANDSLInterfaceConfig service.""" + def get_wan_link_properties(self) -> dict[str, Any]: + """Call WANCommonInterfaceConfig service.""" - return self._service_call_action("WANDSLInterfaceConfig", "1", "GetInfo") + return self._service_call_action( + "WANCommonInterfaceConfig", "1", "GetCommonLinkProperties" + ) def get_wan_link_properties(self) -> dict[str, Any]: """Call WANCommonInterfaceConfig service.""" diff --git a/homeassistant/components/fritz/sensor.py b/homeassistant/components/fritz/sensor.py index 6155cdc5914..5e4b18eebca 100644 --- a/homeassistant/components/fritz/sensor.py +++ b/homeassistant/components/fritz/sensor.py @@ -277,10 +277,14 @@ async def async_setup_entry( _LOGGER.debug("Setting up FRITZ!Box sensors") avm_wrapper: AvmWrapper = hass.data[DOMAIN][entry.entry_id] - dsl: bool = False - dslinterface = await avm_wrapper.async_get_wan_dsl_interface_config() - if dslinterface: - dsl = dslinterface["NewEnable"] + link_properties = await avm_wrapper.async_get_wan_link_properties() + dsl: bool = link_properties.get("NewWANAccessType") == "DSL" + + _LOGGER.debug( + "WANAccessType of FritzBox %s is '%s'", + avm_wrapper.host, + link_properties.get("NewWANAccessType"), + ) entities = [ FritzBoxSensor(avm_wrapper, entry.title, description)