Skip to content

Commit

Permalink
Add Home Assistant Bluetooth LED
Browse files Browse the repository at this point in the history
  • Loading branch information
gfwilliams committed Oct 2, 2024
1 parent 2f9ce82 commit d89a0b8
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 0 deletions.
12 changes: 12 additions & 0 deletions apps.json
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,18 @@
{"name":".bootcde","url":"app.js"}
]
},
{ "id": "ha_led",
"name": "Home Assistant Bluetooth LED",
"icon": "icon.png",
"version":"0.01",
"description": "Turn your Bluetooth Espruino device into a LED that can be controlled from Home assistant",
"tags": "bluetooth,homeassistant,LED",
"readme": "README.md",
"needsFeatures":["BLE","RGBLED"],
"storage": [
{"name":".bootcde","url":"app.js"}
]
},
{ "id": "knobbutton",
"name": "Knob Button",
"icon": "icon.png",
Expand Down
1 change: 1 addition & 0 deletions apps/ha_led/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.01: New App!
12 changes: 12 additions & 0 deletions apps/ha_led/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Home Assistant Bluetooth LED

Turn your Bluetooth Espruino device into a LED that can be controlled from Home assistant.

This uses the [LED BLE Library](https://www.espruino.com/ble_led) which makes Espruino appear as a BLE lightbulb which
is detected by the [LED BLE integration](https://www.home-assistant.io/integrations/led_ble/) in https://www.home-assistant.io/

This is based on https://www.espruino.com/BTHome and https://www.espruino.com/Smart+Meter

## Usage

Install the app and disconnect, and a device called `LEDBLE` should appear in Home Assistant. Turning it on/off or changing the colour will change the built-in LEDs.
10 changes: 10 additions & 0 deletions apps/ha_led/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require("ble_led").setup(function(state) {
if (state.on) {
// state.r/g/b arr in the range 0..255
LED1.pwm(state.r/256);
LED2.pwm(state.g/256);
LED3.pwm(state.b/256);
} else {
digitalWrite([LED1,LED2,LED3],0);
}
});
Binary file added apps/ha_led/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d89a0b8

Please sign in to comment.