Hallo Home Assistant community,
I’m a newbie in Home Assistant and I need some help for a challenge with rest sensors. At home I have some different technologies installed, heating, water condition, photovoltaic…
I thought the best way to bring all the data of the different technologies into Home Assistant is a new abstraction level. So, I created some microservices which collect all information for the different system and provide them to Home Assistant via REST API. The first view API calls were no problem for Home Assistant. Yesterday I configured some more rest sensors and now I have a completely new challenge…
I created a file for each rest sensor and each file has a separate API rest call to one of my microservices (the idea was to make it modular). Each file works when I put it into my sensor folder but when I copy all files into my sensor folder the values will not be shown anymore. It seems that the API calls takes too long and never finish but I don’t know why.
Here is my project setup:
Home Assistant version: 2023.2.4
Environment: Docker
CPU: 8 Cores
Memory 32GB
I insert the following lines into the configuration.yaml to include all files in one folder:
# include custom sensors
sensor: !include_dir_merge_list sensor/
And in my sensor folder there are 21 sensor Yaml files. Each file looks like:
- platform: rest
name: Name of Sensor API
resource: http://local-server/api/content/value
scan_interval: 40000
headers:
Content-Type: "application/json"
x-auth-token: "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
value_template: "{{ value_json.value }}"
json_attributes:
- value
- unit
- platform: template
sensors:
name_of_sensor:
icon_template: "mdi:waves-arrow-right"
friendly_name: "Sensor Value"
value_template: "{{ state_attr('sensor.name_of_sensor_api', 'value') }}"
unit_of_measurement: "l/h"
On the user interface it looks like:
And in the log file there are these lines:
Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:236
Integration: Sensor (documentation, issues)
First occurred: 4:35:17 PM (17 occurrences)
Last logged: 4:35:17 PM
Platform rest not ready yet; Retrying in background in 30 seconds
I think the problem is that Home Assistant cannot handle too much rest API calls. Can I increase or parallelize it? I mean this are only 21 API calls for initialization and I set the interval to 40000 seconds (twice a day). So, why does Home Assistant not resolve the values? Is there a better practice which I should use instead of creating a separate sensor folder with single files for each rest sensor?
Thank you very much for your help!
JulianM