From 7c268862c02aab8c95879d149be3254efa9051a0 Mon Sep 17 00:00:00 2001 From: Simon Berger Date: Mon, 18 Sep 2023 19:31:01 +0000 Subject: [PATCH] log invalid json payloads --- custom_components/vzug/api/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/custom_components/vzug/api/__init__.py b/custom_components/vzug/api/__init__.py index 3861856..ef4e2ca 100644 --- a/custom_components/vzug/api/__init__.py +++ b/custom_components/vzug/api/__init__.py @@ -299,7 +299,12 @@ async def once() -> Any: _LOGGER.debug("raw response: %s", content) return content - data = resp.json() + try: + data = resp.json() + except ValueError: + _LOGGER.debug("invalid json payload: %s", resp.text) + raise + _LOGGER.debug("data: %s", data) if expected_type is list and data is None: # if we want a list and the response is null, we just treat that as an empty list @@ -565,7 +570,6 @@ async def get_eco_info(self, *, default_on_error: bool = False) -> EcoInfo: ) async def get_device_info(self, *, default_on_error: bool = False) -> DeviceInfo: - # TODO: use this to replace a part of aggregations, display api version as a diagnostic sensor # 'getAPIVersion' can be used to get only the API version # 'getZHMode' gives just the zh mode return await self._command(