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?
tom_l
July 10, 2024, 8:12am
3
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.
tom_l
July 10, 2024, 11:45am
5
- 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.
tom_l
July 10, 2024, 12:52pm
7
No it wouldn’t help with that.
Thanks for the confirmation.