LUA script for logging

Moderator: leecollings

Post Reply
Slinkos
Posts: 81
Joined: Thursday 10 December 2015 0:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

LUA script for logging

Post 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.
jannl
Posts: 666
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: LUA script for logging

Post 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.
Slinkos
Posts: 81
Joined: Thursday 10 December 2015 0:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: LUA script for logging

Post by Slinkos »

Well, I have
jannl
Posts: 666
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: LUA script for logging

Post 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
Slinkos
Posts: 81
Joined: Thursday 10 December 2015 0:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: LUA script for logging

Post by Slinkos »

Please just answer my question, this is not helping me. Logging it may help me finding out what causes it.
jannl
Posts: 666
Joined: Thursday 02 October 2014 6:36
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.2
Location: Geleen
Contact:

Re: LUA script for logging

Post by jannl »

Logging is already present on Domoticz
Slinkos
Posts: 81
Joined: Thursday 10 December 2015 0:21
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.4834
Location: Netherlands
Contact:

Re: LUA script for logging

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

Who is online

Users browsing this forum: No registered users and 1 guest