I have a Raspberry Pi running NodeRed listening for my incomming updates, and based on different criterias and the incomming messages NodeRed takes actions such as alarm, turning on/off lights based on rules, temperatures, RestAPI calls etc.
My Lua-script was based on a script by Fredrik Gullberg (link below) but reworked a couple of time but I'm sure you'll find it very similar;
https://github.com/telldus/tellstick-lu ... shover.lua
Code: Select all
function onInit()
local sus = require 'sus.Client'
if sus == nil then
print("Initcheck: SUS plugin is not installed")
return
else
print("Initcheck: SUS plugin is loaded")
sus:send{msg='Telldus LUA SUS is loaded'}
end
return
end
function onDeviceStateChanged(device, state, stateValue)
local sus = require 'sus.Client'
if state == 1 then
status = "ON"
elseif state == 2 then
status = "OFF"
end
report = device:name() .. " " .. status
print("Report: " .. report)
local ret = sus:send{msg="SUS " .. report}
end