core: REST sensors show as "Unavailable" state after upgrading to Home Assistant 0.117.0

The problem

Hi Guys, after upgrading to Home Assistant 0.117.0 four of my REST sensors started producing an “Unavailable” state along with respective “failed with [Errno 111] Connect call failed” errors in the log. My configuration has not changed at all before or after the upgrade.. Also, I can reach ALL the respective API endpoints with a regular web browser without any issues.

Environment

  • Home Assistant Core release with the issue: Home Assistant 0.117.0
  • Last working Home Assistant Core release (if known): 0.116
  • Operating environment (OS/Container/Supervised/Core): VirtualBox VM running on Windows 10
  • Integration causing this issue: Template
  • Link to integration documentation on our website: https://www.home-assistant.io/integrations/template

Problem-relevant configuration.yaml

sensor:
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/fs
    name: Horizon C Drive Used
    value_template: '{{ value_json[0].percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/fs
    name: Horizon E Drive Used
    value_template: '{{ value_json[1].percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    name: diskio_0
    resource: http://192.168.1.2:61208/api/3/diskio
    value_template: '{{ ( value_json[0] ) }}'
    json_attributes_path: "$.0"
    json_attributes:
      - time_since_update
      - read_bytes
      - write_bytes
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    name: diskio_1
    resource: http://192.168.1.2:61208/api/3/diskio
    value_template: '{{ ( value_json[1] ) }}'
    json_attributes_path: "$.1"
    json_attributes:
      - time_since_update
      - read_bytes
      - write_bytes
    verify_ssl: false
    timeout: 30
    scan_interval: 16

It is important to note that I have SEVERAL other REST sensors (few examples below) that connect to the same server that don’t have any issues at all. The only difference I see is in the way value_template is defined when parsing a json response with more than 1 key.

  - platform: rest
    resource: http://192.168.1.2:61208/api/3/cpu
    name: Horizon CPU
    value_template: '{{ value_json.total | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/mem
    name: Horizon RAM
    value_template: '{{ value_json.percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/memswap
    name: Horizon Pagefile
    value_template: '{{ value_json.percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16

Traceback/Error logs

I get the below errors constantly in the log file:

2020-10-29 12:04:26 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.2:61208/api/3/fs failed with [Errno 111] Connect call failed ('192.168.1.2', 61208)
2020-10-29 12:04:26 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.2:61208/api/3/fs failed with [Errno 111] Connect call failed ('192.168.1.2', 61208)
2020-10-29 12:04:26 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.2:61208/api/3/diskio failed with [Errno 111] Connect call failed ('192.168.1.2', 61208)
2020-10-29 12:04:26 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: http://192.168.1.2:61208/api/3/diskio failed with [Errno 111] Connect call failed ('192.168.1.2', 61208)

Additional information

I looked at Home Assistant 0.117.0 breaking changes for templates… however, I can’t tell what change(s) broke my 4 REST sensors. It seems like something changed in Home Assistant adversely affecting REST sensors that have lines like below:

value_template: '{{ ( value_json[0] ) }}'
value_template: '{{ ( value_json[1] ) }}'

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 1
  • Comments: 37 (10 by maintainers)

Most upvoted comments

It looks like the PR with the fix was finally merged into the Master today. It appears this fix will be in the next release of Home Assistant!

I’m still stuck using Home Assistant Version: 0.116.x

I hope this helps…

sensor:
  - platform: rest
    resource: http://192.168.1.2:61208/api/3/fs
    name: Horizon C Drive Used
    value_template: '{{ value_json[0].percent | round }}'
    unit_of_measurement: "%"
    verify_ssl: false
    timeout: 30
    scan_interval: 16

out.txt

sensor:
  - platform: rest
    name: diskio_0
    resource: http://192.168.1.2:61208/api/3/diskio
    value_template: '{{ ( value_json[0] ) }}'
    json_attributes_path: "$.0"
    json_attributes:
      - time_since_update
      - disk_name
      - read_bytes
      - write_bytes
    verify_ssl: false
    timeout: 30
    scan_interval: 16

out2.txt

We are waiting for https://github.com/python-hyper/h11/pull/115 which appears is actively being reviewed now (within the last 24 hours)

@enjoysimpson I’m not sure either. I haven’t been able to get a definitive answer.

Does anybody know how this will continue? A change/fix seems not to be part of Home Assistant 0.118.0. I tried it out, same REST sensors are dead after update to 118.0, same behavior as in 117.x. So I am back to 116.4.