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:

function czujnikDrzwiOff()
      luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget", {newTargetValue = "0"}, 24) -- przedpokoj2
function czujnikDrzwi(device, service, variable, lastvalue, newvalue)
  if (newvalue== "1") then
      local status, mode = luup.inet.wget("",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)
      luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget", {newTargetValue = "1"}, 24) -- przedpokoj2
      luup.call_delay( 'czujnikDrzwiOff', 120)

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.

Best Home Automation shopping experience. Shop at getvera!

© 2021 Ezlo Innovation, All Rights Reserved. Terms of Use | Privacy Policy | Forum Rules