Support display name and icons.

pull/1995/head
David Peer 2022-06-24 09:29:49 +02:00
parent e87d6aa26c
commit bd1a6459b2
7 changed files with 53 additions and 10 deletions

View File

@ -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
<a href="https://www.flaticon.com/free-icons/" title="Icons">Icons created by Flaticon</a>
## Creator
- [David Peer](https://github.com/peerdavid).

View File

@ -3,15 +3,39 @@ var W = g.getWidth(), H = g.getHeight();
var position=0;
var icon = {
// 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);

View File

@ -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"},

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
apps/ha/screenshot_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
apps/ha/screenshot_3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -3,9 +3,15 @@
<link rel="stylesheet" href="../../css/spectre.min.css">
</head>
<body>
triggers
<p>Json file [{display: "Text", trigger: "TRIGGER_1", icon: null}, ...]</p>
<p><textarea id="triggers"></textarea></p>
<h3>Upload Tiggers</h3>
<p>You must upload a list of json objects -- an example is given below</p>
<p><textarea id="triggers">
[
{"display": "Open", "trigger": "OPEN_DOOR", "icon":"door"},
{"display": "Office", "trigger": "TOGGLE_LIGHT", "icon":"light"},
{"display": "Living Room", "trigger": "OVEN", "icon":"fire"}
]
</textarea></p>
<p><button id="upload" class="btn btn-primary">Upload</button></p>
<script src="../../core/lib/customize.js"></script>