# Welcome to OralB BLE documentation!

Installation & Usage

- Installation
- Usage

Developer Reference

- Oral-B BLE wire format
  - Manufacturer-specific advertisement
  - GATT characteristics
  - Adding a new model
  - References

Project Info

- Changelog
  - v0.18.0 (2024-02-21)
  - v0.17.6 (2023-03-21)
  - v0.17.5 (2023-02-07)
  - v0.17.4 (2023-02-06)
  - v0.17.3 (2023-02-06)
  - v0.17.2 (2023-02-03)
  - v0.17.1 (2023-01-13)
  - v0.17.0 (2023-01-12)
  - v0.16.1 (2023-01-08)
  - v0.16.0 (2023-01-08)
  - v0.15.0 (2023-01-07)
  - v0.14.3 (2022-12-01)
  - v0.14.2 (2022-11-11)
  - v0.14.1 (2022-11-09)
  - v0.14.0 (2022-11-06)
  - v0.13.0 (2022-11-05)
  - v0.12.0 (2022-11-05)
  - v0.11.1 (2022-11-05)
  - v0.11.0 (2022-11-05)
  - v0.10.2 (2022-11-04)
  - v0.10.1 (2022-11-03)
  - v0.10.0 (2022-10-31)
  - v0.9.0 (2022-10-28)
  - v0.8.0 (2022-10-27)
  - v0.7.0 (2022-10-27)
  - v0.6.0 (2022-10-27)
  - v0.5.0 (2022-10-25)
  - v0.4.0 (2022-10-25)
  - v0.3.1 (2022-10-25)
  - v0.3.0 (2022-10-24)
  - v0.2.0 (2022-10-24)
  - v0.1.1 (2022-10-24)
  - v0.1.0 (2022-10-24)
- Contributing
  - Types of Contributions
  - Get Started!
  - Pull Request Guidelines
  - Tips
  - Making a new release

# OralB BLE

Bluetooth library for Oral B devices

## Installation

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

`pip install oralb-ble`

## Usage

`oralb-ble` is a passive parser for Oral-B toothbrush BLE advertisements. It does not connect to the device — it decodes the manufacturer data that the brush broadcasts while in use.

Feed each advertisement you receive into `OralBBluetoothDeviceData.update()` and read the resulting `SensorUpdate`:

    from home_assistant_bluetooth import BluetoothServiceInfo
    from oralb_ble import OralBBluetoothDeviceData

    # A BLE advertisement captured from an Oral-B IO Series 6.
    service_info = BluetoothServiceInfo(
        name="Oral-B Toothbrush",
        address="78:DB:2F:C2:48:BE",
        rssi=-63,
        manufacturer_data={220: b"\x062k\x02r\x00\x00\x01\x01\x00\x04"},
        service_uuids=[],
        service_data={},
        source="local",
    )

    parser = OralBBluetoothDeviceData()
    update = parser.update(service_info)

    print(update.title)
    # 'IO Series 48BE'

    for key, value in update.entity_values.items():
        print(f"{key.key}: {value.native_value}")
    # time: 0
    # sector: no sector
    # number_of_sectors: 4
    # sector_timer: 0
    # toothbrush_state: idle
    # pressure: normal
    # mode: sensitive
    # signal_strength: -63

    for key, value in update.binary_entity_values.items():
        print(f"{key.key}: {value.native_value}")
    # brushing: False

The parser is stateful per device: keep the same `OralBBluetoothDeviceData` instance across advertisements from the same toothbrush so that derived fields (`sector_timer`, `toothbrush_state`) stay accurate.

For real-world advertisement collection see Home Assistant’s bluetooth integration — that is the primary consumer of this library.

## Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

## Credits

This package was created with Cookiecutter and the browniebroke/cookiecutter-pypackage project template.