Value_template wrong JSON


i have a gateway (Mediola V5) and i can send http requests to get status infomations etc… via
a rest sensor.

But i get this as a response, wich is not a json object:


So i tried in my value_template: {% set response = value[8:] %}
and i get:

“type”: “HMFHT”,
“adr”: “6BE31201”,
“state”: “0:A:00D2:00E6:00:00”
“type”: “EVENT”,
“adr”: “01”,
“state”: “1”

but it is a string an i need it as a json object, i tried all kind of stuff in the template editor like:
response_json… json.dumps(response)……

but i cant get it covertet into a json object.

Can some help me?


Use from_json.

{% set x = value[8:] | from_json %}

{{ x[0].type }}
{{ x[1].type }}

Oh man thank you so much, worked !!!

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.