{"id":51107519,"url":"https://github.com/hudsonbrendon/apple-ble","last_synced_at":"2026-06-24T15:01:09.521Z","repository":{"id":361933350,"uuid":"1256185069","full_name":"hudsonbrendon/apple-ble","owner":"hudsonbrendon","description":"Pure-Python parser for Apple Continuity BLE proximity-pairing adverts — AirPods battery and nearby Apple device presence","archived":false,"fork":false,"pushed_at":"2026-06-01T21:04:09.000Z","size":34,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-01T23:08:00.397Z","etag":null,"topics":["airpods","apple","ble","bluetooth","continuity","home-assistant","python"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hudsonbrendon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-06-01T14:39:36.000Z","updated_at":"2026-06-01T21:04:00.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hudsonbrendon/apple-ble","commit_stats":null,"previous_names":["hudsonbrendon/apple-ble"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/hudsonbrendon/apple-ble","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hudsonbrendon%2Fapple-ble","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hudsonbrendon%2Fapple-ble/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hudsonbrendon%2Fapple-ble/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hudsonbrendon%2Fapple-ble/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hudsonbrendon","download_url":"https://codeload.github.com/hudsonbrendon/apple-ble/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hudsonbrendon%2Fapple-ble/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34737398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["airpods","apple","ble","bluetooth","continuity","home-assistant","python"],"created_at":"2026-06-24T15:01:05.812Z","updated_at":"2026-06-24T15:01:09.480Z","avatar_url":"https://github.com/hudsonbrendon.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/apple-logo.png\" alt=\"Apple\" width=\"320\"\u003e\n\u003c/p\u003e\n\n# apple-ble\n\n[![CI](https://github.com/hudsonbrendon/apple-ble/actions/workflows/ci.yml/badge.svg)](https://github.com/hudsonbrendon/apple-ble/actions/workflows/ci.yml)\n[![PyPI](https://img.shields.io/pypi/v/apple-ble)](https://pypi.org/project/apple-ble/)\n[![Python](https://img.shields.io/pypi/pyversions/apple-ble)](https://pypi.org/project/apple-ble/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n\nRead **AirPods battery** (case / left / right + charging) and detect nearby\n**Apple devices** from Python, straight off the unencrypted Apple Continuity\n*proximity-pairing* BLE advertisement — no pairing, no connection.\n\nThis library powers the\n[**Apple BLE Home Assistant integration**](https://github.com/hudsonbrendon/ha-apple-ble),\nbut works standalone in any Python project (or straight from the command line).\nThe parser is pure and dependency-free; `bleak` is only needed for the optional\nscanner CLI.\n\n\u003e **What works:** AirPods broadcast their battery in an unencrypted Continuity\n\u003e advert when the lid is opened. **What doesn't:** Apple Watch / iPhone do **not**\n\u003e put battery in their adverts — BLE can only tell you an Apple device is *nearby*.\n\u003e Apple rotates the BLE MAC (~15 min), so there is no stable per-device id.\n\n## Features\n\n- 🔋 **AirPods battery** — case, left, and right levels plus per-pod and case\n  charging flags, decoded from the manufacturer-`0x004C` proximity-pairing advert.\n- 🎧 **Model detection** — AirPods 1/2/3, Pro, Pro 2, Max.\n- 📡 **Presence-friendly** — exposes the Apple manufacturer id so callers can count\n  nearby Apple devices.\n- 🧪 **Pure parser** — `parse_proximity_pairing(bytes) -\u003e AirPodsData | None`, no I/O,\n  trivially unit-testable.\n- 🖥️ **CLI** — `apple-ble` scans and prints any AirPods it sees (needs the `cli` extra).\n\n## Requirements\n\n- Python **3.12** or newer.\n- A Bluetooth LE adapter (built-in or USB) — only for live scanning; the parser\n  itself needs nothing.\n\n## Installation\n\n```bash\npip install apple-ble            # core (parsing only)\npip install \"apple-ble[cli]\"     # + bleak scanner CLI\n```\n\n## CLI usage\n\n```bash\napple-ble    # 15s BLE scan; open your AirPods lid nearby and watch the battery\n```\n\n## Library usage\n\n```python\nfrom apple_ble import parse_proximity_pairing, APPLE_MANUFACTURER_ID\n\n# `payload` is manufacturer_data[76] from any BLE stack (bleak, Home Assistant, ...)\ndata = parse_proximity_pairing(payload)\nif data:\n    print(data.model, data.left_battery, data.right_battery, data.case_battery)\n    print(data.left_charging, data.right_charging, data.case_charging)\n```\n\n`parse_proximity_pairing` returns `None` for anything that isn't a complete\nAirPods proximity-pairing advert, so it is safe to feed it every Apple advert you\nsee and keep the non-`None` results.\n\n### API\n\n| Symbol | Description |\n|---|---|\n| `parse_proximity_pairing(data)` | Parse `manufacturer_data[76]` bytes into `AirPodsData`, or `None` if it isn't AirPods. |\n| `AirPodsData` | Frozen dataclass: `model`, `left_battery`, `right_battery`, `case_battery` (`int %` or `None`), `left_charging`, `right_charging`, `case_charging`. |\n| `decode_battery_nibble(nibble)` | Pure helper: a `0x0`–`0xF` battery nibble to a percentage (`None` when not present). |\n| `APPLE_MANUFACTURER_ID` | `76` (`0x004C`) — Apple's Bluetooth company id. |\n| `MODEL_BY_CHAR` | Mapping of the model nibble to a human model name. |\n\n## Credits\n\nContinuity reverse-engineering:\n[furiousMAC/continuity](https://github.com/furiousMAC/continuity),\n[kavishdevar/librepods](https://github.com/kavishdevar/librepods),\n[delphiki/AirStatus](https://github.com/delphiki/AirStatus),\n[d4rken-org/capod](https://github.com/d4rken-org/capod).\nAuthor [@hudsonbrendon](https://github.com/hudsonbrendon).\n\n## License\n\nMIT — see [LICENSE](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhudsonbrendon%2Fapple-ble","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhudsonbrendon%2Fapple-ble","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhudsonbrendon%2Fapple-ble/lists"}