Fix race when handling updated MQTT discovery data (#65415)
This commit is contained in:
parent
4e7cf19b5f
commit
f3a89de71f
25 changed files with 246 additions and 108 deletions
|
@ -164,7 +164,7 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
|
|||
entity=self,
|
||||
).async_render_with_possible_json_value
|
||||
|
||||
async def _subscribe_topics(self):
|
||||
def _prepare_subscribe_topics(self):
|
||||
"""(Re)Subscribe to topics."""
|
||||
|
||||
@callback
|
||||
|
@ -241,7 +241,7 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
|
|||
|
||||
self.async_write_ha_state()
|
||||
|
||||
self._sub_state = await subscription.async_subscribe_topics(
|
||||
self._sub_state = subscription.async_prepare_subscribe_topics(
|
||||
self.hass,
|
||||
self._sub_state,
|
||||
{
|
||||
|
@ -254,6 +254,10 @@ class MqttBinarySensor(MqttEntity, BinarySensorEntity, RestoreEntity):
|
|||
},
|
||||
)
|
||||
|
||||
async def _subscribe_topics(self):
|
||||
"""(Re)Subscribe to topics."""
|
||||
await subscription.async_subscribe_topics(self.hass, self._sub_state)
|
||||
|
||||
@callback
|
||||
def _value_is_expired(self, *_):
|
||||
"""Triggered when value is expired."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue