Need help - lu_CallAction getting nil value

Here’s the function in the I_file

function Wake (index) local index = tonumber (index) local address = luup.variable_get ("urn:micasaverde-com:serviceId:Elk2Way1", "Address"..index, lug_device) lu_CallAction("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue="1" },address) end

Here’s the code for the action in the I_file.

urn:micasaverde-com:serviceId:Elk2Way1 Wake Wake(lul_settings.index)

Here’s the log:

JobHandler_LuaUPnP::HandleActionRequest argument rand=0.5213319717924586 <0x4c08> 01 01/23/13 1:59:44.032 LuaInterface::CallFunction-1 device 40 function SElk2Way_Elk2Way1_Wake_run failed [string "..."]:89: attempt to call global 'lu_CallAction' (a nil value) <0x4c08>

Thanks in advance.

You syntax is wrong:

http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_call_action

It should be luup.call_action

  • Garrett

Thanks Garrett. Problem solved.

I was working from this post:

[quote=“micasaverde, post:4, topic:164553”]Did you see the sample here already: http://wiki.micasaverde.com/index.php/Luup_Scenes_Events

Turn an appliance switch on for device #5:
lu_CallAction(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“1” },5)

Turn an appliance switch off:
lu_CallAction(“urn:upnp-org:serviceId:SwitchPower1”,“SetTarget”,{ newTargetValue=“0” },5)

Do something if switch device #5 is on:
if( lu_GetVariable(“urn:upnp-org:serviceId:SwitchPower1”,“Status”,5)==“1” ) then
–something to do goes here
end

Dim switch #6 to 30%
lu_CallAction(“urn:upnp-org:serviceId:Dimming1”,“SetLoadLevelTarget”,{ newLoadlevelTarget=“30” },6)

Arm motion senor #7:
lu_SetVariable(“urn:micasaverde-com:serviceId:SecuritySensor1”,“Armed”,“1”,7)

Disarm:
lu_SetVariable(“urn:micasaverde-com:serviceId:SecuritySensor1”,“Armed”,“0”,7)

Note, arming and disarming isn’t a concept within UPnP or Z-Wave. It’s just a flag that the Luup engine uses, and is stored in a variable we created called “Armed”.

Run Scene #5:
lu_CallAction(“urn:micasaverde-com:serviceId:HomeAutomationGateway1”,“RunScene”,{ SceneNum=“5” })

In this case we left the device number off (the 4th parameter to lu_CallAction), because the “RunScene” action is handled by the Luup engine itself–not by some device within Z-Wave, etc.[/quote]

I did read the link showing the code of samples and luup.call_action. I stuck with lu_CallAction because the title and text of the sample page only refers to scenes. Obviously it applies to plugins also but that is never mentioned.

I don’t have privileges to edit the wiki so perhaps if an admin reads this it can be edited so others don’t make the same rookie mistake. I’m learning lua/programming via trial and error and that would have saved me hours. Perhaps they can delete or edit the post above that lead me on this snipe hunt as well.

Thanks again.