REST json returned parse with space

Using 3d printer klipper interface Mainsail, I am trying to get my raspberry pi’s temperature in home assistant using the provided REST api.

I can not seem to parse the returned json with a space in it.

This is what is queried:

http://192.168.0.19:7125/printer/objects/query?temperature_sensor%20raspberry_pi

This is what is returned:

{
  "result": {
    "status": {
      "temperature_sensor raspberry_pi": {
        "measured_min_temp": 35.05,
        "measured_max_temp": 55.017,
        "temperature": 37.485
      }
    },
    "eventtime": 74718.590271519
  }
}

tried this to parse, but it errors on validation:
value_template: “{{ value_json.result.status.temperature_sensor raspberry_pi.temperature }}”

also tried this to parse, but it errors on validation:
value_template: “{{ value_json.result.status.[‘temperature_sensor raspberry_pi’].temperature }}”

What am I missing?

value_template: "{{ value_json.result.status.['temperature_sensor raspberry_pi'].temperature }}"
                                            ^
                                            |
                                   Remove this period

to produce this:

value_template: "{{ value_json.result.status['temperature_sensor raspberry_pi'].temperature }}"
1 Like

Holy crap, that was it!

Thanks a 1000000 :slight_smile:

1 Like