Subscribe
Run code when one specific events starts or stops
Function
local disconnect = DeviceAPI.Subscribe(
eventId,
onStart,
onStop,
fireImmediately
)Parameters
Name
Type
Description
eventId
string
Event ID to listen for
onStart
function(payload)
Called when event starts
onStop
function(payload)
Called when event stops
fireImmediately
boolean
Fire immediately if event already active
Examples
local disconnect = DeviceAPI.Subscribe(
"911",
function(payload)
print("🚨 Lockdown started")
end,
function(payload)
print("✅ Lockdown ended:", payload.reason)
end,
true
)
disconnect()Last updated