Luup - run on door sensor triggered

Hi everyone!

I had a luup code running smoothly for months, after update to Vera 1.7.4903 (7.31) it stopped. It is fragment of my code:

-- DRZWI
function czujnikDrzwiOff()
      luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget", {newTargetValue = "0"}, 24) -- przedpokoj2
end
function czujnikDrzwi(device, service, variable, lastvalue, newvalue)
  if (newvalue== "1") then
      local status, mode = luup.inet.wget("http://127.0.0.1:3480/data_request?id=variableget&Variable=Mode",0)
      if (tonumber(mode)==2) then
         luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="100" }, 48) -- roleta salon
         luup.call_action("urn:upnp-org:serviceId:Dimming1","SetLoadLevelTarget",{ newLoadlevelTarget="100" }, 35) -- roleta kuchnia 
         luup.call_action("urn:micasaverde-com:serviceId:HomeAutomationGateway1","SetHouseMode", {Mode = 1}, 0)
      end
      luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget", {newTargetValue = "1"}, 24) -- przedpokoj2
  else
      luup.call_delay( 'czujnikDrzwiOff', 120)
  end
end
luup.variable_watch("czujnikDrzwi","urn:micasaverde-com:serviceId:SecuritySensor1","Tripped",82)

I think that something is wrong with variable_watch. Can anyone say if it is ok for new version? For now i see that my door sensor is recognized as ‘DoorSensor’ - not ‘SecuritySensor’.

You should look in the LuaUPnP log for error messages. Just eyeballing it, it seems fine. If there were big problems with variable_watch(), a lot of things wouldn’t work, including Reactor.

To my eye, your wget is suspect. I dislike that API, and it’s not an efficient way to retrieve the current house mode. You can luup.attr_get( "Mode", 0 ) instead.