Hello !
I have a sensor that regularly reach timeout. I can catch it and handle it with a retry so that my code works as expected but it will log an Error anyway. As this error is mitigated in the code and there is nothing more I can do, I would like to control the log level of the timeout for this specific sensor.
Idea to handle this would be similar to the max_exceeded parameter of a script : we could set the log level of the timemout for a rest_command with a timeout_exceeded parameter.
The changes made https://github.com/home-assistant/core/pull/97208 are great improvement but still feel this feature is missing for a clean implementation.
Below is a code example to illustrate how it would look like (in my case its is not declared as a rest sensor but it would of course also work for a rest sensor)
rest_command:
pull_sensor_data:
url: "https://XXX.XXX.XXX.XXX/sensor/data"
method: GET
verify_ssl: false
headers:
Content-Type: application/json
timeout: 10
timeout_exceeded: warning
script:
get_sensor_data:
sequence:
- variables:
response: {}
- service: rest_command.pull_sensor_data
response_variable: response
continue_on_error: true
- choose:
- conditions:
- condition: template
value_template: "{{ response is not none and response['status'] == 200 }}"
sequence:
- service: script.process_sensor_data
data:
sensor_response: "{{ response }}"
- conditions: template
value_template: "{{ response is not none }}" #other error than timeout
sequence:
- service: script.retry_sensor_pulling
default: # got timeout, this will log an error and not a warning
sequence:
- service: script.retry_sensor_pulling