Cleanup and simplitfy the async state update (#9390)

* Cleanup and simplitfy the async state update

* Update test_entity.py
This commit is contained in:
Pascal Vizeli 2017-09-12 10:01:03 +02:00 committed by GitHub
parent c84a099b0f
commit 90f9a6bc0a
47 changed files with 128 additions and 102 deletions

View file

@ -100,7 +100,7 @@ class MqttSensor(Entity):
payload = self._template.async_render_with_possible_json_value(
payload, self._state)
self._state = payload
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
return mqtt.async_subscribe(
self.hass, self._state_topic, message_received, self._qos)
@ -110,7 +110,7 @@ class MqttSensor(Entity):
"""Triggered when value is expired."""
self._expiration_trigger = None
self._state = STATE_UNKNOWN
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
@property
def should_poll(self):