mountaindude / Node-RED-Telldus-to-MQTT-bridge

Node-RED code to get data from Telldus Live API, then publish the data as MQTT messages
5 stars 2 forks source link

Node-RED-Telldus-to-MQTT-bridge

Summary

The code in this report will retrieve sensor and device data from Telldus Live, and then output that same data in a structured way to MQTT topics of your choice. Devices are typically various kinds of actuators, for example radio controlled mains switches.

Other applications can then subscribe to the MQTT topics, and provide for example visualizations of the sensor data, send alerts when certain conditions occur, or store the data in some kind of database.

Please note that the code in this repo is intended to go inside a Node-RED function - it is not a Node-RED module in itself.

More related information, ideas and code can be found at www.ptarmiganlabs.com.

alt text

Requirements

  1. Node-RED. As of this writing, I am myself using Node-RED 0.11.1 and Node.js 0.12.7
  2. MQTT node.js module (https://www.npmjs.com/package/mqtt)
  3. Telldus-Live module (https://github.com/TheThingSystem/node-telldus-live)
  4. An MQTT broker to which messages can be posted. Mosquitto works well, for example.
  5. Credentials to log into Telldus Live

Conceptual overview

The code first sets up a connection to the Telldus Live APIs, and to the MQTT broker.

Once that is in place, all information about all devices is downloaded and sent to the MQTT topics defined in the code. These topics can be modified at will (at least as long as a valid MQTT topic structure is used).

When processing of devices is done, the same process is started again for sensors - downloading all sensor data and attributed, for all sensors tracked by Telldus Live.

Why get the data from Telldus Live, rather than directly from your Tellstick?

Good question. For some years I have done exactly that: Using a Tellstick Duo to listen on all device and sensor radio traffic, then having a small python script extract and store the data I was interested in.

It worked, but not very well. When new devices (radio controlled mains switches, typically) were introduced, the python script had to be updated. Also, that script and the Tellstick had to be installed/running on an always-on computer that was in a physical location with good radio reception from all devices and sensors. Not easy.

The current setup is much better:

References

  1. A lot of the Telldus related code is inspired by the test/sample code over at TheThingSystem's Node.js module for Telldus Live.
  2. Blog post: Using Node-RED for publishing Telldus Live data to MQTT.