It would be great if I could call another LUA script as a subroutine somehow. This would allow coding of frequently used logic on one place, and use it in many places.
The only way I can see how to do this, is to write a LUA script and store it on disk or SD card, and call that from the LUA script.
One disadvantage is the fact that I cannot write and update from the normal user interface, but have to go in (e,g, Putty) and use a local editor in the R-Pi.
Another disadvantage is the way I can back this code up: it is not included in the normal backup from the Domoticz settings tab, but has to be done separately.
Am I missing a more simple way?
Call other LUA as subroutine?
Moderator: leecollings
- Varazir
- Posts: 360
- Joined: Friday 20 February 2015 22:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Call other LUA as subroutine?
You can use the global_data file to create you own helper functions
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
https://www.domoticz.com/wiki/DzVents:_ ... _functions
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
https://www.domoticz.com/wiki/DzVents:_ ... _functions
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Several IKEA devices/z-wave devices
-
- Posts: 708
- Joined: Saturday 27 February 2016 12:49
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Location: NL
- Contact:
Re: Call other LUA as subroutine?
I see how this works, but it still has the disadvantage that the code is not included in the Domoticz backup...Varazir wrote: ↑Tuesday 07 September 2021 20:44 You can use the global_data file to create you own helper functions
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
https://www.domoticz.com/wiki/DzVents:_ ... _functions
Hans
- Varazir
- Posts: 360
- Joined: Friday 20 February 2015 22:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Call other LUA as subroutine?
Yes it is. It's stored in the DB as far as I understand.manjh wrote: ↑Wednesday 08 September 2021 16:19I see how this works, but it still has the disadvantage that the code is not included in the Domoticz backup...Varazir wrote: ↑Tuesday 07 September 2021 20:44 You can use the global_data file to create you own helper functions
https://www.domoticz.com/wiki/DzVents:_ ... _scripting
https://www.domoticz.com/wiki/DzVents:_ ... _functions
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Several IKEA devices/z-wave devices
- erem
- Posts: 230
- Joined: Tuesday 27 March 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2021.1
- Location: Amsterdam/netherlands
- Contact:
Re: Call other LUA as subroutine?
only if you use the internal events editor. then the script are stored in domoticz.db
Yes it is. It's stored in the DB as far as I understand.
from the wiki: Note: there can be only one global_data.lua on your system. Either in /path/to/domoticz/scripts/dzVents/script or in Domoticz’ internal GUI web editor.
if you put global_data.lua in /path/to/domoticz/scripts/dzVents/script, it is your responsibility to back it up.
Last edited by erem on Saturday 11 September 2021 13:01, edited 2 times in total.
Regards,
Rob
Rob
- Varazir
- Posts: 360
- Joined: Friday 20 February 2015 22:23
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Contact:
Re: Call other LUA as subroutine?
Ahh okay, I only use the internal editor.erem wrote: ↑Wednesday 08 September 2021 16:52
only if you use the internal events editor. then the script are stored in domoticz.db
fromthe wiki: Note: there can be only one global_data.lua on your system. Either in /path/to/domoticz/scripts/dzVents/script or in Domoticz’ internal GUI web editor.
if you put global_data.lua in /path/to/domoticz/scripts/dzVents/script, it is your responsibility to back it up.
Raspberry PI 2 with RaZberry Controller 2016 ZWave+ and CC2531(zigbee)
Several IKEA devices/z-wave devices
Several IKEA devices/z-wave devices
Re: Call other LUA as subroutine?
If you want to automatically backup ALL Domoticz files you could use rsnapshot. I use it for years now to backup to an USB-stick, and it works perfect.
Then global_data.lua is also included.
Then global_data.lua is also included.
Who is online
Users browsing this forum: No registered users and 0 guests