mirror of
https://github.com/home-assistant/home-assistant.io.git
synced 2025-07-23 09:17:06 +00:00
Correct mqtt sensor info on state updates and add waring on use extra state attributes (#33750)
This commit is contained in:
parent
fb2cd5c94e
commit
9fa88bc2de
@ -350,7 +350,11 @@ mqtt:
|
||||
|
||||
{% endraw %}
|
||||
|
||||
The state and the attributes of the sensor by design do not update in a synchronous manner if they share the same MQTT topic. Temporal mismatches between the state and the attribute data may occur if both the state and the attributes are changed simultaneously by the same MQTT message. An automation that triggers on any state change of the sensor will also trigger both on the change of the state or a change of the attributes. Such automations will be triggered twice if both the state and the attributes change. Please use a [MQTT trigger](/docs/automation/trigger/#mqtt-trigger) and process the JSON in the automation directly via the {% raw %}`{{ trigger.payload_json }}`{% endraw %} [trigger data](/docs/automation/templating/#mqtt) for automations that must synchronously handle multiple JSON values within the same MQTT message.
|
||||
{% warning %}
|
||||
If `json_attributes_topic` and `state_topic` share the same topic, a state update will happen only once, unless the state update did not change the state or `force_update` was set to `true`.
|
||||
|
||||
Setting up MQTT sensor's with extra state attributes that contain values that change at every update, like timestamps, or enabling the `force_update` option, is discouraged, as this will trigger state writes for every update. This can have a serious impact on the total system performance. A better option is creating separate sensors instead.
|
||||
{% endwarning %}
|
||||
|
||||
### Usage of `entity_id` in the template
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user