Skip to content

Commit

Permalink
Fixes after PR #36479 (#37230)
Browse files Browse the repository at this point in the history
  • Loading branch information
definitio authored and balloob committed Jun 30, 2020
1 parent dbdd4f0 commit d9a2cc9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion homeassistant/components/mqtt/__init__.py
Expand Up @@ -994,6 +994,9 @@ async def async_added_to_hass(self) -> None:
await self._availability_subscribe_topics()
async_dispatcher_connect(self.hass, MQTT_CONNECTED, self.async_mqtt_connect)
async_dispatcher_connect(self.hass, MQTT_DISCONNECTED, self.async_mqtt_connect)
self.async_on_remove(
async_dispatcher_connect(self.hass, MQTT_CONNECTED, self.async_mqtt_connect)
)

async def availability_discovery_update(self, config: dict):
"""Handle updated discovery message."""
Expand Down Expand Up @@ -1029,7 +1032,8 @@ def availability_message_received(msg: Message) -> None:
@callback
def async_mqtt_connect(self):
"""Update state on connection/disconnection to MQTT broker."""
self.async_write_ha_state()
if self.hass.is_running:
self.async_write_ha_state()

async def async_will_remove_from_hass(self):
"""Unsubscribe when removed."""
Expand Down

0 comments on commit d9a2cc9

Please sign in to comment.