GithubHelp home page GithubHelp logo

hnesland / telldusmq Goto Github PK

View Code? Open in Web Editor NEW
5.0 1.0 6.0 21 KB

MQTT broker for reading and transmitting events via Tellstick (telldusd).

License: Apache License 2.0

Go 100.00%
tellstick telldus mqtt

telldusmq's Introduction

MQTT Broker for Telldus Core (Tellstick)

Uses libtelldus-core (Tellstick) to transmit events to MQTT. These events can then be used from different home automation / smart home utilities like Home Assistant and OpenHAB or your own custom handlers and loggers.

Installation

The broker is installed with standard Go tools:

go get github.com/hnesland/telldusmq

The broker depends on telldus-core to communicate with Tellstick.

Other dependencies are handled by Go.

It's currently known to work on Ubuntu 16.04, but should also work on other Linux distributions. The C-based API for Telldus works on Linux, MacOS and Windows. This broker should also work on MacOS, but it is untested. If you're adventurous enough, maybe Windows even works ;-)

Usage

After installation the broker can be started directly and will look for a configuration file. A sample configuration file is provided in the repository. The broker currently does not accept any parameters.

Configuration

The broker is configured using a Viper compatible configuration file (JSON, TOML, YAML, HCL or Java properties). Currently the file must be named telldusmq.<type> like telldusmq.json. We'll look for the configuration file in /etc/telldusmq/, $HOME/.telldusmq/ or the current working directory.

Receiving Events From Tellstick

The MQTT parameters for topic and payload, can contain template variables (from Go text/template package). The templates are executed on an object containing the event from Tellstick with the following properties:

  • Class
  • Protocol
  • Model
  • Code
  • House
  • Unit
  • Group
  • Method
  • Id
  • Temp
  • Humidity
  • Value
  • DataType

We can then use the variables like this: Temperature for id#{{.Id}} is: {{.Temp}}

Some sensors supports both temperature and humidity and if you wish to have a separate event for both these types, you can set the configuration item Tellstick => SplitTemperatureAndHumidity to true. The Value property will contain the value (temperature or humidity) and the DataType property will contain temp or humidity. The sample configuration reflects this.

Telldus Core reports device methods as turnon or turnoff by default. If you wish to map these to other values like ON or OFF, 1 or 0 etc, this can be configured with setting Tellstick => MapTurnOnTo and Tellstick => MapTurnOffTo to the appropriate strings.

Transmitting Events To Tellstick

Telldus-core allows to transmit commands to devices. The broker subscribes to the MQTT-topic defined in MQTT => Events => SubscribeTopic. Currently we support two methods for transmitting commands; devices from tellstick.conf and raw commands.

Tellstick.conf Device

A few methods in telldus-core for transmitting actions are implemented. These are turnoff, turnon, learn and dim. The MQTT-payload for these events must be formatted like this:

{"protocol":"telldusdevice", "method":"turnon", "device_id": 145}
{"protocol":"telldusdevice", "method":"dim", "device_id": 145, "level": 25}

The method can be one of the described methods above, and device_id must be a device defined in tellstick.conf. Protocol must be telldusdevice.

We also listen to the topic defined in MQTT => Events => SubscribeDeviceEvents. This topic can either be a specified device id like tellstick/device/events/13 or a wild card defining all devices tellstick/device/events/#. The payload for these events is simply the Tellstick method described above.

Raw Commands

We don't really support raw commands yet, but we hopefully will very soon. There is some initial support for archtech, but it probably won't work.

The WIP is published anyway. MQTT-payload for these are:

{"protocol":"archtech", "house": 12345, "unit": 9, "method": "turnoff"}
{"protocol":"archtech", "house": 12345, "unit": 9, "method": "dim", "level": 25}

Raw Commands TODO

  • Implement archtech properly
  • Implement more protocols
  • Implement proper protocol-switching

Reporting Bugs

Please report bugs by raising issues for this project in Github.

telldusmq's People

Contributors

hnesland avatar torgrimt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

telldusmq's Issues

telldusmq and thingsboard

This is not a bug, but a question.
I'm trying to use telldusmq to send data to a thingsboard iot gatway.
Is it supposed that telldusmq should work as a server, on the port selected in the configuration file, or do telldusmq conect to a broker/server and send data to this?

192.168.10.99 is localhost for telldusmq.

when i try "go run main.go" i got this error:
017/11/05 11:52:23 Started Message Queue for Telldus Core
2017/11/05 11:52:23 Unable to connect to MQTT: Network Error : dial tcp 192.168.10.99:1882: getsockopt: connection refused
panic: Unable to connect to MQTT: Network Error : dial tcp 192.168.10.99:1882: getsockopt: connection refused

goroutine 1 [running]:
panic(0x8448e0, 0xc82015c140)
/usr/lib/go-1.6/src/runtime/panic.go:481 +0x3e6
log.Panicf(0xa31ae0, 0x1d, 0xc8200d5e78, 0x1, 0x1)
/usr/lib/go-1.6/src/log/log.go:327 +0xd8
main.setupMqtt()

Stops working after a while

I've been running telldusmq for a while now (great program btw), but it always stops working after some time, usually about 20-30 hours. There are no error messages in the log and the program is still running, but no more MQTT messages are sent.

Running Rasbian on a Raspberry Pi (Pi2 ver B).

Any ideas? Is there some way for running in debug mode?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.