Skip to content

Scripting

e1z0 edited this page Jun 18, 2025 · 1 revision

Simple loop test

for i = 1, 50 do
    Log("Script says count: " .. i)
end

BlueIris MQTT Subscribe topic example (Topic have data 1 or 0)

function on_start()
    SubscribeToMqtt("BlueIris/Camera/Status", "on_mqtt_message")
end

function on_mqtt_message(payload)
       Notify("Camera","Person detected",5000)
       Log("Received MQTT: " .. payload)
end

on_start()

-- Prevent script from exiting
while Running() do
    Sleep(1000)
end

if Log ~= nil then
    Log("Lua script finished cleanly.")
end

Notification based on MQTT

function on_start()
    SubscribeToMqtt("anotherrtsp/testas1", "on_mqtt_message")
end

function on_mqtt_message(payload)
    Notify("MQTT",payload,5000)
    Log("Received MQTT: " .. payload)
end


on_start()

-- Prevent script from exiting
while Running() do
    Sleep(1000)
end

if Log ~= nil then
    Log:WriteLog("Lua script finished cleanly.")
end

Balloon notify based on MQTT

function on_start2()
    SubscribeToMqtt("anotherrtsp/testas2", "on_mqtt_message2")
end

function on_mqtt_message2(payload)
    BalloonTip("MQTT",payload, "Info" ,5000)
    Log("Received MQTT: " .. payload)
end

on_start2()

-- Prevent script from exiting
while Running() do
    Sleep(1000)
end

if Log ~= nil then
    Log:WriteLog("Lua script finished cleanly.")
end

Sound notify based on MQTT

function on_start()
    SubscribeToMqtt("anotherrtsp/testas3", "on_mqtt_message")
end

function on_mqtt_message(payload)
    Sound("battle1_")
end

on_start()

-- Prevent script from exiting
while Running() do
    Sleep(1000)
end

if Log ~= nil then
    Log("Lua script finished cleanly.")
end

Multiple mqtt topics subscribe (different notification options)

function on_start()
    SubscribeToMqtt("anotherrtsp/testas1", "notif")
    SubscribeToMqtt("anotherrtsp/testas2", "bln")
    SubscribeToMqtt("anotherrtsp/testas3", "snd")
end

function notif(payload)
    Notify("MQTT",payload,5000)
    Log("Received MQTT: " .. payload)
end

function bln(payload)
    BalloonTip("MQTT",payload, "Info" ,5000)
    Log("Received MQTT: " .. payload)
end

function snd(payload)
    Sound("battle1_")
end

on_start()

-- Prevent script from exiting
while Running() do
    Sleep(1000)
end

if Log ~= nil then
    Log:WriteLog("Lua script finished cleanly.")
end
Clone this wiki locally