Fix state saving when sharing topics for MQTT entities (#79421)
* Do not write old state sharing availability topic * Add a test * Support for all availability topics * delay async_write_ha_state till last callback * Process write req after processing callback jobs * Do not count subscription callbacks * Simplify * Stale docsting * No topic needed for delays state write * No need to clear when reloading * Move test to test_mixins.py * Only set up sensor platform for test
This commit is contained in:
parent
6f7cb158d8
commit
8aa30cce26
23 changed files with 164 additions and 56 deletions
|
@ -54,6 +54,7 @@ from .mixins import (
|
|||
warn_for_legacy_schema,
|
||||
)
|
||||
from .models import MqttCommandTemplate, MqttValueTemplate
|
||||
from .util import get_mqtt_data
|
||||
|
||||
DEFAULT_NAME = "MQTT Siren"
|
||||
DEFAULT_PAYLOAD_ON = "ON"
|
||||
|
@ -283,7 +284,7 @@ class MqttSiren(MqttEntity, SirenEntity):
|
|||
)
|
||||
return
|
||||
self._update(process_turn_on_params(self, json_payload))
|
||||
self.async_write_ha_state()
|
||||
get_mqtt_data(self.hass).state_write_requests.write_state_request(self)
|
||||
|
||||
if self._config.get(CONF_STATE_TOPIC) is None:
|
||||
# Force into optimistic mode.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue