I am trying to call from a tap_action to an automation that will turn on an entity. To this automation I want to pass as a parameter the name of the entity but I can’t get it to work.
The code without variables of the automation that works for me is
This makes no sense. Either v_entidad_ext already exists in which case this line of code doesn’t make any difference whatsoever (you are setting a variable to the value it already has), or it does not exist and you’ll get an error.
Edit: Somehow missed the difference in the int/ext suffix. But either way, it makes no practical difference. Either the variable would already be accessible everywhere within the automation, or it is not and will cause an error.
It looks to me you are inventing your own syntax. You cannot “pass” variables to an automation when run by an automation.trigger action. You can add arbitrary data to an event that an automation triggers on though.
This syntax comes from ia suggestions. From what you say in this way it is not possible. This is the first automation that I consider to make and my intention was to pass the entity to turn off/on to the automation and that it picks it up to execute the turn off.
My automations are done with nodered and the reason why I’m going to use an automation is just because of what I said before about the parent_id.
In the end the idea is to call the automation from the node that controls the event in nodered.
It is not clear to me why you want that or what you are hoping to achieve. The context ids do not refer to a thing/device/entity, but to state objects.
The parent_id of an automation is the id the last state object that triggered it. Your automation isn’t triggered by a state object, you are triggering it manually, hence it will never have a parent_id (it will be null/none), and neither will the switch the automation is operating on. They will both have the same id though, but only until either one of them are changed by a different state object.
Here is the context id and parent_id of an occupancy sensor, an automation that it triggers (when no longer occupied), and a light which the automation turned off. The id of the sensor becomes the parent_id of the automation, and the light has the same id and parent_id as the automation. But only until a different state object changes the state of either of the them.
I include a screenshot of what I want to control later from nodered. When a socket is activated automatically due to any reason (movement, clock programming, etc). In step 1 of the image we see that the parent_id to have value will indicate me that it is something programmed and I will handle it normally but if for example I turn on the plug manually I will be able to know it because the parent_id has no value but the user_id has a value. Depending on that I will be able to deactivate the automated control for a time x or whatever I want.
As you can see if I use an automation without passing variables this works but it forces me to make an automation for each light or plug. Hence I tried to make a single automation that would serve me for all by passing a variable where the name of the entity would go.