Problems to template MQTT sensor JSON as entity

Hello,
I get an array from ebusd in mqtt. I tried several ways to make an mqtt sensor in ha from number 6 with the value 12:52, but the result is alway “unknown”.
This is value in mqtt:

{
     "0": {"name": "group", "value": 72},
     "1": {"name": "value", "value": 65},
     "2": {"name": "type", "value": "04"},
     "3": {"name": "unit", "value": 42},
     "4": {"name": "max", "value": 143.9},
     "5": {"name": "min", "value": 0.0},
     "6": {"name": "", "value": "12:52"}}

mqtt sensor:

sensor:
- name: "ebusd Uhrzeit WP"
  unique_id: "ebusd_uhrzeit_wp"
  state_topic: "ebusd/heating/Waermepumpe Uhrzeit 02-072"
  value_template: "{{ value_json.6 }}"
  #unit_of_measurement: '%'
  json_attributes_topic: "ebusd/heating/Waermepumpe Uhrzeit 02-072"

This is my last attempt, but it was just as unsuccessful as many others before.
Maybe someone can give me a tip on how to convert the time (12:52) into a sensor.
Thanks for help in advance
Wolfgang

For this particular case, where the keys are numeric and a reserved word, use bracket notation instead of dot notation.

value_template: "{{ value_json['6']['value'] }}"

That was the tip !!
Thanks you very much and have a nice weekend…
Best regards
Wolfgang

1 Like

You’re welcome!

Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions.

For more information about the Solution tag, refer to guideline 21 in the FAQ.

1 Like

Hello again,
sorry, Iget the correct value, but i see many errors in log:

2024-07-14 15:40:54.050 ERROR (MainThread) [homeassistant.helpers.template] Template variable error: 'dict object' has no attribute 'type' when rendering '{{value_json["type"].value | default('')}}'``

Any hint to avoid this error msgs ?
Thanks

According to the example you posted:

{
     "0": {"name": "group", "value": 72},
     "1": {"name": "value", "value": 65},
     "2": {"name": "type", "value": "04"},
     "3": {"name": "unit", "value": 42},
     "4": {"name": "max", "value": 143.9},
     "5": {"name": "min", "value": 0.0},
     "6": {"name": "", "value": "12:52"}}

If you want the 04 value you would use:

value_template: "{{ value_json['2']['value'] }}"

sorry, but your tip work’s fine :
value_template: “{{ value_json[‘6’][‘value’] }}” and i get the value 12:52 as expected.
But exactly with this value_template is get the errors in noted above.
Maybe because there is an emtpy string “” ?
Thanks