Guys, silly question... but I can't seem to find the answer

I’m trying to write some luup code, what I want to do is this:

  1. wait 30 seconds
  2. if door sensor is armed - set siren (dimmable switch) to 100%
  3. wait 30 seconds
  4. if door sensor is still armed - set siren (dimmable switch) to 20%

I am not sure, how do you guys get the device service ID?
When I go to the device advanced settings I see “device_type”, but when I see code examples it is using something different, like service ID. Where do I get this from?

Also, while you at it - perhaps you can take a look at my code and tell me if I am in the right direction?

– set a delay of 30 seconds, start full alarm if system is still armed,
– reduce to light after 30 more seconds
local DELAY = 30 – 30 seconds for each delay
local FULL_ALARM = 100
local Silent_Alarm = 20
local DOOR_SENSOR = “urn:schemas-micasaverde-com:device:DoorSensor:1” – ???
local Red_Siren = “urn:schemas-upnp-org:device:DimmableLight:1” – ???
local FRONT_DOOR_ID = 4
local Red_Siren_ID = 103

luup.call_delay( “SoundTheAlarm”, DELAY)

function SoundTheAlarm()
local IsArmed = luup.variable_get( DOOR_SENSOR, “Armed”, FRONT_DOOR_ID) or “0”
if( IsArmed ) then
luup.variable_set( Res_Siren, “LoadLevelTarget”, FULL_ALARM, Res_Siren_ID)
luup.call_delay( “BackToSilentAlarm”, DELAY)
end
end

function BackToSilentAlarm()
local IsArmed = luup.variable_get( DOOR_SENSOR, “Armed”, FRONT_DOOR_ID) or “0”
if( IsArmed ) then
luup.variable_set( Res_Siren, “LoadLevelTarget”, Silent_Alarm, Res_Siren_ID)
end
end

Thanks!

[quote=“sirpinky, post:1, topic:180257”]I am not sure, how do you guys get the device service ID?
When I go to the device advanced settings I see “device_type”, but when I see code examples it is using something different, like service ID. Where do I get this from?[/quote]

If you hover over the variable name (in the Advanced tab) then a tooltip pop-up should show you the serviceId.

Thanks, will try.

BTW, I was able to complete my scenario with no code using the very cool plugin “Countdown Timer”

Door sensor trigger - starts the timer
Sound the alarm scene - triggers when timer complete
Disarm scene - stops the timer

My alarm is now complete with no coding at all!

Well that, of course, is the best outcome. Not always possible, though, so hopefully this will be useful another time.

A Vera device implements a set of services. Two variables for a single device can be associated with different services.

To get a complete list of the service IDs and variables for a device, first find the device number in the advanced settings. (Click the wrench in the upper-right corner of the device.) Then enter the following URL in a web browser, where x.x.x.x is your Vera console IP address, and N is the device number:

[font=courier]http://x.x.x.x:3480/data_request?id=status&output_format=xml&DeviceNum=[i]N[/i][/font]

that is a nice tool, but as akbooer points out, it is as easy as hovering over the variable you are interested in working with as attached