Page 1 of 1

LUA script for logging

Posted: Wednesday 18 October 2017 18:45
by Slinkos
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:

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
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.

Re: LUA script for logging

Posted: Thursday 19 October 2017 18:04
by jannl
Not sure why you want to do that. I never have had any false positives on any of my pir's. X10 or zwave.

Re: LUA script for logging

Posted: Thursday 19 October 2017 22:19
by Slinkos
Well, I have

Re: LUA script for logging

Posted: Thursday 19 October 2017 22:21
by jannl
I think you better find out why you have false positives. May be bad location of the pir. Sudden heat flows or so

Re: LUA script for logging

Posted: Friday 20 October 2017 11:01
by Slinkos
Please just answer my question, this is not helping me. Logging it may help me finding out what causes it.

Re: LUA script for logging

Posted: Friday 20 October 2017 11:22
by jannl
Logging is already present on Domoticz

Re: LUA script for logging

Posted: Saturday 21 October 2017 17:15
by Slinkos
But not the way I want it. If you don't know the answer that's fine. Then I hope someone else can reply.