From ab64e454134a4ce8c2cd99c6651adf0935f6ef0b Mon Sep 17 00:00:00 2001 From: Jonny Bergdahl <128166901+jonnybergdahl@users.noreply.github.com> Date: Mon, 23 Oct 2023 17:45:46 +0200 Subject: [PATCH] Fix JSON readability (#29483) Co-authored-by: Jonny Bergdahl --- source/_integrations/sensor.mqtt.markdown | 48 ++++++++++++++++++++--- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/source/_integrations/sensor.mqtt.markdown b/source/_integrations/sensor.mqtt.markdown index 66929025f4c..cc317fe6c5c 100644 --- a/source/_integrations/sensor.mqtt.markdown +++ b/source/_integrations/sensor.mqtt.markdown @@ -211,7 +211,20 @@ In this section you find some real-life examples of how to use this sensor. ### JSON attributes topic configuration -The example sensor below shows a configuration example which uses a JSON dict: `{"ClientName": , "IP": , "MAC": , "RSSI": , "HostName": , "ConnectedSSID": }` in a separate topic `home/sensor1/attributes` to add extra attributes. It also makes use of the `availability` topic. +The example sensor below shows a configuration example which uses the following separate topic and JSON structure to add extra attributes. + +Topic: `home/sensor1/attributes` + ```json + { + "ClientName": , + "IP": , + "MAC": , + "RSSI": , + "HostName": , + "ConnectedSSID": +} + ``` + It also makes use of the `availability` topic. Extra attributes will be displayed in the frontend and can also be extracted in [Templates](/docs/configuration/templating/#attributes). For example, to extract the `ClientName` attribute from the sensor below, use a template similar to: {% raw %}`{{ state_attr('sensor.bs_rssi', 'ClientName') }}`{% endraw %}. @@ -236,7 +249,22 @@ mqtt: ### JSON attributes template configuration -The example sensor below shows a configuration example which uses a JSON dict: `{"Timer1":{"Arm": , "Time":