Use filename of script into script itself
Posted: Sunday 06 October 2019 9:34
Goodmorning.
Is there a way to get the filename of the script that is running back into the script itself as a string ?
I would like to make a generic script that uses the name of the script to select which plug or sensor needs to be used within the script.
I now use a variable at the top with the machine name, but i would like ' generic' 1 step further.
So a script called "Monitor Dishwasher.lua" would (via some string modifications) work on the plug "Dishwasher Usage" (to tell me it is ready)
then changing script name to "Monitor Dryer.lua" I could use the same script on the dryer.
Same could de be used on PIR's (if you have several) or Open/Close sensors or lamps
greetings
Bart
Is there a way to get the filename of the script that is running back into the script itself as a string ?
I would like to make a generic script that uses the name of the script to select which plug or sensor needs to be used within the script.
I now use a variable at the top with the machine name, but i would like ' generic' 1 step further.
So a script called "Monitor Dishwasher.lua" would (via some string modifications) work on the plug "Dishwasher Usage" (to tell me it is ready)
then changing script name to "Monitor Dryer.lua" I could use the same script on the dryer.
Same could de be used on PIR's (if you have several) or Open/Close sensors or lamps
greetings
Bart