Skip to content

Commit

Permalink
check wan access type (home-assistant#65389)
Browse files Browse the repository at this point in the history
  • Loading branch information
mib1185 authored and balloob committed Feb 6, 2022
1 parent 51abdf9 commit 5f6214e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
14 changes: 8 additions & 6 deletions homeassistant/components/fritz/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,11 +567,11 @@ def _service_call_action(
)
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]:
Expand Down Expand Up @@ -678,10 +678,12 @@ def get_wlan_configuration(self, index: int) -> dict[str, Any]:

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."""
Expand Down
12 changes: 8 additions & 4 deletions homeassistant/components/fritz/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5f6214e

Please sign in to comment.