As in the topic, I’m trying to write “generic” code, for few triggers. Each trigger entity has related entities id as attributes. Example below is an attempt to chain 2 actions, first being condition, to trigger the snapshot for certain zone only if door in that zone were not opened before.
The latter works image entity_id is properly templated depending on the trigger, while the initial condition, fails to save with error:
Message malformed: Entity {{ state_attr(trigger.entity_id is neither a valid entity ID nor a valid UUID for dictionary value @ data['actions'][0]['entity_id']
The condition you have included is mostly nonsense… The error code is telling you that the value you have provided in entity_idis not an entity ID. This is because:
State conditions don’t allow templating.
Even if they could accept templates, the included template returns the value of some random attribute… likely not an entity ID.
It is unclear exactly what you are trying to do with the condition. If you can clarify your intent and goal, we can likely help figure out the correct approach.
As I wrote in the first post:
“Each trigger entity has related entities id as attributes.”
and:
"The latter works image entity_id is properly templated depending on the trigger, "
In both templating cases I am using same template to reach attributes of a trigger.
First fails. Second works.
Also, it would be wise to refrain from using sentences like:
“The condition you have included is mostly nonsense…”
It kills the open source community spirit, and apart from templating is a perfectly fine condition, working otherwise. So to be technically correct, it’s definitely not “mostly” nonsense
State triggers cannot use templates on entity_id. While the documentation on state conditions makes no mention of templates at all, it would not surprise me if the same restriction applies there as well, seeing as they are sort of related. None of the documentation examples for the state condition uses a templated entity_id so…
@Didgeridrew already told you what your issue is and you argued it. You cannot template the field you’re trying to template. The field does not allow templates.
If you want to write things in a generic way, you need to migrate to things that allow templates.
The only condition that allows templates is a template condition.
Templates are typically available everywhere in an action, unless it’s the root entity_id field. You can get around that by templating the entity_id inside data, or inside target.