Re: X10 Dimmers; A simple solution
Posted: Wednesday 22 February 2023 15:07
Is that a question to me? on github ?
Open source Home Automation System
https://forum.domoticz.com/
Code: Select all
EventSystem: in script_device_dimmers:[string "commandArray = {}..."]:22: bad argument #1 to 'pairs' (table expected, got nil)
Status: User: admin (IP: xxx.xxx.xxx.xxx) initiated a switch command (172/Lamp Aanrecht/Set Level)
Status: LUA: idx: 172, name: Lamp Aanrecht, state: On, svalue: 30, nvalue: 2
Status: LUA: /home/onshuis/Domotica/domoticz/scripts/lua/mochad_dim.sh J3 18 Code: Select all
if (devicechanged_ext ~= nil) thenCode: Select all
commandArray = {}
local BASHSCRIPT = "/home/pi/domoticz/scripts/lua/mochad_dim.sh " --keep the space at the end!
local bashcall = ""
dimmers = {}
-- Dimmer names must be strictly identical to the dimmer labels
dimmers["Lumiere Salon"]="o4"
dimmers["Lumiere Salle a Manger"]="o6"
dimmers["Lumiere Chambre 1"]="o8"
dimmers["TestDimmer"]="o10"
dimmers["TestSwitch"]="o11"
dimmers["Lumiere Bureau"]="o12"
dimmers["Lumiere Chambre 3"]="o13"
if (devicechanged_ext ~= nil) then
for name,value in pairs(devicechanged_ext) do
if (name == "name") then
local X10Address=dimmers[value]
--If a registered Dimmer
if X10Address ~= nil then
-- Create appropriate way to call the BASH script
local state = devicechanged_ext["state"];
local level = tonumber(devicechanged_ext["svalue"]);
print ("idx: "..devicechanged_ext["idx"]..", name: "..devicechanged_ext["name"]..", state: "..state..", svalue: "..tostring(level)..", nvalue: "..devicechanged_ext["nvalue"]);
if state == "Off" then
bashcall=BASHSCRIPT ..X10Address.." ".. "Off"
elseif state == "On" then
if (level == 0) then
bashcall=BASHSCRIPT ..X10Address.." ".. "On"
else
local intdata=(tostring(math.floor(level*0.63)))
bashcall=BASHSCRIPT..X10Address.." "..intdata
end
end
--Call the Bash script
--os.execute(bashcall)
print(bashcall);
end
end
end
end
return commandArrayYes thanks, it was clear.waltervl wrote: Thursday 23 February 2023 17:16 To be clear, to use this new script you have to update domoticz to the latest beta version 15095 or higher.
To you probably it was clear but not for the other users that will have the same problem and read this thread