how to unregister a variable_watch callback

We are using variable_watch to register a callback with LUUP interface and get a notification when the variable changed.
This is working fine.

But we have a concern when we re-register the same variable with the LUUP for the same “function”.
Lets say we have a function [font=courier]handleVariableChange[/font]
and we have a Security sensor whose variable “Armed” has been registered with this handleVariableChange function…

[font=courier]luup.variable_watch(“handleVariableChange”, “urn:micasaverde-com:serviceId:SecuritySensor1”, “Armed”, device_id_of_security_sensor)[/font]

Now, when the code is restarted, we would automatically call the luup.variable_watch function once again…
And now if the variable changes, we get 2 call backs to the same function…

If we restart code once more (i.e register once more for variable_watch function… We get one more callback (i.e the same function gets called 3 times).

We want to avoid this…

Will the variable_watch function be fixed to not register a duplicate callback for the same function/schema/variable/device_id combination.
Is there a way to un-register this callback that was issued to variable_watch, and calling this function will remove the callback that is currently registered…

Any suggestions please…

Thanks in advance…

Will the variable_watch function be fixed to not register a duplicate callback for the same function/schema/variable/device_id combination.

I’ve never heard of any fixes to the Luup Lua extensions. The following Luup Lua extensions are defective:

[ul][li]luup.timezone[/li]
[li]luup.blacklistip[/li]
[li]luup.device_supports_service[/li]
[li]luup.sleep[/li][/ul]

… and there is no Luup method to un-watch/remove a variable, Luup timers don’t support UTC, …

So I’m afraid you’re on your own. You could write a wrapper for [tt]luup.variable_watch[/tt] that makes sure that [tt]luup.variable_watch[/tt] doesn’t get called twice with the same set of parameters.

AFAIK watching a variable doesn’t survive a LuaUPnP restart/reboot.