From 33dc0c566dd639bdc87a694b2e71129fdfa30326 Mon Sep 17 00:00:00 2001 From: David Peer Date: Sat, 25 Jun 2022 10:52:42 +0200 Subject: [PATCH] Add generic intent "TRIGGER" whenever a trigger is send. --- apps/ha/README.md | 7 +++++-- apps/ha/ha.app.js | 9 +++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/ha/README.md b/apps/ha/README.md index 46c3b8afe..8005421f1 100644 --- a/apps/ha/README.md +++ b/apps/ha/README.md @@ -38,8 +38,11 @@ The following icons are currently supported: 3.) Don't forget to select the action that should be executed at the bottom of each automation. -*Note: There is also an automatic trigger send when the app is started (APP_STARTED) -- so you could -add an action also for that.* +# Default Trigger +This app also implements two default trigger that can always be used: +- APP_STARTED -- Will be sent whenever the app is started. So you could do some actions already when the app is sarted without the need of any user interaction. +- TRIGGER -- Will be sent whenever some trigger is executed. So you could generically listen to that. + # FAQ diff --git a/apps/ha/ha.app.js b/apps/ha/ha.app.js index 17290ab26..85f926138 100644 --- a/apps/ha/ha.app.js +++ b/apps/ha/ha.app.js @@ -101,15 +101,22 @@ Bangle.on('touch', function(btn, e){ Bangle.buzz(40, 0.6); position += 1; position = position >= triggers.length ? 0 : position; + draw(); } if(isLeft){ Bangle.buzz(40, 0.6); position -= 1; position = position < 0 ? triggers.length-1 : position; + draw(); } if(!isRight && !isLeft){ + + // Send a default intent that we triggered something. + sendIntent("TRIGGER"); + + // Now send the selected trigger Bangle.buzz(80, 0.6).then(()=>{ sendIntent(triggers[position].trigger); setTimeout(()=>{ @@ -117,8 +124,6 @@ Bangle.on('touch', function(btn, e){ }, 250); }); } - - draw(); }); // Send intent that the we started the app.