Hi
Still new to Domoticz and scripting. I have set up a virtual switch to be triggered by pilot (iOS app) using geolocation.
I have done a solution using events and a solution using script in /domoticz/scripts/lua and I'm struggling to see what the differences are. Can I confirm that if *any* device state changes, domoticz/lua runs any scripts labelled script_device_xxxx in /domoticz/scripts/lua.
So if you have multiple script_device_xxxx scripts they all run regardless. How does this differ from events?
Is it best practice to have one script_device_xxxx script that calls out to other lua scripts?
Thanks in advance.
lua events and lua scripts
Moderator: leecollings
-
simonrg
- Posts: 329
- Joined: Tuesday 16 July 2013 22:54
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8807
- Location: North East England
- Contact:
Re: lua events and lua scripts
If you mean writting your Lua script in the UI events page versus having a file in the scripts/lua directory, then functionaly no difference.
The UI events page scripts are stored in the mysql database - domoticz.db, whereas obviously the scripts/lua directory stores the files. So convenience of single file to back up versus having individual files you can edit anywhere.
When any device changes in Domoticz, then Domoticz will run each of your Blockly events, Lua UI events and Lua file events.
Experimentation has shown there is a penalty to having lots of separate scripts, as each time Domoticz loads a script it has to set up all the variables to be passed, devicechanged, otherdevices etc..
So performance will be better if you use a single device and a single time script which calls appropriate scripts. This can be as simple as a single master script or a complete framework (search for dzvents on the forum).
The UI events page scripts are stored in the mysql database - domoticz.db, whereas obviously the scripts/lua directory stores the files. So convenience of single file to back up versus having individual files you can edit anywhere.
When any device changes in Domoticz, then Domoticz will run each of your Blockly events, Lua UI events and Lua file events.
Experimentation has shown there is a penalty to having lots of separate scripts, as each time Domoticz loads a script it has to set up all the variables to be passed, devicechanged, otherdevices etc..
So performance will be better if you use a single device and a single time script which calls appropriate scripts. This can be as simple as a single master script or a complete framework (search for dzvents on the forum).
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266
-
georgesattali
- Posts: 84
- Joined: Saturday 05 March 2016 16:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: France
- Contact:
Re: lua events and lua scripts
Yes that's true.Can I confirm that if *any* device state changes, domoticz/lua runs any scripts labelled script_device_xxxx in /domoticz/scripts/lua :
I suppose you are speaking of blocky, the graphical event editor in "Setup/More options/Events".So if you have multiple script_device_xxxx scripts they all run regardless. How does this differ from events?
Functionnality is similar,
using written lua scripts, one gets all the power of a complete programming language.
using blocky, one can make simpler commands without knowing programmation.
In blockly, you can choose when you command will be run (click on "All").
I don't think so. You should stick to one script for one usage.Is it best practice to have one script_device_xxxx script that calls out to other lua scripts?
Each script_device_xxxx contains a test like
Code: Select all
if devicechanged["mydevice"] == "On" then
...
endBye
GD
- darlomrh
- Posts: 35
- Joined: Monday 23 May 2016 8:03
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: UK
- Contact:
Re: lua events and lua scripts
Hi it's in that area, however you have the option to chose Blocky or lua so you can create event scripts there rather than the directory.I suppose you are speaking of blocky, the graphical event editor in "Setup/More options/Events".
Functionnality is similar,
using written lua scripts, one gets all the power of a complete programming language.
Thanks for the replies
Who is online
Users browsing this forum: No registered users and 1 guest