mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Fix Dark Sky async I/O (#4299)
This commit is contained in:
parent
67b599475e
commit
9561fed650
@ -113,6 +113,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
longitude=hass.config.longitude,
|
longitude=hass.config.longitude,
|
||||||
units=units,
|
units=units,
|
||||||
interval=config.get(CONF_UPDATE_INTERVAL))
|
interval=config.get(CONF_UPDATE_INTERVAL))
|
||||||
|
forecast_data.update()
|
||||||
forecast_data.update_currently()
|
forecast_data.update_currently()
|
||||||
except ValueError as error:
|
except ValueError as error:
|
||||||
_LOGGER.error(error)
|
_LOGGER.error(error)
|
||||||
@ -124,7 +125,7 @@ def setup_platform(hass, config, add_devices, discovery_info=None):
|
|||||||
for variable in config[CONF_MONITORED_CONDITIONS]:
|
for variable in config[CONF_MONITORED_CONDITIONS]:
|
||||||
sensors.append(DarkSkySensor(forecast_data, variable, name))
|
sensors.append(DarkSkySensor(forecast_data, variable, name))
|
||||||
|
|
||||||
add_devices(sensors)
|
add_devices(sensors, True)
|
||||||
|
|
||||||
|
|
||||||
class DarkSkySensor(Entity):
|
class DarkSkySensor(Entity):
|
||||||
@ -139,8 +140,6 @@ class DarkSkySensor(Entity):
|
|||||||
self._state = None
|
self._state = None
|
||||||
self._unit_of_measurement = None
|
self._unit_of_measurement = None
|
||||||
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
"""Return the name of the sensor."""
|
"""Return the name of the sensor."""
|
||||||
@ -277,8 +276,6 @@ class DarkSkyData(object):
|
|||||||
self.update_hourly = Throttle(interval)(self._update_hourly)
|
self.update_hourly = Throttle(interval)(self._update_hourly)
|
||||||
self.update_daily = Throttle(interval)(self._update_daily)
|
self.update_daily = Throttle(interval)(self._update_daily)
|
||||||
|
|
||||||
self.update()
|
|
||||||
|
|
||||||
def _update(self):
|
def _update(self):
|
||||||
"""Get the latest data from Dark Sky."""
|
"""Get the latest data from Dark Sky."""
|
||||||
import forecastio
|
import forecastio
|
||||||
|
Loading…
x
Reference in New Issue
Block a user