# bleak-smlight

---

**Documentation**: https://bleak-smlight.readthedocs.io 

**Source Code**: https://github.com/bluetooth-devices/bleak-smlight 

---

A [Bleak](https://github.com/hbldh/bleak) backend that receives Bluetooth Low
Energy advertisements from a SMLIGHT SLZB BLE proxy. The proxy is scan only, so
this library registers a non connectable scanner with
[habluetooth](https://github.com/Bluetooth-Devices/habluetooth); it does not
support GATT connections. The UDP proxy protocol lives in
[pysmlight](https://github.com/smlight-tech/pysmlight), this library is the host
side glue that feeds advertisements into Bleak. See the [architecture
docs](https://bleak-smlight.readthedocs.io/en/latest/architecture.html) for how
the pieces fit together.

## Usage

```python
import asyncio

import habluetooth

from bleak_smlight import SMLIGHTConnectionManager, SMLIGHTDeviceConfig

DEVICES: list[SMLIGHTDeviceConfig] = [
    {"source": "AA:BB:CC:DD:EE:FF", "name": "slzb-proxy", "host": "10.0.0.5"},
]


async def main() -> None:
    await habluetooth.BluetoothManager().async_setup()
    managers = [SMLIGHTConnectionManager(d) for d in DEVICES]
    await asyncio.gather(*(m.start() for m in managers))
    try:
        await asyncio.Event().wait()  # advertisements now flow into Bleak
    finally:
        await asyncio.gather(*(m.stop() for m in managers))


asyncio.run(main())
```

## Installation

Install this via pip (or your favourite package manager):

`pip install bleak-smlight`

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):








This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

## Credits

This package was created with
[Copier](https://copier.readthedocs.io/) and the
[browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)
project template.
