Help with Garage door status and Vera Alert message

Hi folks,
I need some coding help please. I’m trying to send a message that states whether the garage door is up or down when motion is detected by the tilt sensor.
This is as far as I have got. Can anyone help me out getting the ArmedTripped variable value into the message (ideally as up/down rather than 0 or 1)

[code]local ArmedTripped = luup.variable_get(“urn:schemas-micasaverde-com:device:MotionSensor:1”,“ArmedTripped”,79)
– ArmedTripped “1” (Door Up) or “0” (Door Down)

luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”, {Message = “Garage door is ArmedTripped - Up/Down at {DateTime(CurrentTime,%A %B %d, %Y at %H:%M)}”, Recipients = “me”}, 16)[/code]

I tried this instead - but it only sends the ‘else’ response - no matter what the ArmedTripped value is …
Any clues?

[code]local GTripped = luup.variable_get(“urn:schemas-micasaverde-com:device:MotionSensor:1”,“ArmedTripped”,79)
– ArmedTripped “1” (Door Up) or “0” (Door Down)

if (GTripped == “1” ) then
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”, {Message = “Garage door is Up at {DateTime(CurrentTime,%A %B %d, %Y at %H:%M)}”, Recipients = “me”}, 16)

else
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”, {Message = “Garage door is Down at {DateTime(CurrentTime,%A %B %d, %Y at %H:%M)}”, Recipients = “me”}, 16)

end[/code]

You are using a device ID instead of a service ID in your call to luup.variable_get … so it is returning nil

Thanks Richard,

I changed to this but it still doesn’t work logically. It doesn’t seem to get the variable - which is set to 1.

Have I missed anything else?

[code]local GTripped = luup.variable_get(“urn:upnp-org:serviceId:MotionSensor1”, “ArmedTripped”, 79)
– ArmedTripped “1” (Door Up) or “0” (Door Down)

if (GTripped == “1” ) then
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”, {Message = “Garage door is Up at {DateTime(CurrentTime,%A %B %d, %Y at %H:%M)}”, Recipients = “me”}, 16)
else
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”, {Message = “Garage door is Down at {DateTime(CurrentTime,%A %B %d, %Y at %H:%M)}”, Recipients = “me”}, 16)
end[/code]

Still the wrong service ID.
You can find the right service id for ANY variable as follows:

  1. Go to the Advanced Tab of the Device your are interested in.
  2. Let your mouse Hover Over the Name (lower left side of panel)
    A popup will show the correct Service ID for that variable.

Thanks again Richard.
All working now. :slight_smile: What is the syntax to add the variable value into the body of the (Pushover) message?

[code]local TiltTripped = luup.variable_get(“urn:micasaverde-com:serviceId:SecuritySensor1”, “ArmedTripped”, 79)
– ArmedTripped “1” (Door Open) or “0” (Door Closed)
–wait 5 seconds
luup.call_delay (“switch_off”,5, “”)
function switch_off (empty)

if (tonumber(TiltTripped) == 1) then
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”, {Message = “Garage opened at {DateTime(CurrentTime,%H:%M on %A %B %d, %Y)}”, Recipients = “me”}, 16)
else
luup.call_action(“urn:richardgreen:serviceId:VeraAlert1”, “SendAlert”, {Message = “Garage closed at {DateTime(CurrentTime,%H:%M on %A %B %d, %Y)}”, Recipients = “me”}, 16)
end
end[/code]

If you are doing things in LUA … just customize the string before you call the Vera Alert action.

Are you referring to Vera Alert Template support ?

Then something like:

{device([16].Security.ArmedTripped) | Choose(0=Closed,1=Open,Other=Unknown)}
or
{device([16].service[urn:micasaverde-com:serviceId:SecuritySensor1].ArmedTripped) | Choose(0=Closed,1=Open,Other=Unknown)}

See the example files:
veraTemplateTest
veraTemplateDefinitions (Used to define the Short Service identifications!, i.e. the first example)