This is an old revision of the document!


IoT Home Automation

Platform

Installation

Download latest Raspbian image:

sudo raspi-config sudo apt-get update sudo apt-get upgrade

Wireless sensors

WT450H temperature and humidity transmitter and TellStick Duo USB receiver/transmitter.

Installation

There are many alternative installation instructions for telldus-core in the net. This one is proven to work with Debian in Raspberry Pi and BeagleBone Black: http://www.telldus.com/forum/viewtopic.php?f=15&t=3960

sudo su
echo "deb-src http://download.telldus.com/debian/ stable main" >> /etc/apt/sources.list
wget -q http://download.telldus.se/debian/telldus-public.key -O- | sudo apt-key add -
apt-get update
apt-get build-dep telldus-core
apt-get install cmake libconfuse-dev libftdi-dev help2man
apt-get --compile source telldus-core
dpkg --install *.deb

Test installation:

tdtool -l

Message broker

Installation

Install MQTT Broker:

sudo apt-get install mosquitto mosquitto-clients
(sudo apt-get install nodejs npm)

In order to install td-mqtt-bridge, node needs to be upgrades: http://joshondesign.com/2013/10/23/noderpi.
Then install Telldus-MQTT bridge: https://www.npmjs.org/package/td-mqtt-bridge

npm install td-mqtt-bridge --registry http://registry.npmjs.org
sudo npm install -g forever --registry http://registry.npmjs.org

Telldus to MQTT Bridge

Simple node.js bridge compatible with GaianDB and JSON databases. Requirements: net, mqtt.

npm install mqtt
var net = require('net');
var mqtt = require('mqtt');

var lasttime = 0, lastid = 0;

var publisher = mqtt.createClient(1883,'localhost');
var telldus = net.createConnection('/tmp/TelldusEvents');
telldus.setEncoding('utf-8');

telldus.on('connect' , function () {
    console.log("Connected to Tellstick.");
});

telldus.on('data', function(data) {
    var pos = data.indexOf("TDRawDeviceEvent");
    if (pos > -1)
    {
	var jarr={}, keyval=[];
	var arr = data.substr(data.indexOf(":",pos)+1).split(";");
	for (var i=0; i<arr.length; i++) {
	    keyval[i] = arr[i].split(":");
	    if ( parseFloat(keyval[i][1]))
		jarr[keyval[i][0]] = parseFloat(keyval[i][1]);
	    else
		jarr[keyval[i][0]] = keyval[i][1];
	}
	if ( keyval[0][1] == "sensor" )
	{
	    // prevent duplicates
	    var now = new Date().getTime();
	    if (jarr.id != lastid || now > lasttime+1000)
	    {
		var jsonstr = JSON.stringify(jarr);
		var gdbstr = "sensor";
		for (var i=1; i<keyval.length-1;i++)
		    gdbstr += ", "+keyval[i][1];
//		console.log(jsonstr);
//    	        publisher.publish("json/sensor/telldus",jsonstr);
		console.log(gdbstr);
		publisher.publish("gdb/sensor/telldus",gdbstr);
		
		lastid = jarr.id;
		lasttime = now;
	    }
	}
    }
});
iot_ha.1408567299.txt.gz · Last modified: 2014/08/20 23:41 by jap
Recent changes RSS feed CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki