From f777198de049b9d7e4fd03a158f45ef993015b26 Mon Sep 17 00:00:00 2001 From: Piotr Machowski Date: Tue, 5 May 2020 01:02:02 +0200 Subject: [PATCH] Fixed I/O warning --- custom_components/burze_dzis_net/binary_sensor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/custom_components/burze_dzis_net/binary_sensor.py b/custom_components/burze_dzis_net/binary_sensor.py index 90aa655..b176ac0 100644 --- a/custom_components/burze_dzis_net/binary_sensor.py +++ b/custom_components/burze_dzis_net/binary_sensor.py @@ -96,7 +96,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= sensor_name = '{} - '.format(name) x = convert_to_dm(longitude) y = convert_to_dm(latitude) - updater = BurzeDzisNetDataUpdater(x, y, radius, api_key, scan_interval) + updater = BurzeDzisNetDataUpdater(hass, x, y, radius, api_key, scan_interval) await updater.async_update() for warning_type in warnings: uid = '{}_{}'.format(name, warning_type) @@ -188,7 +188,8 @@ def icon(self): class BurzeDzisNetDataUpdater: - def __init__(self, x, y, radius, api_key, scan_interval): + def __init__(self, hass, x, y, radius, api_key, scan_interval): + self._hass = hass self._x = x self._y = y self._radius = radius @@ -198,6 +199,9 @@ def __init__(self, x, y, radius, api_key, scan_interval): self.async_update = Throttle(scan_interval)(self._async_update) async def _async_update(self): + await self._hass.async_add_executor_job(self._update_data) + + def _update_data(self): from zeep import Client from zeep.exceptions import Fault service = Client('https://burze.dzis.net/soap.php?WSDL').service