mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 13:47:35 +00:00
parent
cc7bed5dab
commit
12510b0c97
@ -994,6 +994,9 @@ class MqttAvailability(Entity):
|
|||||||
await self._availability_subscribe_topics()
|
await self._availability_subscribe_topics()
|
||||||
async_dispatcher_connect(self.hass, MQTT_CONNECTED, self.async_mqtt_connect)
|
async_dispatcher_connect(self.hass, MQTT_CONNECTED, self.async_mqtt_connect)
|
||||||
async_dispatcher_connect(self.hass, MQTT_DISCONNECTED, 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):
|
async def availability_discovery_update(self, config: dict):
|
||||||
"""Handle updated discovery message."""
|
"""Handle updated discovery message."""
|
||||||
@ -1029,7 +1032,8 @@ class MqttAvailability(Entity):
|
|||||||
@callback
|
@callback
|
||||||
def async_mqtt_connect(self):
|
def async_mqtt_connect(self):
|
||||||
"""Update state on connection/disconnection to MQTT broker."""
|
"""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):
|
async def async_will_remove_from_hass(self):
|
||||||
"""Unsubscribe when removed."""
|
"""Unsubscribe when removed."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user