diff --git a/plugwise/smile.py b/plugwise/smile.py index a5471fac0..45cee712d 100644 --- a/plugwise/smile.py +++ b/plugwise/smile.py @@ -224,22 +224,21 @@ async def request( resp = None url = f"{self._endpoint}{command}" - if headers is None: - headers = {"Content-type": "text/xml"} - try: with async_timeout.timeout(self._timeout): if method == "get": - resp = await self.websession.get(url, auth=self._auth) + # Work-around for Stretchv2, should not hurt the other smiles + headers = {"Accept-Encoding": "gzip"} + resp = await self.websession.get( + url, auth=self._auth, headers=headers + ) if method == "put": + headers = {"Content-type": "text/xml"} resp = await self.websession.put( url, data=data, headers=headers, auth=self._auth ) if method == "delete": resp = await self.websession.delete(url, auth=self._auth) - if resp.status == 401: - raise InvalidAuthentication - except asyncio.TimeoutError: if retry < 1: _LOGGER.error("Timed out sending command to Plugwise: %s", command) @@ -253,6 +252,9 @@ async def request( if method == "put" and resp.status == 200: return + if resp.status == 401: + raise InvalidAuthentication + result = await resp.text() if not result or "" in result: _LOGGER.error("Smile response empty or error in %s", result)