We have moved at community.getvera.com

Author Topic: Help on coding "local" variables?  (Read 2180 times)

Offline Henk

  • Hero Member
  • *****
  • Posts: 820
  • Karma: +3/-0
Help on coding "local" variables?
« on: July 04, 2011, 02:09:22 pm »
I have been experimenting with adding local variables to a working piece of luup code to make it more accesible for other users.

After studying the Wiki on luup, particularly these pages:
http://wiki.micasaverde.com/index.php/Luup_Variables  &
http://wiki.micasaverde.com/index.php/Lua_tips

I came as far as this with the variables (without using global variables) using the "hold on to your locals" tips

The working code is:
Code: [Select]
function ScreenOpen()
   luup.call_action("urn:upnp-org:serviceId:WindowCovering1","Up",{ },27)
end
function ScreenStop()
   luup.call_action("urn:upnp-org:serviceId:WindowCovering1","Stop",{ },27)
end

luup.call_timer("ScreenOpen", 1 ,"1","","")
luup.call_timer("ScreenStop", 1 ,"24","","")

But now im stuck and the code wont run (scene kicks off, message sent, no reaction from the z-wave device)
Not working (test) code;
Code: [Select]
do
 local DeviceNumber1 = 27
 local Delay1 = "1"
 local Delay2 = "24"

 function ScreenOpen()
  luup.call_action("urn:upnp-org:serviceId:WindowCovering1","Up",{ },Devicenumber1)
 end
 
 function ScreenStop()
  luup.call_action("urn:upnp-org:serviceId:WindowCovering1","Stop",{ },Devicenumber1)
 end

 luup.call_timer("ScreenOpen", 1 ,Delay1,"","")
 luup.call_timer("ScreenStop", 1 ,Delay2,"","")
end

What am i doing wrong? Any help would be appreciated
| Vera2 @ UI4 1.1.1350 / 3.20 | Vera Lite @ UI5 | Vera 3 @ UI5 | 2x Merten  504519 | 1x Duewi  064374 | 1x Everspring SM103 doorbell mod |1 Y-cam IP cam | various LUUP plugins |

Offline mcvflorin

  • Administrator
  • Hero Member
  • *****
  • Posts: 1755
  • Karma: +11/-3
Re: Help on coding "local" variables?
« Reply #1 on: July 04, 2011, 02:41:12 pm »
I think the only thing wrong here it's that you declared the DeviceNumber1 with capital N, but you used it with small n (Devicenumber1).
« Last Edit: July 04, 2011, 02:50:20 pm by mcvflorin »

Offline guessed

  • Community Beta
  • Master Member
  • ******
  • Posts: 5301
  • Karma: +92/-22
  • Release compat is not a bolted-on afterthought
Re: Help on coding "local" variables?
« Reply #2 on: July 04, 2011, 02:43:46 pm »
Also, you can always run
    tail -f /var/log/cmh/LuaUPnP.log

Whilst you run it, and it'll give more clues as to the problem it's experiencing.... Albeit sometimes cryptic.

Offline Henk

  • Hero Member
  • *****
  • Posts: 820
  • Karma: +3/-0
Re: Help on coding "local" variables?
« Reply #3 on: July 04, 2011, 02:49:38 pm »
@guessed,

Thanks i will test that and post back if it works!
(*sigh* spaces, caps, csv... programming... argh ;-))

I think the only thing wrong here it's that you declared the DeviceNumber1 with capital N, but you used it with small n (Devicenumber1).

Also, you can always run
    tail -f /var/log/cmh/LuaUPnP.log

Whilst you run it, and it'll give more clues as to the problem it's experiencing.... Albeit sometimes cryptic.
| Vera2 @ UI4 1.1.1350 / 3.20 | Vera Lite @ UI5 | Vera 3 @ UI5 | 2x Merten  504519 | 1x Duewi  064374 | 1x Everspring SM103 doorbell mod |1 Y-cam IP cam | various LUUP plugins |