I am on a rough ride learning how to write plugin. I have this Iphone tracker plugin kind of running but I struggle a lot with uPNP actions. I am basically trying to add a simple parameterless action called “ManualRefresh” in my service file
Same result with this. I removed my ManualRefresh action and now NONE of my action are working any more. SetPresent action fails also
01 09/30/13 0:13:52.453 e[31;1mLuaInterface::CallFunction_Job device 83 function SIPhone_IPhoneLocator1_SetPresent_run failed attempt to call a nil valuee[0m <0x30145680>
You don’t indicate how you’re calling this ACTION, so I’ll make some assumptions (below). To improve the accuracy of guesses, you’ll need to provide more of the log file, and be running in “Verbose” (debug) mode when those logs are captured. This will let folks see, for example, what parameters are being passed, and what values are coming with those parameters.
Guess 1…
You didn’t pass the parameter for the new status. When parameters aren’t passed, the [tt]lul_settings[/tt] variable is nil, so deref’ing it will give you a NPE issue.
Guess 2…
You passed it, but using incorrect case. Parameter names are case sensitive.
Side-note(s):
a) the Getter ACTIONS aren’t going to do anything meaningful, since MiOS defines no mechanism for them to return state.
I’d recommend you start this effort “small” and grow it, adding incrementally after validation that each piece works… it’ll definitely save you frustration in the long run…
You can also bench test some of the library functions completely outside of Vera, when you’re ready for that.
b) You’ll want an Isolated namespace, not “upnp-org” for your ServiceID’s.
The oldest plugins used to do that, but it was a bad habit. Newer plugins all put their code in a non “UPNP” namespace, since its’ not ours to pollute.
Ok, so I tried a few different things, including nuking the TAB characters on some lines, in some files.
Eventually got it working. Problem appears to be the [tt][/tt] declaration that you’ve used.
When I simplify it down to:
<files>L_IPhone.lua</files>
Then the code appears to work correctly, at least in a test [tt]luup.call_action[/tt] block. In it’s original form (a CSV of two libs) then it fails. Since the first lib “requires” the second lib, it’ll load correctly anyhow.
Technically, you could avoid the declaration, and do a requires for both libs… which would also avoid the issue. Most other plugins do this, instead of the crazy MiOS “[tt][/tt]” tag, in order to support UI4 and UI5 (and be more Lua like)
PS: I also avoided calling the variables lul_*, in the test codeblock, but it shouldn’t make any difference.
My sincere and deep appreciation for your help. indeed it was it. it got me mad and finishing at 3am until I gave up and this morning I have the answer from you
Regarding your other comment on chosing uPNP service name, is there some kind of rules / guidelines for that ?
The UPnP spec gives the general form:
?urn:domain-name:serviceId:serviceID?
And indicates that “upnp-org” is reserved for approved stuff, so most people have (in newer plugins) used either their own domain or the one of the company that the device is from.
Best Home Automation shopping experience. Shop at Ezlo!