i try to combine a switch that executes
on script:///home/pi/domoticz/scripts/start_motion.sh
off script:///home/pi/domoticz/scripts/stop_motion.sh
with a script that executes the above motion switch on timed events ( groupOnTimer1 etc.)
so i can get rid off the two *.sh files and have the same logging (timed and manual)
So i first made a difference in the script between device triggering and timer triggering
Script is finished, but
1) I got an error "on info" that i don't understand and
2) when i turn the switch 'Bewegingsservice' On or off it always executes the ELSE part
I search for houws but i dont see it....
2019-06-14 22:00:31.531 Status: User: Admin initiated a switch command (153/Bewegingsservice/Off)
2019-06-14 22:00:31.770 Status: Executing script: /home/pi/domoticz/scripts/stop_motion.sh
2019-06-14 22:00:31.784 Status: dzVents: Error (2.4.23): MotionTimers: An error occurred when calling event handler DZ_Bewegingsservice
2019-06-14 22:00:31.784 Status: dzVents: Error (2.4.23): MotionTimers: ...cripts/dzVents/generated_scripts/DZ_Bewegingsservice.lua:42: attempt to index local 'info' (a nil value)
Code: Select all
local groupOnTimer1 = 'at 00:05 on mon,tue,wed,thu,fri,sat,sun'
local groupOffTimer1 = 'at 06:00 on mon,tue,wed,thu,fri,sat,sun'
return {
on = {
timer = {groupOnTimer1,groupOffTimer1},
devices = {'Bewegingsservice'},
},
logging = { level = domoticz.LOG_ERROR ,
marker = "MotionTimers"},
execute = function(dz,device,item,info)
local switch0 = dz.devices('timerlog')
local switch2 = dz.devices('Jablotronenabled')
local switch3 = dz.devices('Bewegingsservice')
if ((item.isTimer and item.trigger == groupOnTimer1 and switch2.state == 'Unlocked') or (item.isDevice and device.state == 'On')) then
if item.isTimer then
switch3.switchOn().checkFirst()
end
osExecute('sudo mount -a')
osExecute('sudo /etc/init.d/motion start')
dz.log("Script: " .. info.scriptName .. " Bewegingsservice is geactiveerd....", dz.LOG_INFO)
timertekst = dz.time.rawDate .. ' ' .. dz.time.rawTime .. ' : Bewegingsservice is geactiveerd....' .. '<br>' .. dz.devices('timerlog').text
switch0.updateText(timertekst)
elseif ((item.isTimer and item.trigger == groupOffTimer1 and switch2.state == 'Unlocked') or (item.isDevice and device.state == 'Off')) then
if item.isTimer then
switch3.switchOff().checkFirst()
end
osExecute('sudo /etc/init.d/motion stop')
dz.log("Script: " .. info.scriptName .. " Bewegingsservice is gedeactiveerd....", dz.LOG_INFO)
timertekst = dz.time.rawDate .. ' ' .. dz.time.rawTime .. ' : Bewegingsservice is gedeactiveerd....' .. '<br>' .. dz.devices('timerlog').text
switch0.updateText(timertekst)
else
dz.log("Script: " .. info.scriptName .. " Bewegingsservice blijft aan, waarschijnlijk met vakantie....", dz.LOG_INFO)
timertekst = dz.time.rawDate .. ' ' .. dz.time.rawTime .. ' : Bewegingsservice blijft aan, waarschijnlijk vakantie....' .. '<br>' .. dz.devices('timerlog').text
switch0.updateText(timertekst)
end
end
}