How to template from MQTT?

Hi there,

I have some MQTT data that comes in from a single topic: “Sofar2mqtt/state” and looks like this if I use MQTT fx to subscribe to the topic from my PC:


How do I set up sensors to take the relevant data? I’m thinking along some kind of value template but I dont know how to go about that.

Thanx for any help


    - name: "Battery Current"
      state_topic: "Sofar2mqtt/state"
      unit_of_measurement: "Amps"
      icon: "mdi:current-dc"
      value_template: "{{ value_json.battery_current }}"
1 Like

Thanx @tom_l

How do you make it look so easy! I read the ‘MQTT Sensor’ instruction but even with the solution I couldn’t see how to get there