From 1a55c7db34c87513eb75de7eff7a1154bbc4326e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Wed, 29 Jun 2022 00:13:26 +0300 Subject: [PATCH] Take Huawei LTE XML parse errors to mean unsupported endpoint (#72781) --- homeassistant/components/huawei_lte/__init__.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/homeassistant/components/huawei_lte/__init__.py b/homeassistant/components/huawei_lte/__init__.py index 601a3b9af8d..f4e2cb209db 100644 --- a/homeassistant/components/huawei_lte/__init__.py +++ b/homeassistant/components/huawei_lte/__init__.py @@ -9,6 +9,7 @@ from datetime import timedelta import logging import time from typing import Any, NamedTuple, cast +from xml.parsers.expat import ExpatError from huawei_lte_api.Client import Client from huawei_lte_api.Connection import Connection @@ -204,14 +205,13 @@ class Router: "%s requires authorization, excluding from future updates", key ) self.subscriptions.pop(key) - except ResponseErrorException as exc: + except (ResponseErrorException, ExpatError) as exc: + # Take ResponseErrorNotSupportedException, ExpatError, and generic + # ResponseErrorException with a few select codes to mean the endpoint is + # not supported. if not isinstance( - exc, ResponseErrorNotSupportedException - ) and exc.code not in ( - # additional codes treated as unusupported - -1, - 100006, - ): + exc, (ResponseErrorNotSupportedException, ExpatError) + ) and exc.code not in (-1, 100006): raise _LOGGER.info( "%s apparently not supported by device, excluding from future updates",