akbooer,
I was hoping you might be able to help me solve a problem I am having. Event Watcher is installed and working well, writing its logs to the /dataMine/EventWatcher/ folder as described in your documentation. Where I am struggling is with writing events to the log. Your documentation uses this bit of code:
local function myEvent (text)
local url = require "socket.url"
luup.inet.wget ("http://127.0.0.1:3480/data_request?id=lr_EventWatcher&event=" ..
url.escape(text))
end
which I believe may be a little outdated. I am on UI7 with a Vera Secure. (1.7.3233) The current code to access the data is on my machine (192.168.0.11) is:
http://192.168.0.11/port_3480/data_request?id=lr_EventWatcher&report=log
This works perfectly, but notice the difference in how the port is defined. All following code uses this basic approach.
What I want to do is to be able to write to the log from within PLEG, using the LUA code in the Logic Action. I can successfully write one line of data using this code:
luup.inet.wget ("http://192.168.0.11/port_3480/data_request?id=lr_EventWatcher&event=Something_Happened")
but would like to expand on this with a function that includes URL encoding. I have placed the following code in the LUA startup section of the PLEG instance:
local function EWLogIt (text)
local url = require "socket.url"
local text = "HVAC PLEG" .. url.escape(text)
luup.inet.wget ("http://127.0.0.1/port_3480/data_request?id=lr_EventWatcher&event=" .. text)
end
and am calling the function in the LUA code of the associated action within that PLEG instance using:
EWLogIt "Something happened"
The ultimate goal is to add the start-up code to each of my 4 instances of PLEG, changing the prefixed text to reflect each PLEG, and log specific data to the Event Watcher log. Having a log written to USB allows all logged data to survive a restart, which is a huge advantage in my opinion. Using a function reduces code overhead, simplifies coding changes and makes the call to the function universal. As I understand it, each PLEG uses its own startup functions so calls to the function are local to that instance.
Unfortunately, this does not work. In my mind there are several possibilities; 1) The function is not being called correctly; 2) The function is not defined correctly (Global vs Local?); 3) There is a syntax error in the code or 4) What I am trying to do is simply not possible in this situation. I believe that the code is correct and that this should be possible so I am at a loss for why it does not work.
I thank you for all the work you have done with your plug-ins and hope that there is a simple solution to my problem