Skip to main content

BLE to MQTT bridge

Project description

Service to export BLE devices to MQTT with Home Assistant discovery

!!! It is a very early alpha release !!!

Use this software at your own risk.

Default config should be located in /etc/ble2mqtt.json or can be overridden with BLE2MQTT_CONFIG environment variable.

Example run command:

BLE2MQTT_CONFIG=./ble2mqtt.json ble2mqtt

The configuration file is a JSON with the following content:

{
    "mqtt_host": "localhost",
    "mqtt_port": 1883,
    "mqtt_user": "",
    "mqtt_password": "",
    "devices": [
        {
            "address": "11:22:33:aa:bb:cc",
            "type": "redmond200"
        },
        {
            "address": "11:22:33:aa:bb:dd",
            "type": "xiaomihtv1"
        },
        {
            "address": "11:22:34:aa:bb:dd",
            "type": "xiaomihtv1",
            "passive": false
        },
        {
            "address": "11:22:33:aa:bb:ee",
            "type": "xiaomilywsd"
        },
        {
            "address": "11:22:33:aa:bb:ff",
            "type": "xiaomilywsd_atc"
        }
    ]
}

Supported devices:

Kettles:

  • Redmond G2xx series (redmond200)

Humidity sensors:

  • Xiaomi MJ_HT_V1 (xiaomihtv1)
  • Xiaomi LYWSD03MMC (xiaomilywsd)
  • Xiaomi LYWSD03MMC with custom ATC firmware (xiaomilywsd_atc)

By default, a device works in the passive mode without connection by listening to advertisement packets from a device. To use connection to the device provide "passive": false parameter.

Supported devices in passive mode:

  • Xiaomi MJ_HT_V1 (xiaomihtv1)
  • Xiaomi LYWSD03MMC with custom ATC firmware (xiaomilywsd_atc)

OpenWRT installation

Execute the following commands in the terminal:

opkg update
opkg install python3-pip python3-asyncio
pip3 install git+https://github.com/hbldh/bleak.git@f50a334e1173b27a8cf0a53d8ac56d9acc24fedf#egg=bleak
pip3 install -U ble2mqtt

Create the configuration file in /etc/ble2mqtt.json and append your devices.

Bluetooth must be turned on.

hciconfig hci0 up

Run the service in background

ble2mqtt 2> /tmp/ble2mqtt.log &

Container

Build the image as:

podman build .

Then use it as a mounted volume as:

podman run -d --net=host -v $PWD/ble2mqtt.json.sample:/etc/ble2mqtt.json:z 5966e7eaef47

NOTE: --net=host is required as it needs to use the bluetooth interface

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ble2mqtt-0.1.0a14.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

ble2mqtt-0.1.0a14-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file ble2mqtt-0.1.0a14.tar.gz.

File metadata

  • Download URL: ble2mqtt-0.1.0a14.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for ble2mqtt-0.1.0a14.tar.gz
Algorithm Hash digest
SHA256 b3d1b4609aa283095236a5742e3203b39071116c6bc3fa5fd38eca965601dfed
MD5 ef6e8e9baed01443f9a6345060e8ec89
BLAKE2b-256 39798ab80026da191624a4950c6061ed11f2e08220e9163b964e266ceaf48ef9

See more details on using hashes here.

File details

Details for the file ble2mqtt-0.1.0a14-py3-none-any.whl.

File metadata

  • Download URL: ble2mqtt-0.1.0a14-py3-none-any.whl
  • Upload date:
  • Size: 25.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.53.0 CPython/3.9.0

File hashes

Hashes for ble2mqtt-0.1.0a14-py3-none-any.whl
Algorithm Hash digest
SHA256 ed334cc56efc9d9911f29c2f57d39bad204ca53465a67940ee9b305b640780a6
MD5 77a3afdfa6537dc28e4d44f64fe25f7f
BLAKE2b-256 593759db64608d0f051ff95e0818d232a0268e4dc5703852e38d29766ea39088

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page