forked from FOSS/BangleApps
Merge pull request #2487 from myxor/homeassistant008
Home Assistant: Allow swiping to switch triggers, standardize spellingsmaster
commit
4a7b525a94
|
@ -5,3 +5,4 @@
|
|||
0.05: Clkinfo improvements.
|
||||
0.06: Updated clkinfo icon.
|
||||
0.07: Update clock_info to avoid a redraw
|
||||
0.08: Allow swiping to switch triggers
|
||||
|
|
|
@ -1,28 +1,30 @@
|
|||
# Home Assistant
|
||||
This app integrates your BangleJs into the HomeAssistant.
|
||||
This app integrates your Bangle.js into the Home Assistant.
|
||||
|
||||
|
||||
# How to use
|
||||
Click on the left and right side of the screen to select the triggers that you
|
||||
configured. Click in the middle of the screen to send the trigger to HomeAssistant.
|
||||
Click on the left or right side of the screen to select the triggers that you configured.
|
||||
Swiping left or right works as well.
|
||||
|
||||
Click in the middle of the screen to send the trigger to Home Assistant via Gadgetbridge.
|
||||
|
||||

|
||||
|
||||
|
||||
# Initial Setup
|
||||
1.) First of all, make sure that HomeAssistant and the HomeAssistant Android App works.
|
||||
1.) First of all, make sure that Home Assistant and the Home Assistant Android Companion App work.
|
||||
|
||||
2.) Open your BangleJs Gadgetbridge App, click on the Settings icon of your BangleJs and enable "Allow Intent Access"
|
||||
2.) Open your Bangle.js Gadgetbridge App, click on the Settings icon of your Bangle.js and enable "Allow Intent Access"
|
||||
|
||||
3.) Enable sensor in HomeAssistant Andoird App/Configuration/Companion App/Manage Sensors/LastUpdate Trigger
|
||||
3.) Enable sensor in Home Assistant Android App/Configuration/Companion App/Manage Sensors/LastUpdate Trigger
|
||||
|
||||
4.) At the bottom of the same screen click on "Add New Intent" and enter "com.espruino.gadgetbridge.banglejs.HA"
|
||||
|
||||
5.) The HomeAssistant Android app must be restarted in order to listen for those actions
|
||||
5.) The Home Assistant Android app must be restarted in order to listen for those actions
|
||||
-- a "Force Stop" is necessary (through Android App settings) or restart your phone!
|
||||
|
||||
This setup must be done only once -- now you are ready to configure your BangleJS to
|
||||
control some devices or entities in your HomeAssistant :)
|
||||
control some devices or entities in your Home Assistant :)
|
||||
|
||||
|
||||
# Setup Trigger
|
||||
|
@ -35,7 +37,7 @@ The following icons are currently supported:
|
|||
- fire
|
||||
|
||||
|
||||
2.) Create an "automation" in the HomeAssistant WebUI for each trigger that you created on your BangleJs in order to tell HomeAssistant what you want to control. A sample configuration is shown in the image below -- I use this trigger to open the door:
|
||||
2.) Create an "automation" in the Home Assistant WebUI for each trigger that you created on your Bangle.js in order to tell Home Assistant what you want to control. A sample configuration is shown in the image below -- I use this trigger to open the door:
|
||||
|
||||

