Sensor platform: mqtt Errors after Update

Hi,
I updated Home Assistant to the newest version. Now I get errors:

Invalid config for [sensor.mqtt]: invalid template (TemplateSyntaxError: expected token ‘end of print statement’, got ‘integer’) for dictionary value @ data[‘value_template’]. Got ‘{{ value_json.AM2301-04.Temperature }}’. (See ?, line ?).

How to fix it?!

here is the configuration.yaml entry:


sensor:
  - platform: mqtt
    state_topic: "sensor/full/espdht22/SENSOR"
    name: "Temperatur"
    qos: 0
    unit_of_measurement: "°C"
    value_template: '{{ value_json.AM2301-04.Temperature }}'
  - platform: mqtt
    state_topic: "sensor/full/espdht22/SENSOR"
    name: "Luftfeuchtigkeit"
    qos: 0
    unit_of_measurement: "%"
    value_template: '{{ value_json.AM2301-04.Humidity }}'

Try

{{ value_json["AM2301-04"]["Temperature"] }}

I suspect the “-04” is parsed as an integer operation.

doesn’t work :-/
Invalid config for [sensor.mqtt]: invalid template (TemplateSyntaxError: expected name or number) for dictionary value @ data[‘value_template’]. Got ‘{{ value_json.[“AM2301-04”][“Temperature”] }}’. (See ?, line ?).

I’v got it :slight_smile:
value_template: “{{ value_json[‘AM2301-04’][‘Temperature’] }}”

thanks!