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

I’ve been through the docs and several forum threads and my code LOOKS right to me, but not to the compiler… Hoping for someone else to let me know what I’ve done wrong here.

This is a script that takes an entity_id as a field and will then notify the user when the entity turns OFF. For example, let me know when the clothes dryer has stopped.

The error I receive:
Error:Entity {{ entity_id }} is neither a valid entity ID nor a valid UUID for dictionary value @ data['entity_id']. Got None .

notify_device_off:
alias: “Notify when device turns off”
description: “Sends a notification when the specified device turns off”
fields:
entity_id:
description: “The ID of the device to monitor”
example: “device_tracker.your_entity_id”
sequence:
- wait_for_trigger:
- trigger: state
entity_id: “{{ entity_id }}”
to: ‘off’
- action: notify.MattPhone
data:
title: “Device Turned Off”
message: “The device has turned off.”

I’m ready to just convert this into a Case statement for the very small set of entities I actually care about, but thought I would ask for help on this approach first.

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.