GithubHelp home page GithubHelp logo

lordthorzonus / ble2mqtt-gateway Goto Github PK

View Code? Open in Web Editor NEW
5.0 2.0 0.0 1.53 MB

BLE to MQTT Gateway supporting Ruuvitag and Miflora devices

License: MIT License

Dockerfile 0.53% TypeScript 99.47%
ble home-assistant iot mqtt ruuvitag ble-mqtt-bridge miflora

ble2mqtt-gateway's Introduction

BLE2MQTT Gateway

Gateway for turning ble data into home assistant compatible mqtt messages. Currently supports RuuviTags and MiFlora Devices.

Configuration

The behaviour of the gateway is controlled by a configuration file. The file is in YAML format and it's location can be set with the CONFIG_FILE_LOCATION environment variable.

Example Configuration (configuration.yaml)

log_level: info
decimal_precision: 1
mqtt:
    host: mqtt.lan.fi
    port: 1883
    username: ble2mqtt
    password: secret
    client_id: ble2mqtt
    protocol: mqtt

gateways:
    base_topic: ble2mqtt
    ruuvitag:
        allow_unknown: false
        devices:
            - name: Fridge Ruuvitag
              id: da21045d81a8
            - name: Balcony Second
              id: 641cae0910b5
              timeout: 10000
    miflora:
        devices:
            - name: My super plant
              id: c47c8d6e07cf
              timeout: 40000
homeassistant:
    discovery_topic: homeassistant

Installation

The easiest way to run the gateyway is to use the built docker image:

Example docker-compose.yml

services:
    ble2mqtt:
        image: "lordthorzonus/ble2mqtt-gateway:x.x.x"
        restart: unless-stopped
        cap_add:
            - NET_RAW
        network_mode: host
        volumes:
            - ./configuration.yaml:/home/node/app/config/configuration.yaml
        environment:
            - CONFIG_FILE_LOCATION="/home/node/app/config/configuration.yaml"
            - TZ="Europe/Helsinki"

The Docker image is available at Docker Hub. The version tag "x.x.x" should be replaced with the latest version.

The tagging scheme is as follows:

  • latest - The latest numbered release
  • x.x.x - The specific version of the release
  • edge - The latest commit on the main branch (Here be dragons)

The numbered releases are following semantic versioning.

See example here for how I deploy it with a ansible playbook

Using just docker

docker run \
    -v $(pwd)/configuration.yaml:/home/node/app/config/configuration.yaml \
    -e CONFIG_FILE_LOCATION="/home/node/app/config/configuration.yaml" \
    -e TZ="Europe/Helsinki" \
    --network host \
    --cap-add NET_RAW \
    lordthorzonus/ble2mqtt-gateway:x.x.x

Development

npm install
cp config/configuration.example.yaml config/configuration.yaml

Dev modes that don't actually send any mqtt messages:

  • npm run dev ble - Run in dev mode logging all received ble messages
  • npm run dev ble {manufacturerId} - Run in dev mode logging only messages from given manufacturer
  • npm run dev gateway - Run in dev mode logging all produced device messages
  • npm run dev gateway {deviceType} - Run in dev mode logging all produced device messages from given device type
  • npm run dev mqtt - Run in dev mode logging all mqtt messages that should be sent

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.