Skip to content

Commit

Permalink
Merge pull request #3474 from deirdreobyrne/master
Browse files Browse the repository at this point in the history
BTHome battery level broadcast for e.g. Home Assistant
  • Loading branch information
bobrippling committed Jun 28, 2024
2 parents 9050ffe + e48d253 commit bb02a89
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions apps/bootbthomebatt/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.01: Initial release.
11 changes: 11 additions & 0 deletions apps/bootbthomebatt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# BLE BTHome Battery Service

Broadcasts battery remaining percentage over BLE using the [BTHome protocol](https://bthome.io/) - which makes for easy integration into [Home Assistant](https://www.home-assistant.io/)

## Usage

This boot code runs in the background and has no user interface.

## Creator

[Deirdre O'Byrne](https://github.com/deirdreobyrne)
Binary file added apps/bootbthomebatt/bluetooth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions apps/bootbthomebatt/boot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var btHomeBatterySequence = 0;

function advertiseBTHomeBattery() {
var advert = [0x40, 0x00, btHomeBatterySequence, 0x01, E.getBattery()];

require("ble_advert").set(0xFCD2, advert);
btHomeBatterySequence = (btHomeBatterySequence + 1) & 255;
}

setInterval(function() {
advertiseBTHomeBattery();
}, 300000); // update every 5 min

advertiseBTHomeBattery();
15 changes: 15 additions & 0 deletions apps/bootbthomebatt/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"id": "bootbthomebatt",
"name": "BLE BTHome Battery Service",
"shortName": "BTHome Battery Service",
"version": "0.01",
"description": "Broadcasts battery remaining over bluetooth using the BTHome protocol - makes for easy integration with Home Assistant.\n",
"icon": "bluetooth.png",
"type": "bootloader",
"tags": "battery,ble,bluetooth,bthome",
"supports": ["BANGLEJS2"],
"readme": "README.md",
"storage": [
{"name":"bthomebat.boot.js","url":"boot.js"}
]
}

0 comments on commit bb02a89

Please sign in to comment.