|
||||
|
||||
|
@ -48,7 +50,7 @@ This app also implements two default trigger that can always be used:
|
|||
- TRIGGER -- Will be sent whenever some trigger is executed. So you could generically listen to that.
|
||||
|
||||
|
||||
# How to use the library (ha.lib.js) in my own app/clk
|
||||
# How to use the library (ha.lib.js) in my own app/clock
|
||||
This app inlcludes a library that can be used by other apps or clocks
|
||||
to read all configured intents or to send a trigger. Example code:
|
||||
|
||||
|
@ -74,17 +76,20 @@ ha.sendTrigger("MY_CUSTOM_TRIGGER");
|
|||
# FAQ
|
||||
|
||||
## Sometimes the trigger is not executed
|
||||
While playing and testing a bit I found that it is very important that you allow the android HomeAssistant app, as well as BangleJs Gadgetbridge app to (1) run in background and (2), disable energy optimizations for both apps.
|
||||
Otherwise, Android could stop one of both apps and the trigger will never be sent to HomeAssistant...
|
||||
While playing and testing a bit I found that it is very important that you allow the android Home Assistant app, as well as Bangle.js Gadgetbridge app to (1) run in background and (2), disable energy optimizations for both apps.
|
||||
Otherwise, Android could stop one of both apps and the trigger will never be sent to Home Assistant...
|
||||
|
||||
If you still have problems, you can try another trick:
|
||||
Install "MacroDroid" from the Android AppStore and start the HomeAssistant App
|
||||
Install "MacroDroid" from the Android AppStore and start the Home Assistant App
|
||||
each time the "com.espruino.gadgetbridge.banglejs.HA" intent is send together
|
||||
with the extra trigger: APP_STARTED. Then whenever you open the app on your BangleJs
|
||||
it is ensured that HomeAssistant is running...
|
||||
with the extra trigger: APP_STARTED. Then whenever you open the app on your Bangle.js
|
||||
it is ensured that Home Assistant is running...
|
||||
|
||||
## Thanks to
|
||||
<a href="https://www.flaticon.com/free-icons/" title="Icons">Icons created by Flaticon</a>
|
||||
|
||||
## Creator
|
||||
- [David Peer](https://github.com/peerdavid).
|
||||
|
||||
## Contributor
|
||||
- [myxor](https://github.com/myxor)
|
||||
|
|
|
@ -28,28 +28,19 @@ function draw() {
|
|||
g.setColor(g.theme.bg).drawString(trigger.display, W/2, ypos);
|
||||
}
|
||||
|
||||
|
||||
Bangle.on('touch', function(btn, e){
|
||||
var left = parseInt(g.getWidth() * 0.3);
|
||||
var right = g.getWidth() - left;
|
||||
var isLeft = e.x < left;
|
||||
var isRight = e.x > right;
|
||||
|
||||
if(isRight){
|
||||
Bangle.buzz(40, 0.6);
|
||||
position += 1;
|
||||
position = position >= triggers.length ? 0 : position;
|
||||
draw();
|
||||
}
|
||||
|
||||
if(isLeft){
|
||||
function toLeft() {
|
||||
Bangle.buzz(40, 0.6);
|
||||
position -= 1;
|
||||
position = position < 0 ? triggers.length-1 : position;
|
||||
draw();
|
||||
}
|
||||
|
||||
if(!isRight && !isLeft){
|
||||
}
|
||||
function toRight() {
|
||||
Bangle.buzz(40, 0.6);
|
||||
position += 1;
|
||||
position = position >= triggers.length ? 0 : position;
|
||||
draw();
|
||||
}
|
||||
function sendTrigger() {
|
||||
ha.sendTrigger("TRIGGER");
|
||||
|
||||
// Now send the selected trigger
|
||||
|
@ -59,9 +50,34 @@ Bangle.on('touch', function(btn, e){
|
|||
Bangle.buzz(80, 0.6);
|
||||
}, 250);
|
||||
});
|
||||
}
|
||||
|
||||
Bangle.on('touch', function(btn, e){
|
||||
var left = parseInt(g.getWidth() * 0.3);
|
||||
var right = g.getWidth() - left;
|
||||
var isLeft = e.x < left;
|
||||
var isRight = e.x > right;
|
||||
|
||||
if(isLeft){
|
||||
toLeft();
|
||||
}
|
||||
if(isRight){
|
||||
toRight();
|
||||
}
|
||||
if(!isRight && !isLeft){
|
||||
sendTrigger();
|
||||
}
|
||||
});
|
||||
|
||||
Bangle.on("swipe", (lr,ud) => {
|
||||
if (lr == -1) {
|
||||
toLeft();
|
||||
}
|
||||
if (lr == 1) {
|
||||
toRight();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Send intent that the we started the app.
|
||||
ha.sendTrigger("APP_STARTED");
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"id": "ha",
|
||||
"name": "HomeAssistant",
|
||||
"version": "0.07",
|
||||
"description": "Integrates your BangleJS into HomeAssistant.",
|
||||
"name": "Home Assistant",
|
||||
"version": "0.08",
|
||||
"description": "Integrates your Bangle.js into Home Assistant.",
|
||||
"icon": "ha.png",
|
||||
"type": "app",
|
||||
"tags": "tool,clkinfo",
|
||||
|
|
Loading…
Reference in New Issue