RESTful: is it possible to suppress failures from being logged?

Hi there - newby alert here…

I’ve added a few RESTful sensors to my setup. Unfortunately the service(s) queried often fail to respond. They are somewhat expected to fail, because the service isn’t always available. Unfortunately those failures leave a lot of noise in the server’s log file. Is there any way to avoid these entries?

You can filter out things

Logger - Home Assistant (home-assistant.io)

Alternatively you an use the value template to filter out failed calls to the resource. Share your sensor config and we can work out how.

Thanks both of you! Setting the log level is a first step - but might hide valid issues.

So here’s the simplest I can provide:

- scan_interval: 30
  resource: http://192.168.123.123/status.json
  sensor:
    - name: Device Version
      unique_id: mydevice.version
      value_template: '{{ value_json.MYDEVICE_INFO.SOFTWARE_VERSION }}'

That’s working fine as long as the server responds. There are more sensors defined after that, all taking the data from the same JSON data.

- scan_interval: 30
  resource: http://192.168.123.123/status.json
  sensor:
    - name: Device Version
      unique_id: mydevice.version
      value_template: '{{ value_json.MYDEVICE_INFO.SOFTWARE_VERSION if value_json.MYDEVICE_INFO.SOFTWARE_VERSION is defined else this.state }}'

That will keep the last value if the call to the resource fails.

1 Like

Are you sure this would work if the connection failed with a timeout? I’m still getting “unavailable” when the lookup fails.

No it wouldn’t help with that.

Thanks for the confirmation.