Rest sensor refresh rate

If I create a RESTful sensor fetching data from external API endpoint, how is the refresh frequency controlled? I’ve tried this:

  - platform: rest
    scan_interval: 15
    ....

But regardless of the value (or no value at all) I can’t get the sensor to update automatically, it just stays as is until I refresh manually.
https://www.home-assistant.io/integrations/rest does not list anything on refresh frequency, but https://www.home-assistant.io/docs/configuration/platform_options/ does mention scan_interval, although as mentioned, it has no effect. Plus it states “These options are being phased out and are only available for single platform integrations.”

Thx

1 Like

Does the information change for what you’re scanning? If the answer is no, then you won’t see an update because the information is the same.

1 Like

Right, that makes sense. However, once information changes - and since this is a pull activity - what determines how often the sensor will poll for updates?

scan_interval

That is the problem with polling.
Worst case you could have the “wrong” state scan_interval minus one second if the value updated just after you polled.

I’m still looking for tips here. I have set up a restful sensor and it’s hitting the rest endpoint like 100 times each hour, which is far too often and I’m getting complaints and unnecessarily reaching bandwitdh limits that prevent the sensor from working constantly. So I would like an option to limit the sensor to only poll once every n minutes or something similar.

Hi there,

Searching for something similar I found some nice already answered threads that helped me out:

So basically, setup a very long scan_interval value for your sensor, and whenever you want to update the value run with an action the following:

- service: homeassistant.update_entity
  entity_id: sensor.your_rest_sensor

Cheers,
Emanuel

1 Like