I’m trying to write some luup code, what I want to do is this:
- wait 30 seconds
- if door sensor is armed - set siren (dimmable switch) to 100%
- wait 30 seconds
- 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!