I need to get the name of the automation itself as output of the automation.
e.g. automation.test_blabla
output: test_blabla
I need to extract “blabla” of the name. How to seperate e.g. via “_” into an array or something?
The sense of it: a following script gets textvariable=“blabla” as a variable passed over, so in can perform correctly.
(I can/should not hard code the name of the automation, because there are more than 30 similar of them. The construct would be very fragile to get messed up)
In / Developers Tool / States, you can type-in any entity-name and get its “Attributes”
friendly_name: Test Blabla
Yes you Should and HAVE TO give your automation a name(HardCoded), or they will just be,
“New Automation”
“New Automation”
“New Automation”
“New Automation”
Exactly, and that’s Another good reasons with giving them NAME
If you i.e Named them as Following, the “Construct” can hardly be fragile
"Automation 1 "
"Automation 2 "
"Automation 3 "
"Automation 4 "
However Your sloppy mind , might get messed up , figuring out which does which, , and where
So Start by figuring out a “naming-strategy” that “fits” your imagination/fantasy
Most people do that, not only for their automations/scripts, but also for various multiple entities, of i.e same Domains/Integration/Type
thanks for your fast reply, i wrote it unclear.
I meant:
I have 30 Automation with names like: xy_yxcsdfsdf
now I need a generic code in every of these automations, that extra the name of the automation it is in.
Maybe you should take one of these 30 automations you have, and go through it in The automation UI, to figure out how you can get these automations to give you an " output-action ", without running i.e a template_sensor, or call an i.e service:script, where you have this “generic code” ( fetching the automation.entity_attr.friendly_name , and split it, and set it as state(in i.e a template sensor( and then use this as a variable, in your other Script for some purpose
Can you “Follow” me ?
Sounds to me that you have very hard to express or show what you want to accomplice, sounds to me like you want to write more code, in the believe that you are writing less code.
On the other hand, i haven’t seen any of your automations, or your “script” where you want to use a “spitted” string of the automations name, as a “variable” for some purpose
True, however he then also want to “split” the name, so he i.e have " yxcsdfsdf " left ( also possible ofcause), AND then he want this “template” with-in his Automation(as generic code), and have this as an " output:" from the automation , so he can use it as a “variable” in another script
And all this he wants, to avoid writing the name of the automation, or i.e “fetching the i.e friendly_name, from the attr” , or passing the .split-ed “friendly_name” (from the “generic-template” into a script “variable”
He want it as generic-code , i believe this implies something like " this.entity.attr.friendly_name .split " and again pass this as an “output” from the automation (somehow), so he can use this “output” as an variable in another script
One way or another i think he need a template_sensor, if he not call/trigger the “other” script, from with-in the automation, and in this script “alter” the automation(entity)_name / friendly_name
And again, without presenting his “use-case” with “documentations” and clear description of what he want to achieve , people can come up with many good tips/advices, maybe he eventually figure out how to “put together” the pieces, in a whole other “concept” than his currently try to accomplice