...Ok..
I understand the script name pattern and where to store them on the PI3 (/home/pi/dommoticz/scripts/lua)
I understand that:
script_device_whatever.lua run on ANY devicechange
script_time_whatever.lua run once a minute
script_variable_whatever.lua runs on ANY variable change
script_security_whatever.lua runs on ANY security event (...even if I did not yet well understood which are they)
but... what is I would need to:
Run a script ONLY on triggering a device ON/OFF (or a pushbutton)?
I assume I would use ON Action and OFF Action using prefix script:// but this doesn't work (error 512)... and by my [poor] understanding this would work only for windows and anyhow no tables (otherdevices, othersevices_lasupdate, devicechanged, uservariables) are passed to script.
So.. what shall I do in order to run just a script in case I trigger just one button in a specific state?
Wiki is not really clear about... it just specify to use script_device_ and trigger the correct otherdevices
thanks
ciao
M
LUA On Action and Off Action tables?
Moderators: leecollings, remb0
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
LUA On Action and Off Action tables?
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
- Westcott
- Posts: 423
- Joined: Tuesday 09 December 2014 17:04
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: UK - Glos
- Contact:
Re: LUA On Action and Off Action tables?
The usual way is to use a 'script_device_whatever.lua run on ANY devicechange'.
In the script, test for your devices by name to see which one has changed.
See script_device_demo.lua in the scripts/lua directory
In the script, test for your devices by name to see which one has changed.
See script_device_demo.lua in the scripts/lua directory
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
- emme
- Posts: 909
- Joined: Monday 27 June 2016 11:02
- Target OS: Raspberry Pi / ODroid
- Domoticz version: latest
- Location: Milano, Italy
- Contact:
Re: LUA On Action and Off Action tables?
ok...it's confimed that there is no possibility to launch a specific script for a specific device unless using the On/Off Action but it does NOT forward the system tables (like otherdevices etc etc...)
Thanks for your clarification
ciao
M
Thanks for your clarification
ciao
M
The most dangerous phrase in any language is:
"We always done this way"
"We always done this way"
- Siewert308SW
- Posts: 294
- Joined: Monday 29 December 2014 15:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Stable
- Location: The Netherlands
- Contact:
Re: LUA On Action and Off Action tables?
Maybe i totally misunderstand you.
But you want to run a script only when a specific trigger is triggered?
If so, then it aint so hard.
Create a script_device_whatever.lua in /lua
Move all other device scripts outside the /lua folder
Let say you have moved "a_lua_script.lua" to "/home/pi/domoticz/scripts/lua_events/"
In this script something has to be triggered when opening the frontdoor.
Then do the following in "script_device_whatever.lua" which is the only file in "/home/pi/domoticz/scripts/lua/"
and for your "a_lua_script.lua"
Be aware that in your "a_lua_script.lua" there is no "commandArray {}" and "return commandArray"
If it does contain and multiple scripts are triggered then your scripts will fail.
This way as seen above your main lua "script_device_whatever.lua" does the "commandArray {}" and "return commandArray"
But you want to run a script only when a specific trigger is triggered?
If so, then it aint so hard.
Create a script_device_whatever.lua in /lua
Move all other device scripts outside the /lua folder
Let say you have moved "a_lua_script.lua" to "/home/pi/domoticz/scripts/lua_events/"
In this script something has to be triggered when opening the frontdoor.
Then do the following in "script_device_whatever.lua" which is the only file in "/home/pi/domoticz/scripts/lua/"
Code: Select all
-- Set Lua Path
lua_path = "/home/pi/domoticz/scripts/lua_events/"
commandArray = {}
if devicechanged['frontdoor'] then
dofile(lua_path.."a_lua_script.lua")
end
return commandArray
Code: Select all
if devicechanged['frontdoor'] == 'Open' and otherdevices['Light'] == 'Off' then
commandArray['Light']='On'
end
if devicechanged['frontdoor'] == 'Closed' and otherdevices['Light'] == 'On' then
commandArray['Light']='Off'
end
If it does contain and multiple scripts are triggered then your scripts will fail.
This way as seen above your main lua "script_device_whatever.lua" does the "commandArray {}" and "return commandArray"
Setup:
- DS923+ Docker
Domoticz Latest Stable
Mosquitto / ZwaveJSUI @ Aeotec Z-Stick Gen5+ / PiHole Unbound
P1 USB Gas/Power, HW watermeter
- A lot of Zwave switches, contacts, plugs, smoke/Co2 ect
- DiY 7.5kWh Solar Storage @ GitHuB
- DS923+ Docker
Domoticz Latest Stable
Mosquitto / ZwaveJSUI @ Aeotec Z-Stick Gen5+ / PiHole Unbound
P1 USB Gas/Power, HW watermeter
- A lot of Zwave switches, contacts, plugs, smoke/Co2 ect
- DiY 7.5kWh Solar Storage @ GitHuB
Who is online
Users browsing this forum: Amazon [Bot], Bing [Bot] and 1 guest