Getting started with plugins [BETA]

Moderator: Telldus

kamsvag
Posts: 67
Joined: Thu Jan 18, 2018 11:08 am

Re: Getting started with plugins [BETA]

Post by kamsvag » Thu Jan 02, 2020 12:12 pm

There's no need to pull data as you say. Use my SUS-plugin along with a LUA-script and all your device updates on the Tellstick will be forwarded using UDP to your predefined IP and port.

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

Post Reply