Code check please

I would like to start by first thanking Rex for his excellent tutorial - I tend to think in a more serially than abstractly which tends to lock me up when trying to figure out how to code something new. The examples have been a great help so far.

I have been lurking a while and the following code is based on what I have read from http://wiki.micasaverde.com/index.phpLuup_Scenes_Events, http://forum.micasaverde.com/index.php/topic,18679.msg154756.html#msg154756 and the sticky at the top of this board. Here is where I am stuck. I have a scene where my Insteon door sensor (using the native Vera Insteon code, not Altsteon) will enter a triggered state, whenever the sensor is armed or not, so when the sensor arms, I get alerts. I would like to set some luup code in a scene so that when the sensor trips, the luup waits 5 or 10 seconds (to filter out “reed switch bounces”), then resets to a value of “Tripped” = 0. Here is what i have so far:

luup.call_delay("delayReset",10)
-- Main code terminates at this point

-- Function to be called after delay --21 is my Insteon Sensor device number
function delayReset()
     luup.call_action("urn:schemas-micasaverde-com:device:MotionSensor:1","SetVariable",{ newVariableValue=0 },21)
end

My questions are:

  1. How can I debug this to get feedback? When I test in the Develop Apps area, I get “Failed to test code, please try again” which is not very helpful as to a cause.
    and
  2. Do you see any obvious problems / better ways to solve this issue?

Thanks - any help is appreciated!
Sleepyhat

That call_action does not look right … Where did you come up with this ?

Actions need to be defined by MCV or the developer for the device.

See:
http://wiki.micasaverde.com/index.php/Luup_Requests

I agree that the call_action statement does not look correct.

As far as debugging goes, I often use the “kwiklog” routines. I would place a kwiklog statement before and after the problematic code, and dump out any variables that are relevant.

You can see how to use kwiklog here (thread created by RexBeckett):

http://forum.micasaverde.com/index.php/topic,18679.msg162670.html#msg162670