ha-dockermon icon indicating copy to clipboard operation
ha-dockermon copied to clipboard

REST result could not be parsed as JSON

Open xstrex opened this issue 5 years ago • 1 comments

Hey Phil, been a bit! Hope all is well!

Ran into an interesting issue recently, and thought I'd bring it to your attention, in case you've seen (or haven't seen) it before. My HA config has no other REST sensors, but my logs are filling up with the following:

2020-07-16 13:03:23 WARNING (SyncWorker_3) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:03:53 WARNING (SyncWorker_11) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:04:24 WARNING (SyncWorker_5) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:04:55 WARNING (SyncWorker_1) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:05:26 WARNING (SyncWorker_0) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:05:57 WARNING (SyncWorker_11) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:06:28 WARNING (SyncWorker_4) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:06:59 WARNING (SyncWorker_11) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:07:30 WARNING (SyncWorker_16) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:08:01 WARNING (SyncWorker_15) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:08:32 WARNING (SyncWorker_7) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:09:03 WARNING (SyncWorker_9) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:09:34 WARNING (SyncWorker_9) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:10:05 WARNING (SyncWorker_9) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:10:36 WARNING (SyncWorker_11) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:11:07 WARNING (SyncWorker_1) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:11:38 WARNING (SyncWorker_12) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:12:09 WARNING (SyncWorker_18) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:12:40 WARNING (SyncWorker_4) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:13:11 WARNING (SyncWorker_11) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:13:42 WARNING (SyncWorker_0) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:14:13 WARNING (SyncWorker_11) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:14:44 WARNING (SyncWorker_9) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:15:15 WARNING (SyncWorker_12) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:15:46 WARNING (SyncWorker_16) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:16:17 WARNING (SyncWorker_6) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:16:48 WARNING (SyncWorker_10) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON
2020-07-16 13:17:19 WARNING (SyncWorker_2) [homeassistant.components.rest.sensor] REST result could not be parsed as JSON

Also, here's the current config for one of the sensors:

  - platform: rest
    resource: !secret had-jabba-ha
    authentication: basic
    username: !secret had-jabba-user
    password: !secret had-jabba-pass
    name: Home-Assistant
    json_attributes:
      - status
    value_template: '{{ value_json.state }}'
    timeout: 30

As you can see, I'm simply making a REST call, to the endpoint matching "http://x.x.x.x:8126/container/foobar", passing some basic auth, defined in the docker-config, then parsing out the 'status' line from the JSON output, and using it as a sensor, to tell me the state of the container (without the ability to turn on/off the container, read-only essentially).

But the logs indicate that it can't seem to parse the JSON; but if I load up the same URL, with basic auth u/p in something like postman, to returns a 200 code, followed by JSON output. Which has me confused.

Any idea what might be going on here?

Cheers!

xstrex avatar Jul 20 '20 20:07 xstrex

Hey Jon,

Hope you've been well! Sorry for the delay.

That is really weird. I am wondering if your HA instance is having trouble communicating with HA-Dockermon?

Is your HA install running in a docker? If so can you do this:

docker exec -it <<hass container name>> /bin/bash
curl <<url to ha dockermon sensor>>

My assumption is that HASS can't communicate with HA-Dockermon at all, and hence it is throwing those JSON errors.

philhawthorne avatar Aug 01 '20 05:08 philhawthorne