Restful Sensor - Handle Empty Response

I use the following integration to get some sensor data (temperature and humidity) from a rest-api.

Sometimes the request timesout and the sensor will become not avialable.

Is there a way to avoid this - probably trigger a second request if the response is empty oder ignore it?

Here my Config:

## FES001 ##
  - scan_interval: 300
    resource: https://sensor.example.com/v1/open/data?bleMac=E2:88:1A:72:AA:AB&page=0&size=2
    timeout: 20
    headers:
      Authorization: 12345678
    sensor:
      - name: "FES001"
        json_attributes_path: "$.['data']"
        json_attributes:
          - "list"
          - "mac"
          - "power"
        value_template: "OK"

      - name: "FES001 HumiSensor"
        value_template: "{{states.sensor.fes001.attributes.list[0].humidity | round(2)}}"
        device_class: humidity
        unit_of_measurement: "%"
        
      - name: "FES001 TempSensor"
        value_template: "{{states.sensor.fes001.attributes.list[0].temperature | round(2)}}"
        device_class: temperature
        unit_of_measurement: "°C"
1 Like

Sorry for resurrecting this old thread, did you come up with a way to deal with timeouts and “empty responses”? I just added a RESTful sensor and once in a while I will encounter this problem.