Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ def _message_callback(self, message):
if message.alarm_sounding or message.fire_alarm:
if self._state != STATE_ALARM_TRIGGERED:
self._state = STATE_ALARM_TRIGGERED
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
elif message.armed_away:
if self._state != STATE_ALARM_ARMED_AWAY:
self._state = STATE_ALARM_ARMED_AWAY
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
elif message.armed_home:
if self._state != STATE_ALARM_ARMED_HOME:
self._state = STATE_ALARM_ARMED_HOME
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
else:
if self._state != STATE_ALARM_DISARMED:
self._state = STATE_ALARM_DISARMED
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@property
def name(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def async_added_to_hass(self):
def _update_callback(self, partition):
"""Update Home Assistant state, if needed."""
if partition is None or int(partition) == self._partition_number:
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@property
def code_format(self):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/alarm_control_panel/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def message_received(topic, payload, qos):
_LOGGER.warning("Received unexpected payload: %s", payload)
return
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)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/android_ip_webcam.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def async_ipcam_update(host):
"""Update callback."""
if self._host != host:
return
self.hass.async_add_job(self.async_update_ha_state(True))
self.async_schedule_update_ha_state(True)

async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_DATA, async_ipcam_update)
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/binary_sensor/alarmdecoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ def _fault_callback(self, zone):
"""Update the zone's state, if needed."""
if zone is None or int(zone) == self._zone_number:
self._state = 1
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@callback
def _restore_callback(self, zone):
"""Update the zone's state, if needed."""
if zone is None or int(zone) == self._zone_number:
self._state = 0
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
2 changes: 1 addition & 1 deletion homeassistant/components/binary_sensor/envisalink.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ def device_class(self):
def _update_callback(self, zone):
"""Update the zone's state, if needed."""
if zone is None or int(zone) == self._zone_number:
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
2 changes: 1 addition & 1 deletion homeassistant/components/binary_sensor/ffmpeg_motion.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, config):
def _async_callback(self, state):
"""HA-FFmpeg callback for noise detection."""
self._state = state
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@property
def is_on(self):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/binary_sensor/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def message_received(topic, payload, qos):
elif payload == self._payload_off:
self._state = False

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)
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/binary_sensor/mystrom.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,4 @@ def is_on(self):
def async_on_update(self, value):
"""Receive an update."""
self._state = value
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
2 changes: 1 addition & 1 deletion homeassistant/components/binary_sensor/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def async_check_state(self):
def set_state():
"""Set state of template binary sensor."""
self._state = state
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

# state without delay
if (state and not self._delay_on) or \
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/climate/generic_thermostat.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def _async_switch_changed(self, entity_id, old_state, new_state):
"""Handle heater switch state changes."""
if new_state is None:
return
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@callback
def _async_keep_alive(self, time):
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/cover/knx.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def stop_auto_updater(self):
def auto_updater_hook(self, now):
"""Callback for autoupdater."""
# pylint: disable=unused-argument
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
if self.device.position_reached():
self.stop_auto_updater()

Expand Down
12 changes: 6 additions & 6 deletions homeassistant/components/cover/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def tilt_updated(topic, payload, qos):

level = self.find_percentage_in_range(float(payload))
self._tilt_value = level
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@callback
def message_received(topic, payload, qos):
Expand All @@ -203,7 +203,7 @@ def message_received(topic, payload, qos):
payload)
return

