Skip to content

createthisnl/RFLinkGateway

 
 

Repository files navigation

RFLink Gateway to MQTT

Purpose

Bridge between RFLink Gateway and MQTT broker.

Current features

Forwarding messages received on TTY port from RFLink Gateway Arduino board to MQTT broker in both directions.

Every message received from RFLinkGateway is split into single parameters and published to different MQTT topics. Example: Message:

20;37;Acurite;ID=cbd5;TEMP=0066;HUM=79;WINSP=001a;BAT=OK

ASCII

/data/RFLINK/Acurite/cbd5/READ/TEMP 10.2
/data/RFLINK/Acurite/cbd5/READ/HUM 73
/data/RFLINK/Acurite/cbd5/READ/WINSP 2.6
/data/RFLINK/Acurite/cbd5/READ/BAT OK

JSON

/data/RFLINK/Acurite/cbd5/READ/TEMP {"value": 10.2}
/data/RFLINK/Acurite/cbd5/READ/HUM {"value": 73}
/data/RFLINK/Acurite/cbd5/READ/WINSP {"value": 2.6}
/data/RFLINK/Acurite/cbd5/READ/BAT {"value": "OK"}

Every message received on particular MQTT topic is translated to RFLink Gateway and sent to 433 MHz.

Installation

Install the dependencies with the following commands:

pip install -r requirements.txt

Configuration

Whole configuration is located in config.json file. You can copy and edit config.json.sample.

{
  "mqtt_host": "your_mqtt_host",
  "mqtt_port": 1883,
  "mqtt_prefix": "/data/RFLINK",
  "mqtt_format": "json",
  "mqtt_message_timeout": 60,
  "mqtt_user":"your_mqtt_user",
  "mqtt_password":"your_mqtt_password",
  "rflink_tty_device": "/dev/ttyUSB0",
  "rflink_direct_output_params": [
    "BAT",
    "CMD",
    "SET_LEVEL",
    "SWITCH",
    "HUM",
    "CHIME",
    "PIR",
    "SMOKEALERT"
  ],
  "rflink_signed_output_params": [
    "TEMP",
    "WINCHL",
    "WINTMP"
  ],
  "rflink_wdir_output_params": [
    "WINDIR"
  ]
}
config param meaning
mqtt_host MQTT broker host
mqtt_port MQTT broker port
mqtt_prefix prefix for publish and subscribe topic
mqtt_format publish and subscribe topic as json or ascii
rflink_tty_device Serial device
rflink_direct_output_params Parameters transferred to MQTT without any processing
rflink_signed_output_params Parameters with signed values
rflink_wdir_output_params Parameters with wind direction values

Running

Scripts assume script directory located at: /opt/scripts/RFLinkGateway, and virtualenv was used. If not, use system Python binary, not the virtualenv'ed one.

Running in Supervisor

vim supervisor_RFLinkGateway
cp supervisor_RFLinkGateway /etc/supervisor/conf.d/
supervisorctl reread
supervisorctl update
supervisorctl start RFLinkGateway

Start as a Service

vim RFLinkGateway.service
cp RFLinkGateway.service /lib/systemd/system/RFLinkGateway.service
sudo systemctl daemon-reload
sudo systemctl enable RFLinkGateway.service

Start as a docker container

cd /opt/scripts/RFLinkGateway
docker build --tag rflink .
docker run --name rflinkgw -v /path/to/configfile:/app/config.json --device=/dev/ttyUSB0:/dev/ttyUSB0:rw rflink:latest

Logging

Script logs to STDOUT, it can be redirected through supervisord to files or syslog. For docker you can use any driver (such a Loki).

Output data

Application pushes informations to MQTT broker in following format: [mqtt_prefix]/[device_type]/[device_id]/READ/[parameter]

/data/RFLINK/TriState/8556a8/READ/1 OFF

Except if there its a CMD (Normally a signal from a switch), it is pushed to the following topic: [mqtt_prefix]/[device_type]/[device_id]/[switch_id]/READ/[parameter]

like this, you only have to read the command message to use with devices with two or more switches

/data/RFLINK/NewKaku/0201e3fa/2/READ/CMD ON

Every change should be published to topic: [mqtt_prefix]/[device_type]/[device_id]/W/[switch_ID]

/data/RFLINK/TriState/8556a8/W/1 ON

References

About

MQTT Support for RFLink Gateway (http://www.nemcon.nl/blog2) project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.4%
  • Dockerfile 3.6%