mqtt_statestream component publishes state changes in Home Assistant to individual MQTT topics.
To enable MQTT Statestream in Home Assistant, add the following section to your
# Example configuration.yaml entry mqtt_statestream: base_topic: homeassistant publish_attributes: true publish_timestamps: true
- base_topic (Required): Base topic used to generate the actual topic used to publish.
- publish_attributes (Optional): Publish attributes of the entity as well as the state. Default is false.
- publish_timestamps (Optional): Publish the last_changed and last_updated timestamps for the entity. Default is false.
When any Home Assistant entity changes, this component will publish that change to MQTT.
The topic for each entity is different, so you can easily subscribe other systems to just the entities you are interested in.
The topic will be in the form
For example, with the example configuration above, if an entity called ‘light.master_bedroom_dimmer’ is turned on, this component will publish
If that entity also has an attribute called
brightness, the component will also publish the value of that attribute to
All states and attributes are passed through JSON serialization before publishing. Please note that this causes strings to be quoted (e.g., the string ‘on’ will be published as ‘“on”’). You can access the JSON deserialized values (as well as unquoted strings) at many places by using
value_json instead of
The last_updated and last_changed values for the entity will be published to
homeassistant/light/master_bedroom_dimmer/last_changed, respectively. The timestamps are in ISO 8601 format - for example,