Giter Club home page Giter Club logo

enocean-mqtt's Introduction

EnOcean to MQTT Forwarder

PyPI pyversions PyPI status PyPI version shields.io PyPI download total

This Python module receives messages from an EnOcean interface (e.g. via USB) and publishes selected messages to an MQTT broker.

You may also configure it to answer to incoming EnOcean messages with outgoing responses. The response content is also defined using MQTT requests.

It builds upon the Python EnOcean library.

Installation

enocean-mqtt is available on PyPI and can be installed using pip:

  • pip install enocean-mqtt

Alternatively, install the latest release directly from github:

  • download this repository to an arbritary directory
  • install it using python setup.py develop

Afterwards, perform configuration:

  • adapt the enoceanmqtt.conf.sample file and put it to /etc/enoceanmqtt.conf
    • set the enocean interface port
    • define the MQTT broker address
    • define the sensors to monitor
  • ensure that the MQTT broker is running
  • run enoceanmqtt from within the directory of the config file or provide the config file as a command line argument

Setup as a daemon

Assuming you want this tool to run as a daemon, which gets automatically started by systemd:

  • copy the enoceanmqtt.service to /etc/systemd/system/ (making only a symbolic link will not work)
  • systemctl enable enoceanmqtt
  • systemctl start enoceanmqtt

Setup as a docker container

Alternatively, instead of running a native deamon you may want to use Docker:

  • Mount the /config volume and your enocean USB device
  • Adapt the enoceanmqtt.conf file in the /config folder

Define persistant device name for EnOcean interface

If you own an USB EnOcean interface and use it together with some other USB devices you may face the situation that the EnOcean interface gets different device names depending on your plugging and unplugging sequence, such as /dev/ttyUSB0or /dev/ttyUSB1. You would need to always adapt your config file then.

To solve this you can make an udev rule that assigns a symbolic name to the device. For this, create the file /etc/udev/rules.d/99-usb.rules with the following content:

SUBSYSTEM=="tty", ATTRS{product}=="EnOcean USB 300 DB", SYMLINK+="enocean"

After reboot, this assigns the symbolic name /dev/enocean. If you use a different enocean interface, you may want to check the product string by looking into dmesg and search for the corresponding entry here. Alternatively you can check udevadm info -a -n /dev/ttyUSB0, assuming that the interface is currently mapped to ttyUSB0.

Using with the EnOcean Raspberry Pi Hat

This module works with the element14 EnOcean Raspberry Pi Hat. The hat presents the EnOcean transceiver to the system as device /dev/ttyAMA0, set enocean_port to this device in your configuration file.

Depending on your Raspberry Pi model, you may need to enable the serial port and/or disable the Linux serial console using raspi-config. See Disable Linux serial console in the Raspberry Pi UART documentation for the procedure.

Additionally, for the Raspberry Pi 3, you will need to disable the built-in Bluetooth controller as there is a hardware conflict between the EnOcean Hat and the Bluetooth controller (they both use the same hardware clock.) To do this, add the following line to /boot/config.txt and reboot:

dtoverlay=disable-bt

Configuration

Please take a look at the provided enoceanmqtt.conf.sample sample config file. Most should be self explaining.

Multiple config files can be specified as command line arguments. Values are merged, later config files override values of the former. This is the order:

  • /etc/enoceanmqtt.conf
  • in Dockerfile: /enoceanmqtt-default.conf, compare enoceanmqtt-default.conf.
  • any further command line argument.

This can be used to split security sensitive values from the device configs.

Answering EnOcean Messages

To answer EnOcean messages you configure the answer switch and the default_data in the config file. To customize the response data you publish an MQTT message to the sensor topic where you prefix the topic with /req.

An example: If you want to set the valve position (set point) of a heating actuator named heating (e.g. with rorg = 0xA5, func = 0x20, type = 0x01) to 80 % you publish the integer value 80 to the topic enocean/heating/req/SP. This replaces the corresponding part of default_data.

enocean-mqtt's People

Contributors

romor avatar crowbarz avatar sttts avatar nduhamel avatar flopon avatar

Watchers

James Cloos avatar

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.