How to develop MQTT value templates

I’m trying to work on some MQTT value templates and I’m getting annoyed having to constantly make edits to sensors.yaml, switch to HA and check configuration, jump to another screen to reload the entities, then Developer Tools > States, see what it looks like, then to log file for clues on what’s wrong.

There has to be a better way, it seems like Developer Tools > Template should work, but don’t see how to do MQTT stuff from here.

what i do is use

Subscribe to the topic

and use the Pubish to send stuff

and them I use TEMPLATE to finish it off

Maybe I need you to describe what you are doing a little clearer. I don’t see how I can adopt what you are doing. I looked at the Softblade web site for MQTT.fx and didn’t even see any screen shots to get an idea of what the product can do.

My data is already in MQTT topics. I’m in the process of trying to create a HA sensor that will fetch/parse that data as messages go by. I can’t use the Template in Dev tools until I have a working sensor.

It’s a very large and complicated JSON structure. I can see the messages in MQTT Explorer but its too large for its cut & paste, I only get a partial message out when I try it. I haven’t been able through trial and error to come up with the Jinja2 syntax that can reduce it down to something that fits in a sensor.

Yes you can. Like this:

{% set value_json = 'your json data here' %}
{{ value_json.<your_path_to_the_data_you_want> }}

Also this resource might help in finding those paths:

Paste your data on the left, drill down on the right, the path is at the top of the right hand column. Replace x with value_json.

1 Like

Use a command line utility then? mosquitto_sub should do just fine.