Help with parson MQTT

Hi all,

Need some help in parsing MQTT payload as shown below:

[{“i”:0.815095,“p”:52.37265,“f”:0.53942},{“i”:0.882872,“p”:-0.395224,“f”:-0.629938},{“i”:1.601247,“p”:0.843253,“f”:0.674454},{“i”:0.119281,“p”:-1.426369,“f”:-0.10039},{“i”:0.118915,“p”:-0.022139,“f”:-0.261984},{“i”:0.128542,“p”:0.034876,“f”:0.347481}]

I simply cannot get my head about how to parse, especially since the variable names are the same in the payload. Some assistance please on to crease a value_template to parse this!
thanks

For which value(s)?

Also please format your data correctly for the forum so it does not replace the quotes with invalid “fancy” ones.

There’s a handy tool here for finding paths to json data: https://jsonpathfinder.com/

I need to parse all the data.

You did not format your data, so I had to do it for you. You’re not making this easy.

Using this data (see how the quotes are different?):

[{"i":0.815095,"p":52.37265,"f":0.53942},{"i":0.882872,"p":-0.395224,"f":-0.629938},{"i":1.601247,"p":0.843253,"f":0.674454},{"i":0.119281,"p":-1.426369,"f":-0.10039},{"i":0.118915,"p":-0.022139,"f":-0.261984},{"i":0.128542,"p":0.034876,"f":0.347481}]

And the website linked above gives you all the information you need. For example to create a sensor for the fourth p value:


You would use this value template in your sensor:

value_template: "{{ value_json[3].p }}"

You can make 18 separate sensors or you can put some of the values in attributes.

Thank you! Yes that works. And apologies for the formatting. I need to learn how that’s done for the next time.

See: https://community.home-assistant.io/t/how-to-help-us-help-you-or-how-to-ask-a-good-question/114371#oneone-format-it-properly-16