MQTT Payload delivers to many attributes

Hey there,

I am a first time MQTT User and struggle to get a simple counter for my gas consumption.
MQTT works fine, I get a respones, but it is a string with multiple values:

{"chipid":"123456","ggid":"gasGuard00123123","date":"2023-04-04 21:18:50","med":0,"counter":2019.568,"cm":0.01,"ts":1.553,"ts_p":0,"ms":1.553,"ms_p":0,"js":1.553,"js_p":0} m

The value I want to drop into the “energy dashboard” for gas consumtion is “counter” → “2019.568”.

In the configuration I tried the following, but it doesn’t work (will not show any attribute):

mqtt:
  sensor:
   - state_topic: Gas/Counter
     name: "Gas"
     unit_of_measurement: "m³"
     value_template: >
      {% set items = value.split[5] %}
      {% set items = items | from_json %}
      {{ items.counter }}

Do you have any idea, how I can split / extract the specific value?
Thank you :slight_smile:

Try something like this:

value_template: "{{ value_json['counter'] }}"
1 Like

Thanks Mate!!

How can I get you a beer? :slight_smile: