Page 1 of 1

Use filename of script into script itself

Posted: Sunday 06 October 2019 9:34
by BOverdevest
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

Re: Use filename of script into script itself

Posted: Sunday 06 October 2019 9:49
by waaren
BOverdevest wrote: Sunday 06 October 2019 9:34 Is there a way to get the filename of the script that is running back into the script itself as a string ?
From the wiki
triggerInfo holds information about what triggered the script. The object has two attributes:

type: the type of the the event that triggered the execute function, either:
domoticz.EVENT_TYPE_TIMER,
domoticz.EVENT_TYPE_DEVICE,
domoticz.EVENT_TYPE_SECURITY,
domoticz.EVENT_TYPE_SCENE,
domoticz.EVENT_TYPE_GROUP
domoticz.EVENT_TYPE_VARIABLE)
domoticz.EVENT_TYPE_HTTPRESPONSE 2.4.0
trigger: the timer rule that triggered the script if the script was called due to a timer event, or the security state that triggered the security trigger rule. See below for the possible timer trigger rules.
scriptName: the name of the current script.