From bb5c1ad6590b60a7650b49cf09d5e6fa73ba962f Mon Sep 17 00:00:00 2001 From: Simone Chemelli Date: Thu, 15 Sep 2022 16:05:58 +0200 Subject: [PATCH] Remove some low level calls from Fritz (#77848) Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com> --- homeassistant/components/fritz/common.py | 31 +++++++++--------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/homeassistant/components/fritz/common.py b/homeassistant/components/fritz/common.py index d424b38ec24..6364ada9fb2 100644 --- a/homeassistant/components/fritz/common.py +++ b/homeassistant/components/fritz/common.py @@ -207,38 +207,35 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator): self.fritz_hosts = FritzHosts(fc=self.connection) self.fritz_guest_wifi = FritzGuestWLAN(fc=self.connection) self.fritz_status = FritzStatus(fc=self.connection) - info = self.connection.call_action("DeviceInfo:1", "GetInfo") + info = self.fritz_status.get_device_info() _LOGGER.debug( "gathered device info of %s %s", self.host, { - **info, + **vars(info), "NewDeviceLog": "***omitted***", "NewSerialNumber": "***omitted***", }, ) if not self._unique_id: - self._unique_id = info["NewSerialNumber"] + self._unique_id = info.serial_number - self._model = info.get("NewModelName") - self._current_firmware = info.get("NewSoftwareVersion") + self._model = info.model_name + self._current_firmware = info.software_version ( self._update_available, self._latest_firmware, self._release_url, ) = self._update_device_info() - 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") + + if self.fritz_status.has_wan_support: + self.device_conn_type = ( + self.fritz_status.get_default_connection_service().connection_service + ) + self.device_is_router = self.fritz_status.has_wan_enabled async def _async_update_data(self) -> None: """Update FritzboxTools data.""" @@ -401,11 +398,7 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator): wan_access=None, ) - if ( - "Hosts1" not in self.connection.services - or "X_AVM-DE_GetMeshListPath" - not in self.connection.services["Hosts1"].actions - ) or ( + if not self.fritz_status.device_has_mesh_support or ( self._options and self._options.get(CONF_OLD_DISCOVERY, DEFAULT_CONF_OLD_DISCOVERY) ):