1
0
Fork 0

bthome 0.02: Fix double-button press if you press the next button within 30s (#3243)

master
Gordon Williams 2024-03-08 09:26:38 +00:00
parent 905a7b11b2
commit 306ccb3fe3
3 changed files with 9 additions and 6 deletions

View File

@ -1 +1,2 @@
0.01: New App!
0.02: Fix double-button press if you press the next button within 30s (#3243)

View File

@ -19,12 +19,16 @@ Bangle.btHomeData = [];
/* Global function to allow advertising BTHome adverts
extras = array of extra data, see require("BTHome").getAdvertisement - can add {n:0/1/2} for different instances
options = { event : an event - advertise fast, and when connected
options = {
event : an event - advertise fast, and when connected
}
*/
Bangle.btHome = function(extras, options) {
options = options||{};
if(extras) { // update with extras
// clear any existing events
Bangle.btHomeData.forEach(d => {if (d.type=="button_event") d.v="none";});
// update with extras
if (extras) {
extras.forEach(extra => {
var n = Bangle.btHomeData.find(b=>b.type==extra.type && b.n==extra.n);
if (n) Object.assign(n, extra);
@ -60,9 +64,7 @@ Bangle.btHome = function(extras, options) {
if (Bangle.btHomeTimeout) clearTimeout(Bangle.btHomeTimeout);
Bangle.btHomeTimeout = setTimeout(function() {
delete Bangle.btHomeTimeout;
// clear events
Bangle.btHomeData.forEach(d => {if (d.type=="button_event") d.v="none";});
// update
Bangle.btHome();
},updateTimeout);
}, updateTimeout);
};

View File

@ -1,7 +1,7 @@
{ "id": "bthome",
"name": "BTHome",
"shortName":"BTHome",
"version":"0.01",
"version":"0.02",
"description": "Allow your Bangle to advertise with BTHome and send events to Home Assistant via Bluetooth",
"icon": "icon.png",
"type": "app",