Coder Social home page Coder Social logo

oh2th / ruuvigw_mqtt_decode Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 242 KB

Parse Ruuvi Gateway JSON messages from MQTT broker and return them decoded back to the broker.

License: MIT License

Makefile 11.45% Perl 88.55%
ruuvi ruuvi-gateway ruuvitag-sensor mqtt ruuvi-ble-devices

ruuvigw_mqtt_decode's Introduction

Ruuvi Gateway MQTT JSON Parser

Parse Ruuvi Gateway JSON messages from MQTT broker and return them decoded back to the broker.

As does @OH2MP, I also am using Mosquitto as a broker and InfluxDB + Telegraf with Grafana. See CONFIG_EXAMPLES.md from his project.

This script sends the decoded data as JSON to the broker and the dataformat is compatible with @OH2MP's BLE2MQTT project. See DATAFORMATS.md

Supported BLE beacons

More to be supported eventually. Goal is to support the same as OH2MP ESP32 BLE2MQTT

Hardware prerequisites

Ruuvi Gateway

Software prerequisites

  • Some MQTT broker like Mosquitto running somewhere.
  • Perl libraries Net::MQTT::Simple, JSON::PP, Async::Event::Interval

Configure the Ruuvi Gateway

  • Open the Ruuvi Gateway configuration portal and go to Cloud Options page
  • Select the custom HTTP/MQTT option from Advance settings
  • (Optional) set HTTP(S) Server to the default Ruuvi Cloud address to send the data to the cloud.
  • Select MQTT(S) and configure your MQTT server information.
  • Topic prefix should be as ruuvi/<GW_MAC_ADDRESS>/<SENSOR_MAC_ADDRESS>, tick the first two options. Parsing the topic for this scripts configuration depends on it.

Configuring the script

Two files are needed for the script config.txt and known_tags.txt. Both files are TAB separated lists. Sample configuration files are in the sample directory. Copy them to the source root directory and edit them to your needs.

config.txt

mqtthost    mqtt.server.com:1883
username    mqttuser
password    SecretPasswordForMQTT
sub_topic   ruuvi/+/#
pub_topic   ruuvi/decoded
pub_inter   60

Note! the password is not encrypted and is sent in the clear as SSL is not implemented for now.

known_tags.txt

ee:b4:25:31:cd:52   vaasanrinne7/ulko
ec:ee:96:87:ce:fc   vaasanrinne7/sisä
f8:30:99:04:9c:cd   vaasanrinne7/sauna
ec:b1:3e:0b:17:4f   vaasanrinne7/pakastin
d7:a0:8f:0f:55:2d   vaasanrinne7/jääkaappi
fa:99:df:0f:c6:70   vaasanrinne7/terassi
c1:ea:33:8d:78:3f   goa753/ulko
c5:35:43:fd:63:2a   goa753/sisä
f5:ae:63:b0:4d:3a   goa753/jääkaappi

Only the known tags are reported back to the broker with the matching name added to the pub_topic from config.txt.

Sample data on the broker

MQTT Explorer

The raw JSON message from the gateway

ruuvi/CA:56:56:28:2D:3C/C3:32:96:A8:2A:06 = {
 "gw_mac": "CA:56:56:28:2D:3C",
 "rssi": -60,
 "aoa": [],
 "gwts": "1667194334",
 "ts": "1667194334",
 "data": "0201061BFF990405004D74EDCA130408FE24FFE882161F69DEC33296A82A06",
 "coords": ""
}

The decoded JSON messages sent back to the broker

ruuvi/decoded/vaasanrinne7/sauna {"type":1,"t":184,"rh":32,"bu":2905,"ap":1011,"s":-88}
ruuvi/decoded/vaasanrinne7/terassi {"type":1,"t":211,"rh":29,"bu":2989,"ap":1011,"s":-87}
ruuvi/decoded/vaasanrinne7/sisä {"type":1,"t":204,"rh":31,"bu":2971,"ap":1010,"s":-75}

Disclaimer

Thi script is based on my personal needs and has only been tested based on that.

Thanks

  • @OH2MP for the ESP32 based BLE2MQTT project and dataformats
  • @Ruuvi for creating the Ruuvi Tags and Ruuvi Gateway

ruuvigw_mqtt_decode's People

Contributors

oh2th avatar

Watchers

 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.