[userModule] TTNLoraWAN (discontinued)

Tips, Tricks and Scripts to enhance your home automation and workaround known device bugs, limitations and incompatibilities
Locked
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

[userModule] TTNLoraWAN (discontinued)

Post by pz1 »

Due to changes on the TTN side, this module no longer works. Since TTN is not (yet?) interested in standardisation of sensor data, I stopped developing this generic interface module.

Since TTN (understandably) abandoned their REST API, most of this recipe no longer makes sense.

Latest version: 0.0.3
Date: 20160330
Last tested with: v2.2.1-rc6
STATUS: Beta
Download: Github

userModule TTNLoraWAN

This module assumes some background knowledge of TheThingsNetwork. The next post gives some information about it

This module is a very simple, early demonstrator of how Lora-sensors can be read in ZWay. I have made a similar experimental setup in OpenRemote.
At the moment the module is very rigid. Quite a bit is hard coded at the moment. I may change that when more public Lora Sensors become available on TheThingsNetwork.
I do hope we can stimulate a necessary discussion in the TTN community on the representation of sensors. Right now it is pretty wild. I have seen temperature sensors named t, temp, temperature, etc. If these devices could publish some knowledge about themselves, like Z-Wave does, than inclusion and configuration would be a lot easier. Maybe (name,value,scale) would help.

warning: TTN is in early stage of development, so a lot may change, and the demo server may be off line etc.

Device configuration screen
ModuleTTNLora.PNG
ModuleTTNLora.PNG (21.98 KiB) Viewed 15255 times
Future of this module
Lora messages are generaly sent as encrypted messages (end to end encryption). The protocol is bound in pratice to sent not faster than one message every 6 seconds. So polling at the Zway end is not desirable. Especially not for alarm signals. So it seems better to capture (MQTT) messages somewhere earlier in the stream, in order to get the benefits of pushed status changes, and decryption on your local machine. TheThingsNetwork intends to have the architecture and first stable release fixed by Q1 2016. See also TTN Wiki on MQTT and NODE-RED
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userModule] TTNLoraWAN - background

Post by pz1 »

A couple of weeks ago an interesting "for the people and by the people"-project opened on Kickstarter: TheThingsNetwork.

It uses the long range LoRaWan technology. Potentially this is an interesting complementary technology to Zway, but also other home automation solutions. It can help you connect to sensors too far away for Z-Wave. It typically deploys low power remote battery driven sensors that can last for a couple of years.
This citizen maintained network is completely free and open source. Not only the software, but also the hatdware. No controlling companies. For example citizens and small comapnies set up a network covering Amsterdam in a matter of 6 weeks. The major focus of the Kickstarter project is to make a very low cost (~200 EURO) gateway. These gateways have a range in the order of 10km.

Do not confuse this network with internet. Some people do call in Internet 3. I think that is wrong. It is a slow but reliable and safe data network. It does interface using for example with http, so perfectly usable with ZWay.
For more detail see for yourself at the links I provided.

Additional usefull links
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userModule] TTNLoraWAN

Post by pz1 »

Capture.PNG
Capture.PNG (11.57 KiB) Viewed 15138 times
The time stamp on this widget reflects the time that I extracted the temperature value from the API data. Note the time that the measurement was actually retrieved from the Lora Sensor. That time is avalable in the time-element of the JSON. I would like that time value to appear in this widget.

Is it possible to update the widget time to the observation time from the JSON?

update20151121 On further thought I'll begin with not updating the vDev's if the timestamp hasn't changed.
I remain interested in an answer on the original question.
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userModule] TTNLoraWAN

Post by pz1 »

Updated the module to allow for user configurable polling interval and sensor selection path.
Thanks to PoltoS for some help with the code
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userModule] TTNLoraWAN

Post by pz1 »

Got a bit further with sending Messages using Node-RED (see refs in earlier post under this topic). Rasbian-Jessie releases are pre-loaded with Node-RED, which makes things easier. The manual is a bit confusing w.r.t running on Pi. Just start as stated in the beginning. Forget about the memory settings mentioned later. The November Jessie release has taken care of that.

Below is a flow that transfoms data from a MQTT stream into an UDP meessage that sends sensor data. In this case packaged as:

Code: Select all

{"node":02012902,"count":220,"temp":"18.94"}
UDP-Json.PNG
UDP-Json.PNG (9.58 KiB) Viewed 15065 times
To run this code for yourself, just copy the code below and import it in Node-RED.

Code: Select all

[{"id":"ad735c22.f400e","type":"mqtt-broker","z":"","broker":"croft.thethings.girovito.nl","port":"1883","clientid":"","usetls":false,"verifyservercert":true,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willRetain":null,"willPayload":"","birthTopic":"","birthQos":"0","birthRetain":null,"birthPayload":""},{"id":"2ab9bc05.b7c3ec","type":"function","z":"5e73aa57.dd6be4","name":"Extract data","func":"msg2 = {};\nvar b = new Buffer(msg.payload.data,'base64');\nvar c = new Buffer(msg.payload.nodeEui,'utf8');\nb = b.slice(1);\nmsg2.payload = '{\"node\":' + c + \",\" + b.toString();\nreturn msg2;","outputs":"1","noerr":0,"x":413.36114501953125,"y":100.36111640930176,"wires":[["55ae3863.33322","d5e9bf39.b1b2e8"]]},{"id":"7079d59d.e59cac","type":"json","z":"5e73aa57.dd6be4","name":"","x":280.77780532836914,"y":100.4444408416748,"wires":[["2ab9bc05.b7c3ec"]]},{"id":"6a1d2873.df04e8","type":"mqtt in","z":"5e73aa57.dd6be4","name":"node 02012902 packets","topic":"nodes/02012902/packets","broker":"ad735c22.f400e","x":112.22222900390625,"y":100.77777099609375,"wires":[["7079d59d.e59cac"]]},{"id":"55ae3863.33322","type":"debug","z":"5e73aa57.dd6be4","name":"","active":true,"console":"false","complete":"false","x":571.7777862548828,"y":77.88886642456055,"wires":[]},{"id":"d5e9bf39.b1b2e8","type":"udp out","z":"5e73aa57.dd6be4","name":"UDP Send","addr":"192.168.1.33","iface":"","port":"9093","ipv":"udp4","outport":"9193","base64":false,"multicast":"false","x":563.4443969726562,"y":117.5555419921875,"wires":[]}]
To run this code for yourself, just copy the code above and import it in Node-RED.

Look at this thread on the TheThingsNetwork forum, for the background discussion on parsing LoraWan data for Home Automation Packages like Zway here, and OpenRemote

node 02012902 may not be active at this moment. I am working on a collection of links to working devices

<to be completed>
working on udp listener module in Zway, or is it possible to base it on https://github.com/olliephillips/tinyMQTT?
pz1
Posts: 2053
Joined: 08 Apr 2012 13:44

Re: [userModule] TTNLoraWAN (discontinued)

Post by pz1 »

The support for this module has stopped (see first post). It will soon be removed from the App store.
Locked