LUA script for logging
Posted: Wednesday 18 October 2017 18:45
Hi all,
I have bought a PIR (Motion Sensor) and I want to monitor if it has false positives. So I was thinking to create a lua script that makes a separate log file somewhere, whenever my PIR is on and I am not home. It doesn't have to be readable within Domoticz, I'm fine with setting up a SSH connection and cat the logfile.
So I was thinking something like:
But my experience in LUA is zero, so this will probably be full with mistakes. I don't see any errors, but I also don't see any file being created in the folder specified. The event doesn't even seem to be triggered.
I hope someone can help. thanks in advance.
I have bought a PIR (Motion Sensor) and I want to monitor if it has false positives. So I was thinking to create a lua script that makes a separate log file somewhere, whenever my PIR is on and I am not home. It doesn't have to be readable within Domoticz, I'm fine with setting up a SSH connection and cat the logfile.
So I was thinking something like:
Code: Select all
commandArray = {}
if (devicechanged['PIR'] == 'On' and otherdevices['Home'] == 'Off') then
file = io.open("home/pi/domoticz/scripts/motionlog.txt", "w")
file:write(os.time "Motion detected while not home")
file:close()
end
return commandArray
I hope someone can help. thanks in advance.