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
Use filename of script into script itself
Moderator: leecollings
-
- Posts: 23
- Joined: Wednesday 28 March 2018 20:56
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.11307
- Location: Nederland
- Contact:
Use filename of script into script itself
HUE, Tradfri, Zwave, RFXCOM, rooted TOON, PS4
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Use filename of script into script itself
From the wikiBOverdevest 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 ?
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.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Who is online
Users browsing this forum: No registered users and 1 guest