• 10 dec 2017: forum version update. In case of issues use this topic.
  • 30 nov 2017: pilight moved servers. In case of issues use this topic.
Hello There, Guest! Login Register


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Ideas Wanted Decision Matrix
#31
(03-11-2019, 04:04 PM)felfert Wrote: Regarding this error:

Code:
root@raspberrypi:/usr/local/lib/pilight/functions# lua testmod.lua oktovent 20 30 23 25
lua: testmod.lua:1: attempt to call field 'pack' (a nil value)
stack traceback:
        testmod.lua:1: in main chunk
        [C]: ?

The pack() function was introduced in lua 5.2.x. So: obviously you have an older lua. (My PC runs Fedora19 which provides a newer - current - lua). On the raspberry, there's only lua 5.1.5. You can print your lua version by running:

Code:
[felfert@fritz ~]$ lua -v

Lua 5.3.5  Copyright (C) 1994-2018 Lua.org, PUC-Rio


Sorry for the inconvenience. Here is a new testmod.lua which is backward-compatible to lua 5.1.x (as found on my raspian "Raspbian GNU/Linux 9 (stretch)"):

Code:
local args = {...}
local argc = select('#', ...)
if (argc < 1) then
    error("testmod requires at least a module name")
end
print(string.format("Testing module %s", args[1]))
m = require(args[1])
print(m .run(select(2,...)))

Great, this testmod is working. So there is probably a Problem with the rule itself, so that pilight is doing Nothing.

If I understand the Manual in the Right way, there should be a comparsion of Arguments:

Code:
"IF oktovent (x,x,x,x) == true, THEN...

But pilight is doing nothing, although testmod Returns true.

@ Curlymo: How will the right Syntax look alike?

PS:A big "Thank you" to felfert!! I wish, I could understand lua…;-)
 
Reply
#32
I would suggest to stop the pilight service and then run pilight-daemon manually with full debugging:
Code:
pilight-daemon -D

If your rule is used, then an indicator would be seeing something like this:


Code:
[ Mar 11 16:58:15:56886] pilight-daemon: DEBUG: rule #2 rBS2 was parsed in 0.153525 seconds

Your rule number and name are different of course.
Unfortunately there are almost no debugging/logging facilities for lua modules existing in pilight.

@curlymo:
It would be really cool to have logging available in lua. E.g: access to logprintf(verbosity, string) Smile
Unfortunately, I don't understand the lua integration code  sufficiently enough to create a PR  Crying
I also tried writing to stdout and stderr in lua without luck. Apparently, those are closed (most likely in daemonize())

Cheers
 -Fritz
 
Reply
#33
True, logging inside lua is working in progres.
 
Reply
#34
Somehow, magic did happen.

After doing some configuration stuff, the lua script gets magically executed in my lab area and everything seems to work great!

Now I´m going to Phase 2 "Onsite testing"

A big Thank you to felfert!
 
Reply
  


Forum Jump:


Browsing: 1 Guest(s)