Cleanup some async stuff (#6127)
* Cleanup some async stuff * change to schedule_update_ha_state() * fix media player * fix zigbee
This commit is contained in:
parent
14cf5b884b
commit
1d7ab0fa95
8 changed files with 9 additions and 8 deletions
|
@ -67,4 +67,4 @@ class EnvisalinkBinarySensor(EnvisalinkDevice, BinarySensorDevice):
|
||||||
def _update_callback(self, zone):
|
def _update_callback(self, zone):
|
||||||
"""Update the zone's state, if needed."""
|
"""Update the zone's state, if needed."""
|
||||||
if zone is None or int(zone) == self._zone_number:
|
if zone is None or int(zone) == self._zone_number:
|
||||||
self.hass.async_add_job(self.update_ha_state)
|
self.hass.schedule_update_ha_state()
|
||||||
|
|
|
@ -123,7 +123,7 @@ class GenericCamera(Camera):
|
||||||
return self._last_image
|
return self._last_image
|
||||||
finally:
|
finally:
|
||||||
if response is not None:
|
if response is not None:
|
||||||
self.hass.async_add_job(response.release())
|
yield from response.release()
|
||||||
|
|
||||||
self._last_url = url
|
self._last_url = url
|
||||||
return self._last_image
|
return self._last_image
|
||||||
|
|
|
@ -151,7 +151,7 @@ class UniversalMediaPlayer(MediaPlayerDevice):
|
||||||
@callback
|
@callback
|
||||||
def async_on_dependency_update(*_):
|
def async_on_dependency_update(*_):
|
||||||
"""Update ha state when dependencies update."""
|
"""Update ha state when dependencies update."""
|
||||||
self.hass.add_job(self.async_update_ha_state(True))
|
self.hass.async_add_job(self.async_update_ha_state(True))
|
||||||
|
|
||||||
depend = copy(children)
|
depend = copy(children)
|
||||||
for entity in attributes.values():
|
for entity in attributes.values():
|
||||||
|
|
|
@ -420,12 +420,13 @@ class MQTT(object):
|
||||||
will_message.get(ATTR_QOS),
|
will_message.get(ATTR_QOS),
|
||||||
will_message.get(ATTR_RETAIN))
|
will_message.get(ATTR_RETAIN))
|
||||||
|
|
||||||
|
@asyncio.coroutine
|
||||||
def async_publish(self, topic, payload, qos, retain):
|
def async_publish(self, topic, payload, qos, retain):
|
||||||
"""Publish a MQTT message.
|
"""Publish a MQTT message.
|
||||||
|
|
||||||
This method must be run in the event loop and returns a coroutine.
|
This method must be run in the event loop and returns a coroutine.
|
||||||
"""
|
"""
|
||||||
return self.hass.loop.run_in_executor(
|
yield from self.hass.loop.run_in_executor(
|
||||||
None, self._mqttc.publish, topic, payload, qos, retain)
|
None, self._mqttc.publish, topic, payload, qos, retain)
|
||||||
|
|
||||||
@asyncio.coroutine
|
@asyncio.coroutine
|
||||||
|
|
|
@ -68,4 +68,4 @@ class EnvisalinkSensor(EnvisalinkDevice):
|
||||||
def _update_callback(self, partition):
|
def _update_callback(self, partition):
|
||||||
"""Update the partition state in HA, if needed."""
|
"""Update the partition state in HA, if needed."""
|
||||||
if partition is None or int(partition) == self._partition_number:
|
if partition is None or int(partition) == self._partition_number:
|
||||||
self.hass.async_add_job(self.update_ha_state)
|
self.hass.schedule_update_ha_state()
|
||||||
|
|
|
@ -179,7 +179,7 @@ class YrData(object):
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
if resp is not None:
|
if resp is not None:
|
||||||
self.hass.async_add_job(resp.release())
|
yield from resp.release()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import xmltodict
|
import xmltodict
|
||||||
|
|
|
@ -55,7 +55,7 @@ class ZigBeeTemperatureSensor(Entity):
|
||||||
self._config = config
|
self._config = config
|
||||||
self._temp = None
|
self._temp = None
|
||||||
# Get initial state
|
# Get initial state
|
||||||
hass.add_job(self.async_update_ha_state, True)
|
self.schedule_update_ha_state(True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
|
@ -307,7 +307,7 @@ class ZigBeeDigitalIn(Entity):
|
||||||
subscribe(hass, handle_frame)
|
subscribe(hass, handle_frame)
|
||||||
|
|
||||||
# Get initial state
|
# Get initial state
|
||||||
hass.add_job(self.async_update_ha_state, True)
|
self.schedule_update_ha_state(True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def name(self):
|
def name(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue