Package: enocean-mqtt
EnOcean to MQTT ForwarderThis 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 thePython EnOceanlibrary.Installationenocean-mqtt is available onPyPIand can be installed using pip:pip install enocean-mqttAlternatively, install the latest release directly from github:download this repository to an arbritary directoryinstall it usingpython setup.py developAfterwards, perform configuration:adapt theenoceanmqtt.conf.samplefile and put it to /etc/enoceanmqtt.confset the enocean interface portdefine the MQTT broker addressdefine the sensors to monitorensure that the MQTT broker is runningrunenoceanmqttfrom within the directory of the config file or provide the config file as a command line argumentSetup as a daemonAssuming you want this tool to run as a daemon, which gets automatically started by systemd:copy theenoceanmqtt.serviceto/etc/systemd/system/(making only a symbolic linkwill not work)systemctl enable enoceanmqttsystemctl start enoceanmqttSetup as a docker containerAlternatively, instead of running a native deamon you may want to use Docker:Mount the/configvolume and your enocean USB deviceAdapt theenoceanmqtt.conffile in the/configfolderThe volume mount has to point to -v /local/path/to/configfile:/config.
Example docker command:sudo docker run --name="enoceanmqtt" --device=/dev/enocean -v /volume1/docker/enocean2mqtt/config:/config volschin/enocean-mqtt:latest.Define persistant device name for EnOcean interfaceIf 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.ruleswith 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 intodmesgand search for the corresponding entry here. Alternatively you can checkudevadm info -a -n /dev/ttyUSB0, assuming that the interface is currently mapped tottyUSB0.Using with the EnOcean Raspberry Pi HatThis module works with theelement14 EnOcean Raspberry Pi Hat. The hat presents the EnOcean transceiver to the system as device/dev/ttyAMA0, setenocean_portto 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 usingraspi-config. SeeDisable Linux serial consolein theRaspberry Pi UART documentationfor 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.txtand reboot:dtoverlay=disable-btConfigurationPlease take a look at the providedenoceanmqtt.conf.samplesample 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.confin Dockerfile:/enoceanmqtt-default.conf, compareenoceanmqtt-default.conf.any further command line argument.This can be used to split security sensitive values from the device configs.UsageReading EnOcean MessagesEvery EnOcean message that a configured sensor receives will get decoded according the configuredrorg,func,typefields. Then, the decoded content will be published to MQTT.To avoid receiving MQTT messages for specific devices you have two choinces. You may either not configure it at all, but you will still see entries in the log file then on messages fron unknown devices. Alternatively you can enter the device in the configuration and setignoreto 1.Sending EnOcean MessagesTo send EnOcean messages you prepare the packet data by sending MQTT request to specific fields. You typically configure thedefault_dataproperty in the config file and afterwards customize/complete the packet by publishing an MQTT message to the device topic where you prefix the topic with/req.An example: If you want to set the valve position (set point) of a heating actuator namedheating(e.g. withrorg = 0xA5,func = 0x20,type = 0x01) to 80 % you publish the integer value 80 to the topicenocean/heating/req/SP. This replaces the corresponding part ofdefault_data.For VLD packets, you need to set the VLD type. For this, configure acommandtopic in the configuration file. Sending and MQTT request to this topic sets the command ID of the used EEP profile.To finally trigger the sending of the packet, place an MQTT message to the device'sreq/sendtopic. If you want to clear the customized data buffer back to default, set the MQTT payload toclear. Any other payload will keep the data buffer for further send requests.Answering EnOcean MessagesSimilar to sending EnOceam Messages you can configure it to send a packet as an answer to in incoming EnOcean packet. For this, you configure theanswerswitch in the device's configuration section. As above, you set thedefault_datain the config file and customize the response data by publishing MQTT messages to the device topic where you prefix the topic with/req.