Can't "cast" field when passing it into a service

That’s not a service (at least not in HA-speak), it’s a Trigger… Templates are not supported in State triggers, use a Template trigger.

- trigger: template
  value_template: "{{ is_state(entity_id, 'off') }}"

HA Forum Cookbook: Where should I use Templates

FWIW, a device_tracker entity will never have the state “off”, unless you have a defined Zone called “off”… so it’s not a great entity type to use as the example in the field configuration.