Hi all
I have a REST-configuration that receives water data from a website.
First you need to get a token for permission, and then get a client based on token. Then you can get data. To do this, Scan_Interval in each request is 10 seconds more.
When the system works in a standard configuration, the sensors receive information once a day on request sequentially.
But when rebooting the Homa assistant, all sensors are trying to fulfill requests at the same time. Since the token has not yet been received, subordinate requests have a mistake that will be corrected only every other day.
The question is, is it possible to pause so that the requests are executed one after another, and not at the same time? I would be grateful for any help.
The code is given below.
rest:
# Request to receive a token
- resource: https://xxx.yy/login
scan_interval: 86400
method: POST
headers:
Content-Type: application/json;
Connection: keep-alive;
payload: !secret me_payload
sensor:
- name: "ME Token"
unique_id: me_token
icon: mdi:cloud-key-outline
value_template: "{{ value_json.token }}"
# Client request
- resource: https://xxx.yy/client
scan_interval: 86410
method: GET
headers:
Content-Type: application/json;
X-Auth-Tenant-Token: "{{- states('sensor.me_token') -}}"
sensor:
- name: "ME Client"
unique_id: me_client
icon: mdi:home-account
value_template: "{{ value_json['items'][0]['name'] }}"
json_attributes_path: "$.items.[0]"
json_attributes:
- id
- address
#Request for counter data
- resource_template: "https://xxx.yy/meters/{{- state_attr('sensor.me_client','id') }}"
scan_interval: 86420
method: GET
headers:
Content-Type: application/json;
X-Auth-Tenant-Token: "{{- states('sensor.me_token') -}}"
sensor:
- name: "ME ColdWater"
unique_id: me_meter_coldwater
icon: mdi:water-thermometer-outline
value_template: "{{ value_json[0]['meter']['name'] }}"
json_attributes_path: "$.[0]"
json_attributes:
- meter
- name: "ME HotWater"
unique_id: me_meter_hotwater
icon: mdi:water-thermometer
value_template: "{{ value_json[1]['meter']['name'] }}"
json_attributes_path: "$.[1]"
json_attributes:
- meter