JSON String template issue

Hi,
Having issues getting the value I need out of this MQTT string from a generator controller
test_json outputs value 1
value_json outputs error: expected token ‘end of print statement’, got ‘E47E69B734F’

{% set test_json = {"one":{"two":{"three":1}}} %}
{{ test_json.one.two.three }}

{% set value_json = {"1922E47E69B734F":{"P019":{"R040":1}}} %}
{{ value_json.1922E47E69B734F.P019.R040 }}

Seems to be an issue with a combo of letters and numbers?
I am unable to change the format of the json from the device
Any help would be greatly appreciated

Because the name of one of the dictionary’s keys starts with a number, use bracket notation instead of dot notation.

{{ value_json['1922E47E69B734F']['P019']['R040'] }}

FWIW, the same advice applies if have an entity_id whose object_id starts with a number (such as light.12xyz).

Thanks heaps!

1 Like