Remove some low level calls from Fritz (#77848)

Co-authored-by: Michael <35783820+mib1185@users.noreply.github.com>
This commit is contained in:
Simone Chemelli 2022-09-15 16:05:58 +02:00 committed by GitHub
parent 6f02f7c6ce
commit bb5c1ad659
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -207,38 +207,35 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator):
self.fritz_hosts = FritzHosts(fc=self.connection) self.fritz_hosts = FritzHosts(fc=self.connection)
self.fritz_guest_wifi = FritzGuestWLAN(fc=self.connection) self.fritz_guest_wifi = FritzGuestWLAN(fc=self.connection)
self.fritz_status = FritzStatus(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( _LOGGER.debug(
"gathered device info of %s %s", "gathered device info of %s %s",
self.host, self.host,
{ {
**info, **vars(info),
"NewDeviceLog": "***omitted***", "NewDeviceLog": "***omitted***",
"NewSerialNumber": "***omitted***", "NewSerialNumber": "***omitted***",
}, },
) )
if not self._unique_id: if not self._unique_id:
self._unique_id = info["NewSerialNumber"] self._unique_id = info.serial_number
self._model = info.get("NewModelName") self._model = info.model_name
self._current_firmware = info.get("NewSoftwareVersion") self._current_firmware = info.software_version
( (
self._update_available, self._update_available,
self._latest_firmware, self._latest_firmware,
self._release_url, self._release_url,
) = self._update_device_info() ) = self._update_device_info()
if "Layer3Forwarding1" in self.connection.services:
if connection_type := self.connection.call_action( if self.fritz_status.has_wan_support:
"Layer3Forwarding1", "GetDefaultConnectionService" self.device_conn_type = (
).get("NewDefaultConnectionService"): self.fritz_status.get_default_connection_service().connection_service
# Return NewDefaultConnectionService sample: "1.WANPPPConnection.1" )
self.device_conn_type = connection_type[2:][:-2] self.device_is_router = self.fritz_status.has_wan_enabled
self.device_is_router = self.connection.call_action(
self.device_conn_type, "GetInfo"
).get("NewEnable")
async def _async_update_data(self) -> None: async def _async_update_data(self) -> None:
"""Update FritzboxTools data.""" """Update FritzboxTools data."""
@ -401,11 +398,7 @@ class FritzBoxTools(update_coordinator.DataUpdateCoordinator):
wan_access=None, wan_access=None,
) )
if ( if not self.fritz_status.device_has_mesh_support or (
"Hosts1" not in self.connection.services
or "X_AVM-DE_GetMeshListPath"
not in self.connection.services["Hosts1"].actions
) or (
self._options self._options
and self._options.get(CONF_OLD_DISCOVERY, DEFAULT_CONF_OLD_DISCOVERY) and self._options.get(CONF_OLD_DISCOVERY, DEFAULT_CONF_OLD_DISCOVERY)
): ):