Skip to content

Commit

Permalink
Fixed Client Connection Error
Browse files Browse the repository at this point in the history
  • Loading branch information
jellespijker committed Jan 12, 2021
1 parent 3b3ea7d commit ca72371
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions custom_components/ultimaker/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,17 @@ async def async_update(self):
self._data = await self.fetch_data(self._url_printer)
self._data |= await self.fetch_data(self._url_print_job)
self._data |= await self.fetch_data(self._url_system)
except aiohttp.ClientConnectorError:
except aiohttp.ClientError:
self._data = {'status': 'not connected'}
self._data['sampleTime'] = datetime.now()

async def fetch_data(self, url):
try:
with async_timeout.timeout(5):
response = await self._session.get(url)
except aiohttp.ClientConnectorError as err:
except aiohttp.ClientError as err:
_LOGGER.warning(f"Printer {self._host} is offline")
raise err
except aiohttp.ClientError as err:
_LOGGER.error(f"Cannot poll Ultimaker printer using url: {url} error {err}")
except asyncio.TimeoutError:
_LOGGER.error(f" Timeout error occurred while polling ultimaker printer using url {url}")
except Exception as err:
Expand Down

0 comments on commit ca72371

Please sign in to comment.