I have a number of RESTful sensors, and during restart HA send API requests to all of them at the same time, resulting in a number of “Timeout while fetching data”, “Setup of rest is taking over 10 seconds.”, “Platform rest not ready yet; Retrying in background in 30 seconds”. And soon I guess that my IP will be banned…
How do you have your rest sensors formatted? Are you taking advantage of the rest integration over the rest platforms?
All of them are configured in yaml, 243 entities.
I have more or less two variants, see examples below.
- platform: rest
resource: https://opendata-download-hydroobs.smhi.se/api/version/latest/parameter/2/station/751/period/latest-hour/data.json
method: GET
name: "smhi_hydro_nu_751"
scan_interval: 901
value_template: "{{ value_json.value[3].value | round(1) }}"
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
´´´
```yaml
- resource: https://vattenwebb.smhi.se/hydronu/data/point?subid=1005
scan_interval: 3601
sensor:
- name: "smhi_hydro_prognos_1005_d1p"
value_template: '{{ value_json["chartData"].coutHindcast.data[29].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
- name: "smhi_hydro_prognos_1005_d0"
value_template: '{{ value_json["chartData"].coutForecast.data[0].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
- name: "smhi_hydro_prognos_1005_d1"
value_template: '{{ value_json["chartData"].coutForecast.data[1].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
- name: "smhi_hydro_prognos_1005_d2"
value_template: '{{ value_json["chartData"].coutForecast.data[2].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
- name: "smhi_hydro_prognos_1005_d3"
value_template: '{{ value_json["chartData"].coutForecast.data[3].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
- name: "smhi_hydro_prognos_1005_d4"
value_template: '{{ value_json["chartData"].coutForecast.data[4].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
- name: "smhi_hydro_prognos_1005_d5"
value_template: '{{ value_json["chartData"].coutForecast.data[5].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
- name: "smhi_hydro_prognos_1005_d6"
value_template: '{{ value_json["chartData"].coutForecast.data[6].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
- name: "smhi_hydro_prognos_1005_d7"
value_template: '{{ value_json["chartData"].coutForecast.data[7].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
- name: "smhi_hydro_prognos_1005_d8"
value_template: '{{ value_json["chartData"].coutForecast.data[8].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
- name: "smhi_hydro_prognos_1005_d9"
value_template: '{{ value_json["chartData"].coutForecast.data[9].1 }}'
unit_of_measurement: "m³/h"
device_class: VOLUME_FLOW_RATE
state_class: measurement
´´´
Unfortunately is it not possible to use “availability_template”, otherwise could that be a option during startup.