Skip to content

REST sensors show as "Unavailable" state after upgrading to Home Assistant 0.117.0 #42608

Description

@mkanet

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] ) }}'

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions