GithubHelp home page GithubHelp logo

ble-mqtt-bridge's Introduction

ble-mqtt-bridge

A Python Bluetooth LE to MQTT bridge

Should be run as root or as user with appropriate permissions to start BT LE scans.

Last time I tried, the MQTT server built into HA did not support the MQTT protocol fully. So use Mosquitto or another full-featured MQTT server instead!

Needs paho.mqtt.client and bluepy.

Run the bridge

Run like this:

source /opt/ble-mqtt/bin/activate ; /opt/ble-mqtt/ble-mqtt-bridge.py

Run the watcher

There is a watcher script which I need because I use a Intel AC7260 card for Bluetooth, which crashes quite often. The script works around that by waiting for too many errors or too little activity (sometimes the card stops responding to anything and doesn't even report scan results). It then removes the btusb modules, waits 5 seconds for USB autosuspend to kick in and then reloads the module. This prevents BT failures very reliably for me.

Run as

source /opt/ble-mqtt/bin/activate ; /opt/ble-mqtt/watcher.py

Example configuration

IPV 877710 Cccool Chain Control Bluetooth sensor

sensor:
  - platform: mqtt
    state_topic: "ble/88:4a:ea:bb:bb:bb/advertisement/ff"
    name: 'Sensor 1'
    unit_of_measurement: '°C'
    value_template: >-
      {% if value[0:2]|int(base=16) is lessthan(128) %}
      {{ value[0:2]|int(base=16)|float + value[2:4]|int(base=16)|float/256 }}
      {% else %}
      {{ value[0:2]|int(base=16)|float + value[2:4]|int(base=16)|float/256 - 256.0 }}
      {% endif %}

April Brother ABTemp Temperature BLE Sensor Beacon

sensor:
  - platform: mqtt
    state_topic: "ble/12:3b:6a:cc:cc:cc/advertisement/ff"
    name: 'Beacon SZ'
    unit_of_measurement: '°C'
    value_template: >-
      {% if value[0:2] == '4c' %}
      {{ value[46:48]|int(base=16)|float }}
      {% else %}
      {{ states.sensor.beacon_sz.state }}
      {% endif %}

April Brother Smart BLE Accelerometer iBeacon Beacon Sensor

sensor:
- platform: mqtt
    state_topic: "ble/12:3b:6a:dd:dd:dd/advertisement/ff"
    name: 'Blue Beacon'
    unit_of_measurement: '°C'
    value_template: >-
      {% if value[0:2] == 'd2' %}
      {{ value[18:20]|int(base=16)|float }}
      {% else %}
      {{ states.sensor.blue_beacon.state }}
      {% endif %}

ble-mqtt-bridge's People

Contributors

seidler2547 avatar

Watchers

James Cloos 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.