I am creating the hereunder script and getting the following error when trying to save: Message malformed: Entity {{ entity2ctrl }} is neither a valid entity ID nor a valid UUID for dictionary value @ data[‘entity_id’]
Can someone please help me with what am I doing wrong with a field/ variable script?
Second, you can’t use a template for entity_id in a State Trigger.
- platform: state
entity_id: "{{ entity2ctrl }}"
from: unavailable
It’s this second mistake that is responsible for the error message:
Entity {{ entity2ctrl }} is neither a valid entity ID nor a valid UUID for dictionary value @ data[‘entity_id’]
The challenge is to find another kind of trigger that supports templates and is able to detect the entity’s previous state, because you want to detect from: ‘unavailable’). Normally I would suggest using a Template Trigger but it can’t check an entity’s previous state.
The only thing I can think of right now is to use a Template Trigger that checks if entity2ctrl has not changed to unavailable.
In other words, it waits for a state-change from any value (on, off, or unavailable) to either on or off. It’s not exactly the same as your State Trigger but, depending on your requirements, it might be close enough. After all, your script is designed to first check that the entity’s current state isunavailable. Then it wants to trigger on a state-change to some other value (on or off) and the suggested Template Trigger will do that.