self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._state_topic is None:
# Force into optimistic mode.
Expand Down Expand Up @@ -275,7 +275,7 @@ def async_open_cover(self, **kwargs):
if self._optimistic:
# Optimistically assume that cover has changed state.
self._state = False
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_close_cover(self, **kwargs):
Expand All @@ -289,7 +289,7 @@ def async_close_cover(self, **kwargs):
if self._optimistic:
# Optimistically assume that cover has changed state.
self._state = True
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_stop_cover(self, **kwargs):
Expand All @@ -309,7 +309,7 @@ def async_open_cover_tilt(self, **kwargs):
self._retain)
if self._tilt_optimistic:
self._tilt_value = self._tilt_open_position
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_close_cover_tilt(self, **kwargs):
Expand All @@ -319,7 +319,7 @@ def async_close_cover_tilt(self, **kwargs):
self._retain)
if self._tilt_optimistic:
self._tilt_value = self._tilt_closed_position
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_set_cover_tilt_position(self, **kwargs):
Expand Down
16 changes: 8 additions & 8 deletions homeassistant/components/cover/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ def async_added_to_hass(self):
@callback
def template_cover_state_listener(entity, old_state, new_state):
"""Handle target device state changes."""
self.hass.async_add_job(self.async_update_ha_state(True))
self.async_schedule_update_ha_state(True)

@callback
def template_cover_startup(event):
"""Update template on startup."""
async_track_state_change(
self.hass, self._entities, template_cover_state_listener)

self.hass.async_add_job(self.async_update_ha_state(True))
self.async_schedule_update_ha_state(True)

self.hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_START, template_cover_startup)
Expand Down Expand Up @@ -271,7 +271,7 @@ def async_open_cover(self, **kwargs):
yield from self._position_script.async_run({"position": 100})
if self._optimistic:
self._position = 100
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_close_cover(self, **kwargs):
Expand All @@ -282,7 +282,7 @@ def async_close_cover(self, **kwargs):
yield from self._position_script.async_run({"position": 0})
if self._optimistic:
self._position = 0
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_stop_cover(self, **kwargs):
Expand All @@ -297,15 +297,15 @@ def async_set_cover_position(self, **kwargs):
yield from self._position_script.async_run(
{"position": self._position})
if self._optimistic:
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_open_cover_tilt(self, **kwargs):
"""Tilt the cover open."""
self._tilt_value = 100
yield from self._tilt_script.async_run({"tilt": self._tilt_value})
if self._tilt_optimistic:
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_close_cover_tilt(self, **kwargs):
Expand All @@ -314,15 +314,15 @@ def async_close_cover_tilt(self, **kwargs):
yield from self._tilt_script.async_run(
{"tilt": self._tilt_value})
if self._tilt_optimistic:
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_set_cover_tilt_position(self, **kwargs):
"""Move the cover tilt to a specific position."""
self._tilt_value = kwargs[ATTR_TILT_POSITION]
yield from self._tilt_script.async_run({"tilt": self._tilt_value})
if self._tilt_optimistic:
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_update(self):
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/eight_sleep.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ def async_added_to_hass(self):
@callback
def async_eight_user_update():
"""Update callback."""
self.hass.async_add_job(self.async_update_ha_state(True))
self.async_schedule_update_ha_state(True)

async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_USER, async_eight_user_update)
Expand All @@ -233,7 +233,7 @@ def async_added_to_hass(self):
@callback
def async_eight_heat_update():
"""Update callback."""
self.hass.async_add_job(self.async_update_ha_state(True))
self.async_schedule_update_ha_state(True)

