Using template in device_tracker scan_interval

Is it possible to use Templates inside my device_tracker.yaml file? I’m trying to dynamically adjust the scan interval.

I have some family that stays with us for about a week a few times a year. I don’t want to ping their devices every 30 seconds all year long. I thought I would ping their devices every three hours, then when they arrive, Guest Mode turns on. When Guest Mode is on and they are home, I don’t want it to ping as often, but I want it to ping more frequently when they are not home.

How resource intensive is a ping? Is it worth trying to optimize this?

I’m getting errors when I check my configuration. Can someone point me in the right direction? Much appreciated.

- platform: ping
  hosts:
    deb_ping: 192.168.100.234
  scan_interval: >-
    {% if is_state('input_boolean.guest_mode', 'off') -%}
      03:00:00
    {%- else -%}
      {% if is_state('device_tracker.deb_ping', 'home') -%}
        00:02:00
      {%- else -%}
        00:00:30
      {%- endif %}
    {%- endif %}
  consider_home: 900

The scan_interval variable expects a value of seconds as an integer, and does not accept templates.

So I have to set it to a fixed number then?

Yes, the number of seconds between scans…

- platform: ping
  hosts:
    deb_ping: 192.168.100.234
  scan_interval: 30
  consider_home: 900