Implementation Files and Callbacks

I am a bit stumped and all the spaghetti that I have thrown against the wall has not stuck. I am trying to make an Ajax call to the Vera from my configuration tabs. I put a register_callback in my initialization code that I would have expected to be called when I perform my Ajax call.

for instance I called luup.register_handler(“connectionHandler”, “GetConnectionData”)

then in the lua function connectionHandler I returned a json with the connection information. However, the Ajax call “lr_GetConnectionData” returns 200-OK with response text of “No Handler.” I have tried to put an tag in my implementation file I_xxxxx.xml with a tag but it makes no difference. My connectionHandler function never gets called.

The data I need to return has already been acquired so I don’t need to perform any job gymnastics or asynchronous callbacks. I simply need to return some state info from my plugin.

What am I missing? Is there something that needs to be placed in my service file S_xxxxx.xml or should I be making mac-n-cheese in lieu of the spaghetti?

You don’t need to use an action for this. You should call luup.register_handler(…) in your startup code. The handler function should be global. The calling command should be:


Is your code in the I_XXX.xml file ?
If so make sure it’s global.

If it’s in an L_XXX.lua file that you load, the function is NOT global … it’s global in the table XXX.
In that case inside your init code you need:
_G.connectionHandler = connectionHandler

@RexBeckett – Thanks the rabbit hole was going nowhere and I wasn’t sure what the downstream effects were. I suppose I could rant about unclear documentation but how does one document what I don’t need based upon me throwing pasta around.
@RichardTShaefer – My code is in a L_AutelisPentair.lua file. I got the feeling the function was out of scope. I just couldn’t figure out how to get it into scope. Putting a _G.connectionHandler = connectionHandler in the startup code solved the issue. btw: Are you saying that there is a table in the global execution scope that is called AutelisPentair out there? Thanks.

A LUA file (structured as a module and loaded by Vera) creates a Table that contains the global functions and data in that LUA file.

In the following example … L_ProgramLogicCCP.lua is one of the files from my plugin.

Lua 5.1.4  Copyright (C) 1994-2008, PUC-Rio
> require("Dump")
> require("L_ProgramLogicCCP")
> print(L_ProgramLogicCCP)
table: 0081D760
> print(dump(L_ProgramLogicCCP, 1))
{ ["GetData"] = function: 0033A200,["_NAME"] = L_ProgramLogicCCP,["_PACKAGE"] = ,["Parse"] = function: 0033AAC8,["_M"] = { ["GetData"] = function: 0033A200,["_NAME"] = L_ProgramLogicCCP,["_PACKAGE"] = ,["Parse"] = function: 0033AAC8,["_M"] = *table*,["PutData"] = function: 0033A1E0,["Reset"] = function: 0033A1C0,} ,["PutData"] = function: 0033A1E0,["Reset"] = function: 0033A1C0,} 

The file starts out with:

module("L_ProgramLogicCCP", package.seeall)

What’s in the table are GLOBAL functions in that file.