Skip to content

Commit

Permalink
Fixed I/O warning
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrMachowski committed May 4, 2020
1 parent 532417a commit f777198
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions custom_components/burze_dzis_net/binary_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit f777198

Please sign in to comment.