Homie based bridge between MQTT and RFlink module
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
lib
src
.gitignore
.travis.yml
README.md
platformio.ini

README.md

Homie based bridge MQTT to RFLink module

Features:

  • publish via MQTT in JSON format message received from RFlink gateway
  • send to RFlink gateway message received via MQTT
  • All Homie buildin features (OTA,configuration)

Limitations

  • Too long messages (mostly debug) may not be published - error message will be published

Connections

  • Do standard RFlink wiring
  • Connect RFLink to ESP8266
    • Arduino MEGA TX (D1) to ESP8266 Soft Serial RX (GPIO14/D5) via logic level shifter 5V->3,3V or voltage divider (use 200Ohm and 470Ohm resistors)
    • Arduino MEGA RX (D0) to ESP8266 Soft Serial TX (GPIO5/D1)

schematic

alt text

MQTT messages

Property Message format Direction Description
_HOMIE_PREFIX_/_node-id_/serial01/to-send/set See [RFlink protocol reference](http://www.nemcon.nl/blog2/protref) Controller → Device
_HOMIE_PREFIX_/_node-id_/serial01/publish-mode/set (RAW|JSON|STANDARD) Controller → Device Set publishing methods
_HOMIE_PREFIX_/_node-id_/serial01/_device_name_ See below JSON message format section Device → Controller
_HOMIE_PREFIX_/_node-id_/$online (true|false) Device → Controller /true when the device is online, false when the device is offline (through LWT)

Message format

  • JSON Message received from RFLink is converted to JSON array. Each field is converted to array element. Name is used in topic name.

RFlink message: 20;1B;Keeloq;ID=e311;SWITCH=0A;CMD=ON;BAT=OK; will be published in topic: HOMIE_PREFIX/node-id/serial01/Keeloq with value {"msgIdx":"12","ID":"e331","SWITCH":"01","CMD":"ON","BAT":"OK"}

  • RAW Message recived from RFLink is published as is. Used in debug.

  • STANDARD Message received from RFLink is converted to JSON array partialy RFlink message: 20;1B;Keeloq;ID=e311;SWITCH=0A;CMD=ON;BAT=OK; will be published in topic: HOMIE_PREFIX/node-id/serial01/Keeloq/e331 with value {"SWITCH":"01","CMD":"ON","BAT":"OK"}

Examples of usage

  • Sending RF - Publish to HOMIE_PREFIX/node-id/serial01/to-send/set value: 10;Kaku;00004d;1;OFF;
  • Turn on RFDEBUG - Publish to HOMIE_PREFIX/node-id/serial01/to-send/set value: 10;RFDEBUG=ON;
  • PING RFLink module - Publish to HOMIE_PREFIX/node-id/serial01/to-send/set value: 10;PING;. Response will be published in topic HOMIE_PREFIX/node-id/serial01/PONG

Usage with OpenHAB

  • STANDARD format
    • create rflink.items file:
    Group gRFLink
    String rfLinkKeeloq
            "Keeloq message [%s]" (gRFLink)
            {mqtt="<[mosquitto:_HOMIE_PREFIX_/_node-id_/serial01/Keeloq/1111:state:default]"}
    • create keeloq.rules file:
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

rule keeloqUpdate
when
        Item rfLinkKeeloq received update
then
        var String SWITCH = transform("JSONPATH", "$.SWITCH", Message)
        var String CMD = transform("JSONPATH", "$.CMD", Message)
        var String BAT = transform("JSONPATH", "$.BAT", Message)
        if (SWITCH=="01" && CMD=="ON")
        {
                // When button was pressed log it
                logInfo("keeloq","Received message from keeloq")
        }
end
  • JSON format
    • create rflink.items file:
Group gRFLink
String rfLinkKeeloq
        "Keeloq message [%s]" (gRFLink)
        {mqtt="<[mosquitto:_HOMIE_PREFIX_/_node-id_/serial01/Keeloq:state:default]"}
  • create keeloq.rules file:
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*

rule keeloqUpdate
when
        Item rfLinkKeeloq received update
then
        var String Message = rfLinkKeeloq.state.toString
        var String ID = transform("JSONPATH", "$.ID", Message)
        var String SWITCH = transform("JSONPATH", "$.SWITCH", Message)
        var String CMD = transform("JSONPATH", "$.CMD", Message)
        var String BAT = transform("JSONPATH", "$.BAT", Message)

        if (ID=="1111" && SWITCH=="01" && CMD=="ON")
        {
                // When button was pressed log it
                logInfo("keeloq","Received message from keeloq")
        }
end