From bbbc330d3891c61b3add6a169641ed29d79937b2 Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Fri, 27 Oct 2017 17:55:07 +0200 Subject: [PATCH] Document JSON serialization (#3783) --- source/_components/mqtt_statestream.markdown | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/_components/mqtt_statestream.markdown b/source/_components/mqtt_statestream.markdown index cbf831206a3..1fa88b4469f 100644 --- a/source/_components/mqtt_statestream.markdown +++ b/source/_components/mqtt_statestream.markdown @@ -40,8 +40,10 @@ When any Home Assistant entity changes, this component will publish that change 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 `base_topic/domain/entity/state`. -For example, with the example configuration above, if an entity called 'light.master_bedroom_dimmer' is turned on, this component will publish `on` to `homeassistant/light/master_bedroom_dimmer/state`. +For example, with the example configuration above, if an entity called 'light.master_bedroom_dimmer' is turned on, this component will publish `on` to `homeassistant/light/master_bedroom_dimmer/state`. -If that entity also has an attribute called `brightness`, the component will also publish the value of that attribute to `homeassistant/light/master_bedroom_dimmer/brightness`. +If that entity also has an attribute called `brightness`, the component will also publish the value of that attribute to `homeassistant/light/master_bedroom_dimmer/brightness`. + +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 `value`. The last_updated and last_changed values for the entity will be published to `homeassistant/light/master_bedroom_dimmer/last_updated` and `homeassistant/light/master_bedroom_dimmer/last_changed`, respectively. The timestamps are in ISO 8601 format - for example, `2017-10-01T23:20:30.920969+00:00`.