Device tracker: variable interval scan

I think it would be interesting a service to change the refresh interval to check for new devices. It is currently fixed on configuration, but in some cases change that value could be useful.
For example, in my case, I have a Xiaomi router for detecting presence. If I leave home, once I come back and I enter the zone Home, I would like to set the interval to 2s (for example) and then, once detected by the router, change the interval to 20s.
It would decrease the response time for any automation triggered when “at home”, and also it would relief the work load of HA when it’s not necessary a higher interval.

Home Assistant currently has a service called homeassistant.update_entity (documentation).

It can be used, in an automation, to update an entity’s status independently of the entity’s existing scan_interval.

For example, this automation checks the entity’s status every 5 seconds.

  - alias: 'rainfall_update'
      - platform: time_pattern
        seconds: '/5'
      - service: homeassistant.update_entity
        entity_id: sensor.rainfall_rate
1 Like

Thanks for the info. I didn’t know that service exists.
i’ve just tried it using the UI Services panel, and I get an error like this:
Forced update failed. Component for device_tracker.wifi not loaded.
But the component is loaded and working. Any idea what’s happening?