Skip to content

mortylabs/multi_rflink_tcp_bridge

Repository files navigation

MultiRFLink TCP Bridge

Python Version License: MIT

multi_rflink_tcp_bridge.py is a Python app that consolidates multiple RFLink streams (433MHz, 868MHz, etc.) from distributed devices, with their own IP addresses or ports, into a single TCP output - ready for Home Assistant or any automation hub.


📌 Key Benefit

🔧 Multi-RFLink support out of the box - Home Assistant supports only one RFLink connection natively. This bridge removes that limitation by allowing multiple RFLink units - each potentially sniffing different RF frequencies like 433MHz and 868MHz - to be connected simultaneously.

🛰️ Extend signal range and coverage by deploying RFLink devices (e.g., Raspberry Pi Zero W + RF modules) in different rooms or floors. This bridge links all devices into one TCP stream, letting Home Assistant consume everything from a single, unified endpoint.


📖 Table of Contents


🧩 Features

  • Supports 433MHz and 868MHz RFLinks in parallel
  • Centralizes multiple RFLink TCP feeds into one
  • Compatible with Home Assistant, Node-RED, MQTT, etc.
  • Optional Telegram alerts on disconnect/reconnect
  • Graceful handling of stale messages on client connection
  • Lightweight and efficient (runs on Pi Zero W)

🚀 Quickstart

git clone https://github.com/mortylabs/multi_rflink_tcp_bridge.git
cd multi_rflink_tcp_bridge
cp .env.example .env
nano .env  # configure IPs, ports, and logging
pip install -r requirements.txt
python multi_rflink_tcp_bridge.py

⚙️ Configuration

Create and customize a .env file in the project root:

cp .env.example .env
Variable Description Example
RFLINK1_IP, PORT RFLink device #1 IP and port 192.168.1.10:5000
RFLINK2_IP, PORT Optional second RFLink device 192.168.1.11:5001
RFLINK3_IP, PORT Optional third RFLink device 192.168.1.12:5002
RFLINK_BRIDGE_IP IP for this bridge to listen on 0.0.0.0
RFLINK_BRIDGE_PORT Port for unified stream 1234
WRITE_LOG_TO_DISK Write logs to file (true or false) true
LOGGING_LEVEL Logging level (DEBUG, INFO, WARN, ERROR) INFO
TELEGRAM_ENABLED Enable Telegram alerts true
TELEGRAM_BOT_KEY Telegram bot token -
TELEGRAM_BOT_CHAT_ID Target chat ID for alerts -

🧠 Usage

Once configured, simply run the script:

python multi_rflink_tcp_bridge.py
  • Starts listener threads for each RFLink
  • Forwards their messages into one bridge stream
  • Supports reconnects and alerting via Telegram
  • Messages drained on new client connect to avoid stale payloads

This bridge gives your automation system a unified, real-time view of your RF environment, regardless of how many RFLinks you deploy or where you place them.


🚁 Running as a Service

To run the bridge as a background service that starts automatically on boot:

sudo nano /etc/systemd/system/multirflink.service
[Unit]
Description=MultiRFLinkTCPBridge service
Wants=network-online.target
After=network-online.target

[Service]
Type=simple
ExecStartPre=/bin/sleep 10
ExecStart=/usr/bin/python3 -u /home/pi/github/multi_rflink_tcp_bridge/multi_rflink_tcp_bridge.py
Restart=always
RestartSec=5
User=pi
Group=pi

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable multirflink
sudo systemctl start multirflink
sudo systemctl status multirflink

Note: ExecStartPre=/bin/sleep 10 prevents Errno 99 bind failures on boot by giving the network stack time to fully initialise before the bridge tries to bind its port.


🔌 Remote Device Setup

For each Raspberry Pi Zero W / 2 W with an RFLink USB device:

  1. Install Python 3 and rflinkproxy
sudo apt update
pip3 install rflink
  1. Create a proxy systemctl service:
sudo nano /etc/systemd/system/rflinkproxy.service
[Unit]
Description=RFLink Proxy Service
After=network.target

[Service]
ExecStart=/home/pi/start-rflinkproxy.sh
WorkingDirectory=/home/pi
User=pi
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable rflinkproxy
sudo systemctl start rflinkproxy

🏠 Integration Examples

🔌 Home Assistant

sensor:
  - platform: tcp
    host: 192.168.1.50  # IP of your bridge device
    port: 1234          # Port defined in your .env
    name: RFLink Stream

🔁 Node-RED Integration

To integrate the unified RFLink stream into Node-RED:

  1. Add a TCP In node

    • Type: stream
    • Host: IP of your MultiRFLinkTCPBridge (e.g., 192.168.1.50)
    • Port: TCP port from your .env (e.g., 1234)
  2. Connect it to a debug or processing node

    • This will show raw RFLink messages from all linked devices

💡 Tip: You can split or parse the RFLink strings using a function node.


📈 Roadmap

  • Multi-RFLink support across IPs and ports
  • Support for multiple frequencies (433MHz and 868MHz)
  • Telegram alert integration for error/reconnects
  • Graceful queue draining on new client connect
  • Systemctl service with boot-time Errno 99 fix
  • Dockerfile and container support
  • AsyncIO-based socket backend for better scalability

📜 License

This project is licensed under the MIT License. See the LICENSE file for details.


💬 Questions?

Have feedback or need support?

  • Open an issue
  • Start a discussion on the repo
  • Suggest features or improvements via pull requests

About

Aggregates multiple RFLink devices (433MHz & 868MHz) from across your home into a single TCP stream — letting Home Assistant connect to all your RF sensors through one unified endpoint. Runs on a Raspberry Pi Zero W.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages