# INKBIRD BLE

<p align="center">
  <a href="https://github.com/bluetooth-devices/inkbird-ble/actions?query=workflow%3ACI">
    <img src="https://img.shields.io/github/workflow/status/bluetooth-devices/inkbird-ble/CI/main?label=CI&logo=github&style=flat-square" alt="CI Status" >
  </a>
  <a href="https://inkbird-ble.readthedocs.io">
    <img src="https://img.shields.io/readthedocs/inkbird-ble.svg?logo=read-the-docs&logoColor=fff&style=flat-square" alt="Documentation Status">
  </a>
  <a href="https://codecov.io/gh/bluetooth-devices/inkbird-ble">
    <img src="https://img.shields.io/codecov/c/github/bluetooth-devices/inkbird-ble.svg?logo=codecov&logoColor=fff&style=flat-square" alt="Test coverage percentage">
  </a>
</p>
<p align="center">
  <a href="https://python-poetry.org/">
    <img src="https://img.shields.io/badge/packaging-poetry-299bd7?style=flat-square&logo=data:image/png;base64, " alt="Poetry">
  </a>
  <a href="https://github.com/ambv/black">
    <img src="https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square" alt="black">
  </a>
  <a href="https://github.com/pre-commit/pre-commit">
    <img src="https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=flat-square" alt="pre-commit">
  </a>
</p>
<p align="center">
  <a href="https://pypi.org/project/inkbird-ble/">
    <img src="https://img.shields.io/pypi/v/inkbird-ble.svg?logo=python&logoColor=fff&style=flat-square" alt="PyPI Version">
  </a>
  <img src="https://img.shields.io/pypi/pyversions/inkbird-ble.svg?style=flat-square&logo=python&amp;logoColor=fff" alt="Supported Python versions">
  <img src="https://img.shields.io/pypi/l/inkbird-ble.svg?style=flat-square" alt="License">
</p>

Parser for INKBIRD BLE devices

## Installation

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

`pip install inkbird-ble`

## Usage

`inkbird-ble` parses the BLE advertisements (and, for some models, GATT
reads/notifications) emitted by INKBIRD devices into structured sensor values.

Most sensors broadcast their readings, so passive parsing needs no connection:

```python
from inkbird_ble import INKBIRDBluetoothDeviceData

# `service_info` is a habluetooth `BluetoothServiceInfoBleak`
data = INKBIRDBluetoothDeviceData()
if data.supported(service_info):
    update = data.update(service_info)
    for device_key, value in update.entity_values.items():
        print(device_key.key, value.native_value)
    # temperature 20.44
    # humidity 48.07
    # battery 86
```

A few models must be polled (`async_poll`) or subscribed to (`async_start`)
over a connection. See the [usage documentation](https://inkbird-ble.readthedocs.io/en/latest/usage.html)
for the active device flow and for building a `service_info` outside Home
Assistant.

## Contributors ✨

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

<!-- prettier-ignore-start -->
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- markdownlint-disable -->
<!-- markdownlint-enable -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
<!-- prettier-ignore-end -->

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
[Cookiecutter](https://github.com/audreyr/cookiecutter) and the
[browniebroke/cookiecutter-pypackage](https://github.com/browniebroke/cookiecutter-pypackage)
project template.