async_dispatcher_connect(
self.hass, SIGNAL_UPDATE_HEAT, async_eight_heat_update)
Expand Down
10 changes: 5 additions & 5 deletions homeassistant/components/fan/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def state_received(topic, payload, qos):
self._state = True
elif payload == self._payload[STATE_OFF]:
self._state = False
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._topic[CONF_STATE_TOPIC] is not None:
yield from mqtt.async_subscribe(
Expand All @@ -177,7 +177,7 @@ def speed_received(topic, payload, qos):
self._speed = SPEED_MEDIUM
elif payload == self._payload[SPEED_HIGH]:
self._speed = SPEED_HIGH
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._topic[CONF_SPEED_STATE_TOPIC] is not None:
yield from mqtt.async_subscribe(
Expand All @@ -193,7 +193,7 @@ def oscillation_received(topic, payload, qos):
self._oscillation = True
elif payload == self._payload[OSCILLATE_OFF_PAYLOAD]:
self._oscillation = False
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._topic[CONF_OSCILLATION_STATE_TOPIC] is not None:
yield from mqtt.async_subscribe(
Expand Down Expand Up @@ -287,7 +287,7 @@ def async_set_speed(self, speed: str) -> None:

if self._optimistic_speed:
self._speed = speed
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_oscillate(self, oscillating: bool) -> None:
Expand All @@ -309,4 +309,4 @@ def async_oscillate(self, oscillating: bool) -> None:

if self._optimistic_oscillation:
self._oscillation = oscillating
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
2 changes: 1 addition & 1 deletion homeassistant/components/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def async_shutdown_handle(event):
def async_start_handle(event):
"""Start FFmpeg process."""
yield from self._async_start_ffmpeg(None)
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

self.hass.bus.async_listen_once(
EVENT_HOMEASSISTANT_START, async_start_handle)
18 changes: 9 additions & 9 deletions homeassistant/components/light/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def state_received(topic, payload, qos):
self._state = True
elif payload == self._payload['off']:
self._state = False
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._topic[CONF_STATE_TOPIC] is not None:
yield from mqtt.async_subscribe(
Expand All @@ -233,7 +233,7 @@ def brightness_received(topic, payload, qos):
device_value = float(templates[CONF_BRIGHTNESS](payload))
percent_bright = device_value / self._brightness_scale
self._brightness = int(percent_bright * 255)
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._topic[CONF_BRIGHTNESS_STATE_TOPIC] is not None:
yield from mqtt.async_subscribe(
Expand All @@ -250,7 +250,7 @@ def rgb_received(topic, payload, qos):
"""Handle new MQTT messages for RGB."""
self._rgb = [int(val) for val in
templates[CONF_RGB](payload).split(',')]
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._topic[CONF_RGB_STATE_TOPIC] is not None:
yield from mqtt.async_subscribe(
Expand All @@ -266,7 +266,7 @@ def rgb_received(topic, payload, qos):
def color_temp_received(topic, payload, qos):
"""Handle new MQTT messages for color temperature."""
self._color_temp = int(templates[CONF_COLOR_TEMP](payload))
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._topic[CONF_COLOR_TEMP_STATE_TOPIC] is not None:
yield from mqtt.async_subscribe(
Expand All @@ -282,7 +282,7 @@ def color_temp_received(topic, payload, qos):
def effect_received(topic, payload, qos):
"""Handle new MQTT messages for effect."""
self._effect = templates[CONF_EFFECT](payload)
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._topic[CONF_EFFECT_STATE_TOPIC] is not None:
yield from mqtt.async_subscribe(
Expand All @@ -300,7 +300,7 @@ def white_value_received(topic, payload, qos):
device_value = float(templates[CONF_WHITE_VALUE](payload))
percent_white = device_value / self._white_value_scale
self._white_value = int(percent_white * 255)
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._topic[CONF_WHITE_VALUE_STATE_TOPIC] is not None:
yield from mqtt.async_subscribe(
Expand All @@ -317,7 +317,7 @@ def xy_received(topic, payload, qos):
"""Handle new MQTT messages for color."""
self._xy = [float(val) for val in
templates[CONF_XY](payload).split(',')]
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

if self._topic[CONF_XY_STATE_TOPIC] is not None:
yield from mqtt.async_subscribe(
Expand Down Expand Up @@ -483,7 +483,7 @@ def async_turn_on(self, **kwargs):
should_update = True

if should_update:
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()

@asyncio.coroutine
def async_turn_off(self, **kwargs):
Expand All @@ -498,4 +498,4 @@ def async_turn_off(self, **kwargs):
if self._optimistic:
# Optimistically assume that switch has changed state.
self._state = False
self.hass.async_add_job(self.async_update_ha_state())
self.async_schedule_update_ha_state()
Loading