RESTfull can't parse JSON all of a suddon

Just updated HA Core to core-2021.10.5 and all of a sudden RESTfull is unable to parse the website data I am passing it. If I plug the JSON directly into a JSON validator it says that there is nothing wrong with it.

{
   "background":{
      "fill":"#202124",
      "text":"White"
   },
   "event":{
      "unixTime":1634530500,
      "date":"18-10-21",
      "day":"Mon",
      "time":"14:45",
      "dayFinish":"Mon",
      "timeFinish":"21:30",
      "text":"ADL - BNE - ADL",
      "address":"Long Term Car Park, Adelaide Airport SA 5950, Australia",
      "distance":"24.9 km",
      "travelTime":"28 mins",
      "travelTimeSecs":1680
   },
   "remaining":{
      "duration":"00:000",
      "editable":false,
      "starts_at":"2021-10-18T21:30:00+10:30",
      "finishes_at":"2021-10-18T13:50:00+10:30",
      "remainingText":" 19 hours, 14 minutes"
   },
   "alarm":{
      "unixWakeUpTime":1634523300,
      "time":"12:45",
      "day":"Mon",
      "unixGetReadyTime":1634523600,
      "getReady":"12:50",
      "unixTimeToLeave":1634527200,
      "timeToLeave":"13:50",
      "normalNightLight":"22:15"
   },
   "nightLights":{
      "enabled":false,
      "unixSleepTime":1634473800,
      "sleepTime":"23:00",
      "unixLightFade":1634490000,
      "lightFade":"22:15"
   },
   "GPS":{
      "distance":0,
      "timezoneDistance":19.83,
      "timeZone":"Australia\/Adelaide"
   }
}

This was previously working.

rest:
  - scan_interval: 30
    timeout: 20
    resource: https://alarm.blackhorse.com:749/quickstart_data.php
    verify_ssl: false
    sensor:
      - name: "Google Alarm Event"
        json_attributes_path: "$.event"
        value_template: "{{  state_attr('sensor.google_alarm_event', 'text') }}"
        json_attributes:
          - "text"
          - "unixTime"
          - "time"
          - "timeFinish"
          - "day"
          - "dayFinish"
          - "address"
          - "travelTime"
          - "travelTimeSecs"
      - name: "Google Alarm"
        json_attributes_path: "$.alarm"
        value_template: "{{  state_attr('sensor.google_alarm', 'timeToLeave') }}"
        json_attributes:
          - "unixWakeUpTime"
          - "unixGetReadyTime"
          - "unixTimeToLeave"
          - "timeToLeave"
      - name: "Google Night Lights"
        json_attributes_path: "$.nightLights"
        value_template: "{{  state_attr('sensor.google_night_lights', 'enabled') }}"
        json_attributes:
          - "enabled"
          - "unixLightFade"
          - "lightFade"
          - "unixSleepTime"
          - "sleepTime"
      - name: "Google Leave Time Remaining"
        json_attributes_path: "$.remaining"
        value_template: "active"
        json_attributes:
          - "duration"
          - "editable"
          - "starts_at"
          - "finishes_at"
          - "remainingText"

** I have changed the URL, but you can see the correct data

I do see some errors in the supervisor logs, however I’m not usre if they are relevent or not

21-10-17 18:47:41 ERROR (MainThread) [asyncio] Task exception was never retrieved
future: <Task finished name='Task-1075' coro=<_websocket_forward() done, defined at /usr/src/supervisor/supervisor/api/ingress.py:280> exception=ConnectionResetError('Cannot write to closing transport')>
Traceback (most recent call last):
  File "/usr/src/supervisor/supervisor/api/ingress.py", line 287, in _websocket_forward
    await ws_to.send_bytes(msg.data)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_ws.py", line 155, in send_bytes
    await self._writer.send(data, binary=True, compress=compress)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 685, in send
    await self._send_frame(message, WSMsgType.BINARY, compress)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 643, in _send_frame
    self._write(header + mask + message)
  File "/usr/local/lib/python3.9/site-packages/aiohttp/http_websocket.py", line 660, in _write
    raise ConnectionResetError("Cannot write to closing transport")
ConnectionResetError: Cannot write to closing transport

The ONLY error or clue that I am getting in the normal longs are:

Logger: homeassistant.components.rest.sensor
Source: components/rest/sensor.py:177
Integration: RESTful (documentation, issues)
First occurred: 18:42:36 (360 occurrences)
Last logged: 19:32:33

REST result could not be parsed as JSON

Can you ping the resource, https://alarm.blackhorse.com:749/quickstart_data.php ?

Yes I can… That URL is NOT the right URL… it’s a dummy URL as I don’t want to post it on the forum… I can see the data without any issues in a web browser

I can see in the source code that this log message is followed by a debug log message that shows the JSON that it is unable to parse. The following snippet shows how you can change the rest integration’s log level to debug.

logger:
  default: info
  logs:
    homeassistant.components.rest: debug
1 Like

bingo… that allowed me to see the problem… cheers for that. There was text in there that was hidden making it looked like it was working when it wasn’t

1 Like