MQTT value_template erro

Tags: #<Tag:0x00007f73ad2db838> #<Tag:0x00007f73ad2db770>

My MQTT switch sends the following Json.

{    "datas": [
            "name": "i",
            "types": [0,0,0,0,0,0,0,0],
            "name": "o",
            "types": [1,1,1,1,1,1,1,1],

I’m not able to get data from the “values” field
In the tests in the templante editor, using

{{my_test_json.datas [1] .types [1]}}

I get the correct value, but this is not the information I need.
But when I search for the information I need

{{my_test_json.datas [1] .values [1]}}

I have no answer.
I believe the name of the field that is generating the problem, how can I solve this problem.

Add a space between : and [

     "values": [1,0,0,0,0,0,0,0]

Instead of dot notation, use bracket notation to specify the values item.

{{ my_test_json.datas[1]['values'][1] }}

The word values is the name of a built-in function.

  • If you use dot notation, its meaning becomes ambiguous so Jinja2 defaults to interpreting it as the built-in function.
  • If you use bracket notation, it clearly indicates you want the the use key word values and not the built-in function.

thank you worked