Simulating 'trigger' in template editor

Developing templates for automations, and I’d like to simulate the data available in the trigger object. I see that I can use Jinja2 set statement and fill in some dummpy JSON - but I haven’t found a way to set the python list of attributes inside.

Ie, I’d like to set a Jinja2 variable named “trigger” that has platform, entity_id, to_state, from_state, and for properties where to_state and from_state are populated HA state objects with attributes. This would allow me to test my automation templates in template editor without having to edit / reload automation / test.

OR – if there is a way to set the to_state and from_state properties of trigger variable to the live state of some object available in HA, I could do that – but I haven’t found a way to tell Jinja2 to make a variable the same contents as some other object.

Thanks in advance for any assistance.

Replying to my own question:

The following seems to work, but I’ll leave this thread open in case there is a better way that someone can add.

{% set trigger =
  } %}
1 Like

What I typically do is setup dummy devices using MQTT and then use those devices in my templates while testing. That way, I can code the templates (automations and scripts) using virtual devices which I can control through MQTT. Once I’m done with the template, I switch it over to the real device entities and remove the MQTT ones.