Door lock -- warn not locked when setting 'away'

Hello,

I get an error when I tried my first luup. Can anyone assist? I don’t really get any error info, just a red blob that says luup code error when I try to save…

– Inform me if I forgot to lock the door.
local lul_lock = luup.variable_get(“urn:upnp-org:serviceId:Doorlock”,“Status”, 3)
if (lul_lock == ‘0’) then
luup.inet.wget(“http://www.prowlapp.com/publicapi/add?apikey=999..................9999&application=Vera&event=Armed&description=Lock+the+door&priority=1”)
return true

Hello haveitall,

Here is the corrected code:

-- Inform me if I forgot to lock the door.
local lul_lock = luup.variable_get("urn:micasaverde-com:serviceId:DoorLock1", "Status", 3)
if (lul_lock == '0') then
    luup.inet.wget("http://www.prowlapp.com/publicapi/add?apikey=999..................9999&application=Vera&event=Armed&description=Lock+the+door&priority=1")
end
return true

So, teach a man to fish…

Material Changes:
urn:micasaverde-com vice urn:upnp-org (This appears to be the device_type in the Doorlock device that I have…urn:schemas-micasaverde-com:device:DoorLock:1)
Add a 1 to the name because of the above

Cosmetic:
Add end

Thanks for the help!

Sorry for not being more verbose, I was in a hurry.

The service ID and the state variable names are case sensitive. Doorlock is different from DoorLock.

In Lua you must put end at the end of every block, even if there’s only one instruction in that block, so it’s not cosmetic.

awsome! thanks!

This is what I’ve got…

[code]local lul_lock = luup.variable_get(“urn:schemas-micasaverde-com:device:DoorLock:1”, “Status”, 15)
if (lul_lock == ‘0’) then

luup.inet.wget(“http://www.prowlapp.com/publicapi/add?apikey=xxxxxxxxxxxxxxxxxxxxx&application=Vera&event=Alert&description=Front+door+is+still+unlocked&priority=1”)
end
return true[/code]

Haveitall, does this jive with what you ended up with?

Did @mcvflorin’s code not work? (I think @haveitall asked @mcvflorin to explain the reason behind the changes to @haveitall’s code.)

I’m confused because of havitall’s “teach a man to fish” post, which shows a difference in one line, so I thought he ended up using this:
local lul_lock = luup.variable_get(“urn:schemas-micasaverde-com:device:DoorLock:1”, “Status”, 3)

instead of this:
local lul_lock = luup.variable_get(“urn:micasaverde-com:serviceId:DoorLock1”, “Status”, 3)

…note the two differences I’m trying to clarify. I believe the RED should be the FIRST version… unsure about the green. Thanks…

It should be the second one with out the colon before the number 1.

  • Garrett

I’m confused because of havitall’s “teach a man to fish” post, which shows a difference in one line, so I thought he ended up using this:
local lul_lock = luup.variable_get(“urn:schemas-micasaverde-com:device:DoorLock:1”, “Status”, 3)

instead of this:
local lul_lock = luup.variable_get(“urn:micasaverde-com:serviceId:DoorLock1”, “Status”, 3)

…note the two differences I’m trying to clarify. I believe the RED should be the FIRST version… unsure about the green. Thanks…[/quote]

This is the correct syntax to get the variable:

local xxxxxx = luup.variable_get(“urn:micasaverde-com:serviceId:DoorLock1”, “Status”, 3)

[quote=“CMRancho, post:10, topic:169511”]This is the correct syntax to get the variable:
local xxxxxx = luup.variable_get(“urn:micasaverde-com:serviceId:DoorLock1”, “Status”, 3)[/quote]
Great–thanks!

That post is not a correction to @mcvflorin’s code, but only lists the deltas and asks @mcvflorin (the teacher) why those changes had to be made. Which @mcvflorin explains in the next post.