I suspect the answer is “no”, but it’s worth a check. I have a sensor which calls an API which I know updates only once a day. I would like it to update relatively quickly after that time, and then not waste resources repeating itself. Is there a way to specifically schedule update times?
Set the value of scan_interval
to a large number (it’s in seconds) so that it updates very infrequently (effectively, you’re trying to disable the sensor’s automatic updates).
Create an automation with a Time Trigger set to whatever time you require and make its action
call the homeassistant.update_entity
service for the REST sensor.
Exactly what i´m looking for! THX
Can rest sensors only be updated by the scan interval? I have a lot of rest sensors tied to an API call and I have a limited number of calls. I restart my home assistant a lot while working on new automatons and would like to prevent rest api calls when this is happening.
The answer to your question is in the Solution post.
Why are you restarting Home Assistant while working on automations?
Yeah i have my scan interval to check the rest sensors once a week. I restart my home assistant a lot when adding new rest sensors or help files. It just works better than resetting just the rest configs from the developer tab. So I am just asking if is possible to make rest sensors not hit an api on a home assistant restarts.
The command in Developer Tools > YAML reloads the integration. How is restarting Home Assistant better at reloadingthe integration?
In my experience, using the command for REST does not add any new sensors, so I used restart home assistant more often. I will try reloading the entire YAML config to see if I get better results. But even doing that, won’t the API still get hit?
It should. If it fails to do that then report it as an Issue in Home Assistant’s GitHub Core repository.
Thank you so much for sharing!
Thanks and another question.
If the rest call updates several sensors, using homeassistant.update_entity for only one sensor the other sensors are updated too?
I have never tried that particular arrangement so I can’t provide a definitive answer. My guess would be ‘yes’ but I suggest you try it and report back with your results.