RESTful - Invalid HTTP version

I try to read a JSON file from the integrated Webserver of a B&R PLC.
However I get the following error message in the logger:

Logger: homeassistant.components.rest.data
Quelle: components/rest/data.py:181
Integration: RESTful (Dokumentation, Probleme)
Erstmals aufgetreten: 14:01:29 (2 Vorkommnisse)
Zuletzt protokolliert: 14:01:40

Error fetching data: http://192.168.0.12/indexjson.asp failed with 400, message="Invalid HTTP version:\n\n b'HTTP/3.12.15 Python/3.13 200 OK '\n ^", url='http://192.168.0.12/indexjson.asp'

When I read the file with curl, I get this:

$curl -v http://192.168.0.12/indexjson.asp
*   Trying 192.168.0.12:80...
* Established connection to 192.168.0.12 (192.168.0.12 port 80) from 192.168.1.20 port 43402 
* using HTTP/1.x
> GET /indexjson.asp HTTP/1.1
> Host: 192.168.0.12
> User-Agent: curl/8.16.0
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK 
< Date: Wed, 29 Oct 2025 14:04:01 GMT
< Expires: Wed, 29 Oct 2025 14:04:01 GMT
< Server: B&R Web Server  Ver. {2-231112-19}
< Content-Type: text/html; charset=utf-8
< Content-Length: 753
< Connection: close
< 
{
    "tempAussen": 153,
    "tempPufferOben": 565,
    "tempPufferVorlaufHk": 452,
    "tempPufferUnten": 443,
    "betriebsArt": 1,
    "stateHk1": 1,
    "stateHk2": 1,
    "modeHk1": "hkAutomatik",
    "modeHk2": "hkAutomatik",
    "Hk1TempIst": 350,
    "Hk2TempIst": 258,
    "Hk1TempSoll": 347,
    "Hk2TempSoll": 258,
    "anfBrenner": 0,
    "Hk1TempVAus": 240,
    "Hk2TempVAus": 232,
    "Hk1Pumpe": 1,
    "Hk2Pumpe": 1,
    "Hk1MischerZu": 0,
    "Hk1MischerAuf": 0,
    "Hk2MischerZu": 0,
    "Hk2MischerAuf": 0,
    "anfBrennerManuell": 0,
    "reglerHk": {
        "E": 4,
        "P": 320.0,
        "I": 0.0,
        "D": 200.0
    },
    "reglerFbh": {
        "E": -1,
        "P": -100.0,
        "I": 0.0,
        "D": 0.0
    }
}
* shutting down connection #0

What’s the issue?

I forgot to mention that the PLC is about 10 years old. So there is definitely no web server with Python 3.13. Don’t know where this version comes from…

I’m not sure why you are getting that error, but you could use a command_line sensor instead:

sensor:
  - platform: command_line
    name: custom_json_sensor
    command: "curl -s http://192.168.0.12/indexjson.asp"
    value_template: "{{ value_json }}"
    scan_interval: 60

Thanks, I’ll try that

You also forgot to share your sensor config.

Sorry…
in configuration.yaml:

rest: !include rest_sensors_heizung.yaml

in rest_sensors_heizung.yaml:

- resource: http://192.168.0.12/indexjson.asp
  scan_interval: 60  # alle 60 Sekunden abrufen
  sensor:
    - name: "Außentemperatur"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.tempAussen / 10 }}"
    - name: "Puffer oben"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.tempPufferOben / 10 }}"
    - name: "Puffer Vorlauf HK"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.tempPufferVorlaufHk / 10 }}"
    - name: "Puffer unten"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.tempPufferUnten / 10 }}"
    - name: "Heizkreis 1 Soll"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.Hk1TempSoll / 10 }}"
    - name: "Heizkreis 1 Ist"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.Hk1TempIst / 10 }}"
    - name: "Heizkreis 2 Soll"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.Hk2TempSoll / 10 }}"
    - name: "Heizkreis 2 Ist"
      unit_of_measurement: "°C"
      value_template: "{{ value_json.Hk2TempIst / 10 }}"
    - name: "Betriebsart"
      value_template: "{{ value_json.betriebsArt }}"
    - name: "Regler HK P"
      value_template: "{{ value_json.reglerHk.P }}"
    - name: "Regler FBH E"
      value_template: "{{ value_json.reglerFbh.E }}"
  binary_sensor:
    - name: "Brenner aktiv"
      value_template: "{{ value_json.anfBrenner == 1 }}"
    - name: "HK1 Pumpe"
      value_template: "{{ value_json.Hk1Pumpe == 1 }}"
    - name: "HK2 Pumpe"
      value_template: "{{ value_json.Hk2Pumpe == 1 }}"
    - name: "HK1 Mischer auf"
      value_template: "{{ value_json.Hk1MischerAuf == 1 }}"
    - name: "HK1 Mischer zu"
      value_template: "{{ value_json.Hk1MischerZu == 1 }}"
    - name: "HK2 Mischer auf"
      value_template: "{{ value_json.Hk2MischerAuf == 1 }}"
    - name: "HK2 Mischer zu"
      value_template: "{{ value_json.Hk2MischerZu == 1 }}"

Do not get it to work… :frowning:
Could it be a problem that the web server delivers text/html instead of application/json?

What changed since it last worked? Have you done a clean shutdown and restart of all the equipment? Twice?

Try using the command_line sensor and jq:

sensor:
  - platform: command_line
    name: "heating_raw_json"
    command: "curl -s http://192.168.0.12/indexjson.asp | jq -c '.'"
    value_template: "{{ value_json.tempAussen / 10 }}"
    json_attributes:
      - tempAussen
      - tempPufferOben
      # etc.