Code Monkey home page Code Monkey logo

mqtt-rflink-bridge's Introduction

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

mqtt-rflink-bridge's People

Contributors

piotrc4 avatar

Watchers

James Cloos avatar Neil Cherry 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.