diff --git a/apps/ha/README.md b/apps/ha/README.md index 35a90ea88..c51da967a 100644 --- a/apps/ha/README.md +++ b/apps/ha/README.md @@ -23,7 +23,14 @@ This setup must be done only once -- now you are ready to configure your BangleJ control some devices or entities in your HomeAssistant :) # Setup Trigger -1.) Upload the app and all corresponding triggers through the AppStore UI. For example I entered "DOOR,LIGHT,OVEN". The list will be shown in your BangleJs in the corresponding order so enter more important triggers first. +1.) Upload the app and all corresponding triggers through the AppStore UI. You must specify +the display name, the trigger as well as an icon. +The following icons are currently supported: +- ha (default) +- light +- door +- 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: @@ -40,5 +47,8 @@ add an action also for that.* 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... +## Thanks to +Icons created by Flaticon + ## Creator - [David Peer](https://github.com/peerdavid). diff --git a/apps/ha/ha.app.js b/apps/ha/ha.app.js index 4b85fbf56..ee30a66e9 100644 --- a/apps/ha/ha.app.js +++ b/apps/ha/ha.app.js @@ -3,15 +3,39 @@ var W = g.getWidth(), H = g.getHeight(); var position=0; -var icon = { - width : 48, height : 48, bpp : 1, - transparent : 0, - buffer : require("heatshrink").decompress(atob("AD8BwAFDg/gAocP+AFDj4FEn/8Aod//wFD/1+FAf4j+8AoMD+EPDAUH+OPAoUP+fPAoUfBYk/C4l/EYIwC//8n//FwIFEgYFD4EH+E8nkP8BdBAonjjk44/wj/nzk58/4gAFDF4PgCIMHAoPwhkwh4FB/EEkEfIIWAHwIFC4A+BAoXgg4FDL4IFDL4IFDLIYFkAEQA==")) +// Note: All icons should have 48x48 pixels +function getIcon(icon){ + if(icon == "light"){ + return { + width : 48, height : 48, bpp : 1, + transparent : 0, + buffer : require("heatshrink").decompress(atob("AAMBwAFE4AFDgYFJjgFBnAFBjwXBvAFBh4jBuAFCAQPwAQMHAQPgEQQCBEgcf/AvDn/8Aof//5GDAoJOBh+BAoOB+EP8YFB4fwgfnAoPnGANHAoPjHYQFBHYQFd44pDg47C4/gh/DIIZNFLIplGgF//wFIgZ9BRIUHRII7Ch4FBUIUOAoKzCjwFEhgCBmDpIVooFFh4oCAA4LFC5b7BAob1BAYI=")) + }; + } else if(icon == "door"){ + return { + width : 48, height : 48, bpp : 1, + transparent : 0, + buffer : require("heatshrink").decompress(atob("AAM4Aok/4AED///Aov4Aon8DgQGBAv4FpnIFKJv4FweAQFFAgQFB8AFDnADC")) + }; + } else if (icon == "fire"){ + return { + width : 48, height : 48, bpp : 1, + transparent : 0, + buffer : require("heatshrink").decompress(atob("ABsDAokBwAFE4AFE8AFE+AFE/AFJgf8Aon+AocHAokP/8QAokYAoUfAok//88ApF//4kDAo//AgMQAgIFCjgFEjwFCOYIFFHQIFDn/+AoJ/BAoIqBAoN//xCBAoI5BDIPAgP//gFB8AFChYFBgf//EJAogOBAoSgBAoMHAQIFEFgXAAoJEBv4FCNoQFGVYd/wAFEYYIFIvwCBDoV8UwQCBcgUPwDwDfQMBaIYADA")) + }; + } + + // Default is always the HA icon + return { + width : 48, height : 48, bpp : 1, + transparent : 0, + buffer : require("heatshrink").decompress(atob("AD8BwAFDg/gAocP+AFDj4FEn/8Aod//wFD/1+FAf4j+8AoMD+EPDAUH+OPAoUP+fPAoUfBYk/C4l/EYIwC//8n//FwIFEgYFD4EH+E8nkP8BdBAonjjk44/wj/nzk58/4gAFDF4PgCIMHAoPwhkwh4FB/EEkEfIIWAHwIFC4A+BAoXgg4FDL4IFDL4IFDLIYFkAEQA==")) + }; }; // Try to read custom actions, otherwise use default var triggers = [ - {display: "Not found.", trigger: "NOP", icon: null}, + {display: "Not found.", trigger: "NOP", icon: "ha"}, ]; try{ @@ -31,6 +55,7 @@ function draw() { var w = g.stringWidth(trigger.display); g.setFontAlign(-1,-1); + var icon = getIcon(trigger.icon); g.setColor(g.theme.fg).drawImage(icon, 12, H/5-2); g.drawString("Home", icon.width + 20, H/5); g.drawString("Assistant", icon.width + 18, H/5+24); diff --git a/apps/ha/metadata.json b/apps/ha/metadata.json index eea1b6905..c7ba2f46b 100644 --- a/apps/ha/metadata.json +++ b/apps/ha/metadata.json @@ -11,8 +11,10 @@ "custom": "trigger.html", "screenshots": [ {"url":"screenshot.png"}], + {"url":"screenshot_2.png"}], + {"url":"screenshot_3.png"}], "data": [ - {"name":"ha.trigger.txt" } + {"name":"ha.trigger.json" } ], "storage": [ {"name":"ha.app.js","url":"ha.app.js"}, diff --git a/apps/ha/screenshot.png b/apps/ha/screenshot.png index ea5a41ed9..dc059e2de 100644 Binary files a/apps/ha/screenshot.png and b/apps/ha/screenshot.png differ diff --git a/apps/ha/screenshot_2.png b/apps/ha/screenshot_2.png new file mode 100644 index 000000000..55019c3b1 Binary files /dev/null and b/apps/ha/screenshot_2.png differ diff --git a/apps/ha/screenshot_3.png b/apps/ha/screenshot_3.png new file mode 100644 index 000000000..b9eae0b74 Binary files /dev/null and b/apps/ha/screenshot_3.png differ diff --git a/apps/ha/trigger.html b/apps/ha/trigger.html index bcb3c72b7..60fedda7a 100644 --- a/apps/ha/trigger.html +++ b/apps/ha/trigger.html @@ -3,9 +3,15 @@ - triggers -

Json file [{display: "Text", trigger: "TRIGGER_1", icon: null}, ...]

-

+

Upload Tiggers

+

You must upload a list of json objects -- an example is given below

+