mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-16 11:28:40 +00:00
Compare commits
18 Commits
Author | SHA1 | Date | |
---|---|---|---|
8c5aa820ef | |||
a13f04fa6c | |||
143bcf08a7 | |||
ee3b2abed2 | |||
44d5bf8e93 | |||
fae2241f01 | |||
42e89906f6 | |||
8c0540ee45 | |||
ea58171b2f | |||
531c3e972e | |||
2d07eaa9c6 | |||
0e443e33d3 | |||
e616a6bd76 | |||
239f8a793b | |||
fc22ca3497 | |||
1df64286f0 | |||
0ab9cb800a | |||
3fe48be756 |
67
README.md
67
README.md
@ -35,7 +35,10 @@ Example schema as shown in the images:
|
||||
"entity": "script.food_on_table",
|
||||
"name": "Food is Ready!",
|
||||
"type": "tap",
|
||||
"service" : "script.turn_on"
|
||||
"tap_action": {
|
||||
"service": "script.turn_on",
|
||||
"confirm": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"entity": "light.bedside_light_switch",
|
||||
@ -84,13 +87,17 @@ Example schema as shown in the images:
|
||||
"entity": "automation.turn_off_usb_chargers",
|
||||
"name": "Turn off USBs",
|
||||
"type": "tap",
|
||||
"service" : "automation.trigger"
|
||||
"tap_action": {
|
||||
"service": "automation.trigger"
|
||||
}
|
||||
},
|
||||
{
|
||||
"entity": "scene.tv_light",
|
||||
"name": "TV Lights Scene",
|
||||
"type": "tap",
|
||||
"service": "scene.turn_on"
|
||||
"tap_action": {
|
||||
"service": "scene.turn_on"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -112,9 +119,9 @@ The example JSON shows an example usage of each of these Home Assistance entity
|
||||
|------------|:---:|:------:|
|
||||
| Switch | ❌ | ✅ |
|
||||
| Light | ❌ | ✅ |
|
||||
| Automation | ✅ | ✅ |
|
||||
| Script | ✅ | ❌ |
|
||||
| Scene | ✅ | ❌ |
|
||||
| Automation | ✅ | ✅ |
|
||||
| Script | ✅ | ❌ |
|
||||
| Scene | ✅ | ❌ |
|
||||
|
||||
NB. All 'tap' items must specify a 'service' tag.
|
||||
|
||||
@ -122,6 +129,47 @@ Possible future extensions might include specifying the alternative texts to use
|
||||
|
||||
The [schema](https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json) is checked by using a URL directly back to this GitHub source repository, so you do not need to install that file. You can just copy & paste your entity names from the YAML configuration files used to configure Home Assistant. With a submenu, there's a difference between "title" and "name". The "name" goes on the menu item, and the "title" at the head of the submenu. If your dashboard definition fails to meet the schema, the application will simply drop items with the wrong field names without warning.
|
||||
|
||||
### Old depricated format
|
||||
|
||||
Version 1.5 brought in a change to the JSON schema so the follow old format remains useable but is no longer favoured. The schema now marks it as 'depracated' to nudge people over.
|
||||
|
||||
```json
|
||||
{
|
||||
"entity": "scene.tv_light",
|
||||
"name": "TV Lights Scene",
|
||||
"type": "tap",
|
||||
"service": "scene.turn_on"
|
||||
}
|
||||
```
|
||||
|
||||
The above should be replaced by the following:
|
||||
|
||||
```json
|
||||
{
|
||||
"entity": "scene.tv_light",
|
||||
"name": "TV Lights Scene",
|
||||
"type": "tap",
|
||||
"tap_action": {
|
||||
"service": "scene.turn_on"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This allows the `confirm` field to be accommodated in the `tap_action` along side the `service` tag, and follows the Home Assistant YAML format more closely.
|
||||
|
||||
## Editing the JSON file
|
||||
|
||||
You have options. The first is what we use.
|
||||
1. **Best!** Use the [Studio Code Server](https://community.home-assistant.io/t/home-assistant-community-add-on-visual-studio-code/107863) addon for Home Assistant. You can then edit your JSON file in place.
|
||||
2. Locally installed VSCode, or if not installed
|
||||
3. try the on-line version at https://vscode.dev/
|
||||
|
||||
Paste in your JSON (and change the file type to JSON if not saving), it will then verify your file format and schema for you, highlighting any errors for you to fix.
|
||||
|
||||
A failure to get the file format right tends to mean that the response to the application errors with `INVALID_HTTP_BODY_IN_NETWORK_RESPONSE` (code of -400). This means the response did not contain JSON, it was probably an error message in plain text that could not be parsed by the Connect IQ API call. See [Toybox.Communications](https://developer.garmin.com/connect-iq/api-docs/Toybox/Communications.html) for the list of error code you might be present with on your device.
|
||||
|
||||
Make sure you can browse to the URL of your JSON file in a standard web browser to make sure it is accessible.
|
||||
|
||||
## API Key Creation
|
||||
|
||||
Having created your JSON definition for your dashboard, you need to create an API key for your personal account on Home Assistant.
|
||||
@ -130,6 +178,8 @@ Having created your JSON definition for your dashboard, you need to create an AP
|
||||
|
||||
Having created that token, before you dismiss the dialogue box with the value you will never see again, copy it somewhere safe. You need to paste this into the Garmin Application's settings.
|
||||
|
||||
**Please, please, please!** Copy and paste this API key, do not retype as it will be wrong.
|
||||
|
||||
## Settings
|
||||
|
||||
<img src="images/GarminHomeAssistantSettings.png" width="400" title="Application Settings"/>
|
||||
@ -170,4 +220,7 @@ When you change the JSON file defining your dashboard, you must exit the applica
|
||||
| 1.1 | Updated for 54 more devices, 80 in total. Scene support. Added vibrate acknowledgement for tap-based menu items. Falls back to a custom visual confirmation in the absence of 'toast' and vibrate support. Bug fix for large menus needing status updates. |
|
||||
| 1.2 | Do not crash on zero items to update. Report unreachable URLs. Verify API URL does not have a trailing slash '/'. Increased HTTP response diagnosis. Reduced minimum API Level required from 3.3.0 to 3.1.0 to allow more device "part numbers" to be satisfied. |
|
||||
| 1.3 | Tap for scripts was working in emulation but not on some phones. Decision is to make the 'service' field in the JSON compulsory for 'tap' menu items. This is a breaking change, but for many might be a fix for something not working correctly. Improve language support, we can now accept language corrections and prevent the automated translation of strings from clobbering manually refined entries. Thank you to two new contributors. |
|
||||
| 1.4 | New lean user Interface with thanks to [SomeoneOnEarth](https://github.com/Someone0nEarth) for their contribution which is now the default. If you prefer the old style you can still select it in the settings. The provision of a 'service' tag is now not just heavily suggested by the JSON schema, it is enforced in code. With appologies to anyone suffering a breakage as a result. |
|
||||
| 1.4 | New lean user Interface with thanks to [SomeoneOnEarth](https://github.com/Someone0nEarth) for their contribution which is now the default. If you prefer the old style you can still select it in the settings. The provision of a 'service' tag is now not just heavily suggested by the JSON schema, it is enforced in code. With apologies to anyone suffering a breakage as a result. |
|
||||
| 1.5 | <img src="images/confirmation_view.jpg" width="200" title="Confirmation View" style="float:right"/> Added an optional confirmation dialogue view to prevent accidental execution of actions on mistaken tap. This also brings a change in the JSON schema to allow an optional field to specify that the confirmation should be used for a menu item. As we are now maturing and adding features we have decided to mitigate breaking changes to the JSON schema by being more careful to adopt the Home Assistant schema (noting there is a 1:1 mapping between YAML and JSON). This change does deprecate the top level `service` tag in favour of `tag_action` containing multiple fields including `service` & `confirm`. Users should migrate to the new format for the new functionality, but the timescale for actual deprecation are long and undecided. |
|
||||
| 1.6 | Added a user configurable 'timeout' in seconds so that when no action is taken the application automatically closes, stopping the continuous polling for changes of status and hence saving the drain on the battery. This can be disabled with timeout=0. |
|
||||
| 1.7 | Added timeout to confirmation views so that when used for security devices it does not linger when left unconfirmed. Thanks to [Jan Schneider](https://github.com/j-a-n) for the contribution. Known bug for devices not supporting [`WatchUi.getCurrentView()`](https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi.html#getCurrentView-instance_function) API call which is only available on API Level 3.4.0, e.g. Vivoactive 4S. |
|
||||
|
@ -12,8 +12,12 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"entity": { "$ref": "#/$defs/entity" },
|
||||
"name": { "type": "string" },
|
||||
"type": { "const": "toggle" }
|
||||
"name": { "title": "Your familiar name", "type": "string" },
|
||||
"type": {
|
||||
"title": "Menu item type",
|
||||
"description": "One of 'tap, 'toggle' or 'group'.",
|
||||
"const": "toggle"
|
||||
}
|
||||
},
|
||||
"required": ["entity", "name", "type"],
|
||||
"additionalProperties": false
|
||||
@ -22,20 +26,37 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"entity": { "$ref": "#/$defs/entity" },
|
||||
"name": { "type": "string" },
|
||||
"type": { "const": "tap" },
|
||||
"service": { "$ref": "#/$defs/entity" }
|
||||
"name": { "title": "Your familiar name", "type": "string" },
|
||||
"type": {
|
||||
"title": "Menu item type",
|
||||
"description": "One of 'tap, 'toggle' or 'group'.",
|
||||
"const": "tap"
|
||||
},
|
||||
"service": {
|
||||
"$ref": "#/$defs/entity",
|
||||
"deprecated": true,
|
||||
"title": "Schema change:",
|
||||
"description": "Use 'tap_action' instead to mirror Home Assistant."
|
||||
},
|
||||
"tap_action": { "$ref": "#/$defs/action" }
|
||||
},
|
||||
"required": ["entity", "name", "type", "service"],
|
||||
"oneOf": [
|
||||
{ "required": ["entity", "name", "type", "service"] },
|
||||
{ "required": ["entity", "name", "type", "tap_action"] }
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
"menu": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"entity": { "$ref": "#/$defs/entity" },
|
||||
"name": { "type": "string" },
|
||||
"name": { "title": "Your familiar name", "type": "string" },
|
||||
"title": { "type": "string" },
|
||||
"type": { "const": "group" },
|
||||
"type": {
|
||||
"title": "Menu item type",
|
||||
"description": "One of 'tap, 'toggle' or 'group'.",
|
||||
"const": "group"
|
||||
},
|
||||
"items": { "$ref": "#/$defs/items" }
|
||||
},
|
||||
"required": ["entity", "name", "title", "type", "items"],
|
||||
@ -52,8 +73,23 @@
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"title": "Home Assistant entity name",
|
||||
"type": "string",
|
||||
"pattern": "^[^.]+\\.[^.]+$"
|
||||
},
|
||||
"action": {
|
||||
"title": "Action",
|
||||
"description": "'confirm' field is optional.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"service": { "$ref": "#/$defs/entity" },
|
||||
"confirm": {
|
||||
"type": "boolean",
|
||||
"default": false,
|
||||
"description": "Confirm the action before execution as a precaution."
|
||||
}
|
||||
},
|
||||
"required": ["service"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
images/confirmation_view.jpg
Normal file
BIN
images/confirmation_view.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
@ -21,7 +21,7 @@
|
||||
Use "Monkey C: Edit Application" from the Visual Studio Code command palette
|
||||
to update the application attributes.
|
||||
-->
|
||||
<iq:application id="40131e87-31ff-454b-a8e2-92276ee399d6" type="watch-app" name="@Strings.AppName" entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.1.0">
|
||||
<iq:application id="98c36259-498a-4458-9cef-74a273ad2bc3" type="watch-app" name="@Strings.AppName" entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.1.0">
|
||||
<!--
|
||||
Use the following from the Visual Studio Code comand palette to edit
|
||||
the build targets:
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">عن</string>
|
||||
<string id="MenuItemTap">مقبض</string>
|
||||
<string id="MenuItemMenu">قائمة طعام</string>
|
||||
<string id="Confirm">بالتأكيد؟</string>
|
||||
<string id="NoPhone">لا يوجد اتصال الهاتف</string>
|
||||
<string id="NoInternet">لا يوجد اتصال بالإنترنت</string>
|
||||
<string id="NoResponse">لا توجد استجابة، تحقق من الاتصال بالإنترنت</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Изкл</string>
|
||||
<string id="MenuItemTap">Докоснете</string>
|
||||
<string id="MenuItemMenu">Меню</string>
|
||||
<string id="Confirm">Сигурен?</string>
|
||||
<string id="NoPhone">Няма телефонна връзка</string>
|
||||
<string id="NoInternet">Няма интернет връзка</string>
|
||||
<string id="NoResponse">Няма отговор, проверете интернет връзката</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Vypnuto</string>
|
||||
<string id="MenuItemTap">Klepněte</string>
|
||||
<string id="MenuItemMenu">Jídelní lístek</string>
|
||||
<string id="Confirm">Tak určitě?</string>
|
||||
<string id="NoPhone">Žádné telefonní spojení</string>
|
||||
<string id="NoInternet">Žádné internetové připojení</string>
|
||||
<string id="NoResponse">Žádná odpověď, zkontrolujte připojení k internetu</string>
|
||||
@ -32,7 +33,7 @@
|
||||
<string id="NoApiUrl">V nastavení aplikace není žádná adresa URL API</string>
|
||||
<string id="NoConfigUrl">V nastavení aplikace není žádná konfigurační URL</string>
|
||||
<string id="ApiFlood">Příliš rychlá volání API. Zpomalte prosím své požadavky.</string>
|
||||
<string id="ApiUrlNotFound">Adresa URL nenalezena. Potenciální chyba adresy URL rozhraní API v nastavení.</string>
|
||||
<string id="ApiUrlNotFound">Adresa URL nenalezena. Potenciální chyba URL API v nastavení.</string>
|
||||
<string id="ConfigUrlNotFound">Adresa URL nenalezena. Potenciální chyba konfigurační adresy URL v nastavení.</string>
|
||||
<string id="UnhandledHttpErr">Požadavek HTTP vrátil kód chyby =</string>
|
||||
<string id="TrailingSlashErr">Adresa URL rozhraní API nesmí mít koncové lomítko „/“</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Af</string>
|
||||
<string id="MenuItemTap">Tryk på</string>
|
||||
<string id="MenuItemMenu">Menu</string>
|
||||
<string id="Confirm">Jo da?</string>
|
||||
<string id="NoPhone">Ingen telefonforbindelse</string>
|
||||
<string id="NoInternet">Ingen internetforbindelse</string>
|
||||
<string id="NoResponse">Intet svar, tjek internetforbindelse</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Aus</string>
|
||||
<string id="MenuItemTap">Antippen</string>
|
||||
<string id="MenuItemMenu">Menü</string>
|
||||
<string id="Confirm">Sicher?</string>
|
||||
<string id="NoPhone">Keine Telefonverbindung</string>
|
||||
<string id="NoInternet">Keine Internetverbindung</string>
|
||||
<string id="NoResponse">Keine Antwort, überprüfen Sie die Internetverbindung</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Uit</string>
|
||||
<string id="MenuItemTap">Kraan</string>
|
||||
<string id="MenuItemMenu">Menu</string>
|
||||
<string id="Confirm">Zeker?</string>
|
||||
<string id="NoPhone">Geen telefoonverbinding</string>
|
||||
<string id="NoInternet">Geen internet verbinding</string>
|
||||
<string id="NoResponse">Geen reactie, controleer de internetverbinding</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Väljas</string>
|
||||
<string id="MenuItemTap">Puudutage</string>
|
||||
<string id="MenuItemMenu">Menüü</string>
|
||||
<string id="Confirm">Muidugi?</string>
|
||||
<string id="NoPhone">Telefoniühendus puudub</string>
|
||||
<string id="NoInternet">Interneti-ühendus puudub</string>
|
||||
<string id="NoResponse">Ei reageeri, kontrollige Interneti-ühendust</string>
|
||||
@ -31,7 +32,7 @@
|
||||
<string id="NoAPIKey">Rakenduse seadetes pole API-võtit</string>
|
||||
<string id="NoApiUrl">Rakenduse seadetes pole API URL-i</string>
|
||||
<string id="NoConfigUrl">Rakenduse seadetes pole konfiguratsiooni URL-i</string>
|
||||
<string id="ApiFlood">API-kõned liiga kiired. Palun aeglustage oma taotlusi.</string>
|
||||
<string id="ApiFlood">API-kutsed liiga kiired. Palun aeglustage oma taotlusi.</string>
|
||||
<string id="ApiUrlNotFound">URL-i ei leitud. Võimalik API URL-i viga seadetes.</string>
|
||||
<string id="ConfigUrlNotFound">URL-i ei leitud. Võimalik konfiguratsiooni URL-i viga seadetes.</string>
|
||||
<string id="UnhandledHttpErr">HTTP päring tagastas veakoodi =</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Vinossa</string>
|
||||
<string id="MenuItemTap">Napauta</string>
|
||||
<string id="MenuItemMenu">Valikko</string>
|
||||
<string id="Confirm">Varma?</string>
|
||||
<string id="NoPhone">Ei puhelinyhteyttä</string>
|
||||
<string id="NoInternet">Ei Internet-yhteyttä</string>
|
||||
<string id="NoResponse">Ei vastausta, tarkista Internet-yhteys</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Désactivé</string>
|
||||
<string id="MenuItemTap">Clic</string>
|
||||
<string id="MenuItemMenu">Menu</string>
|
||||
<string id="Confirm">Bien sûr?</string>
|
||||
<string id="NoPhone">Pas de connexion téléphonique</string>
|
||||
<string id="NoInternet">Pas de connexion Internet</string>
|
||||
<string id="NoResponse">Pas de réponse, vérifiez la connexion Internet</string>
|
||||
|
@ -24,12 +24,13 @@
|
||||
<string id="MenuItemOff">Μακριά από</string>
|
||||
<string id="MenuItemTap">Παρακέντηση</string>
|
||||
<string id="MenuItemMenu">Μενού</string>
|
||||
<string id="Confirm">Σίγουρος?</string>
|
||||
<string id="NoPhone">Δεν υπάρχει σύνδεση τηλεφώνου</string>
|
||||
<string id="NoInternet">Δεν υπάρχει σύνδεση στο διαδίκτυο</string>
|
||||
<string id="NoResponse">Καμία απάντηση, ελέγξτε τη σύνδεση στο Διαδίκτυο</string>
|
||||
<string id="NoMenu">Σφάλμα ανάκτησης μενού</string>
|
||||
<string id="NoAPIKey">Δεν υπάρχει κλειδί API στις ρυθμίσεις της εφαρμογής</string>
|
||||
<string id="NoApiUrl">Δεν υπάρχει διεύθυνση URL API στις ρυθμίσεις της εφαρμογής</string>
|
||||
<string id="NoApiUrl">Δεν υπάρχει URL API στις ρυθμίσεις της εφαρμογής</string>
|
||||
<string id="NoConfigUrl">Δεν υπάρχει διεύθυνση URL διαμόρφωσης στις ρυθμίσεις της εφαρμογής</string>
|
||||
<string id="ApiFlood">Κλήσεις API πολύ γρήγορες. Παρακαλώ επιβραδύνετε τα αιτήματά σας.</string>
|
||||
<string id="ApiUrlNotFound">Η διεύθυνση URL δεν βρέθηκε. Πιθανό σφάλμα διεύθυνσης URL API στις ρυθμίσεις.</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">כבוי</string>
|
||||
<string id="MenuItemTap">בֶּרֶז</string>
|
||||
<string id="MenuItemMenu">תַפרִיט</string>
|
||||
<string id="Confirm">בטוח?</string>
|
||||
<string id="NoPhone">אין חיבור לטלפון</string>
|
||||
<string id="NoInternet">אין חיבור אינטרנט</string>
|
||||
<string id="NoResponse">אין תגובה, בדוק חיבור לאינטרנט</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Isključeno</string>
|
||||
<string id="MenuItemTap">Dodirnite</string>
|
||||
<string id="MenuItemMenu">Jelovnik</string>
|
||||
<string id="Confirm">Naravno?</string>
|
||||
<string id="NoPhone">Nema telefonske veze</string>
|
||||
<string id="NoInternet">Nema internetske veze</string>
|
||||
<string id="NoResponse">Nema odgovora, provjerite internetsku vezu</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Ki</string>
|
||||
<string id="MenuItemTap">Koppintson a</string>
|
||||
<string id="MenuItemMenu">Menü</string>
|
||||
<string id="Confirm">Biztos?</string>
|
||||
<string id="NoPhone">Nincs telefonkapcsolat</string>
|
||||
<string id="NoInternet">Nincs internetkapcsolat</string>
|
||||
<string id="NoResponse">Nincs válasz, ellenőrizze az internetkapcsolatot</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Mati</string>
|
||||
<string id="MenuItemTap">Mengetuk</string>
|
||||
<string id="MenuItemMenu">Menu</string>
|
||||
<string id="Confirm">Tentu?</string>
|
||||
<string id="NoPhone">Tidak ada koneksi Telepon</string>
|
||||
<string id="NoInternet">Tidak ada koneksi internet</string>
|
||||
<string id="NoResponse">Tidak Ada Respon, periksa koneksi Internet</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Spento</string>
|
||||
<string id="MenuItemTap">Rubinetto</string>
|
||||
<string id="MenuItemMenu">Menù</string>
|
||||
<string id="Confirm">Sicuro?</string>
|
||||
<string id="NoPhone">Nessuna connessione telefonica</string>
|
||||
<string id="NoInternet">Nessuna connessione internet</string>
|
||||
<string id="NoResponse">Nessuna risposta, controlla la connessione Internet</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">オフ</string>
|
||||
<string id="MenuItemTap">タップ</string>
|
||||
<string id="MenuItemMenu">メニュー</string>
|
||||
<string id="Confirm">もちろん?</string>
|
||||
<string id="NoPhone">電話が接続されていません</string>
|
||||
<string id="NoInternet">インターネット接続なし</string>
|
||||
<string id="NoResponse">応答がありません。インターネット接続を確認してください</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">끄다</string>
|
||||
<string id="MenuItemTap">수도꼭지</string>
|
||||
<string id="MenuItemMenu">메뉴</string>
|
||||
<string id="Confirm">확신하는?</string>
|
||||
<string id="NoPhone">전화 연결 없음</string>
|
||||
<string id="NoInternet">인터넷에 연결되지 않음</string>
|
||||
<string id="NoResponse">응답이 없습니다. 인터넷 연결을 확인하세요.</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Izslēgts</string>
|
||||
<string id="MenuItemTap">Krāns</string>
|
||||
<string id="MenuItemMenu">Izvēlne</string>
|
||||
<string id="Confirm">Protams?</string>
|
||||
<string id="NoPhone">Nav tālruņa savienojuma</string>
|
||||
<string id="NoInternet">Nav interneta savienojuma</string>
|
||||
<string id="NoResponse">Nav atbildes, pārbaudiet interneta savienojumu</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Išjungta</string>
|
||||
<string id="MenuItemTap">Bakstelėkite</string>
|
||||
<string id="MenuItemMenu">Meniu</string>
|
||||
<string id="Confirm">Žinoma?</string>
|
||||
<string id="NoPhone">Nėra telefono ryšio</string>
|
||||
<string id="NoInternet">Nėra interneto ryšio</string>
|
||||
<string id="NoResponse">Neatsako, patikrinkite interneto ryšį</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Av</string>
|
||||
<string id="MenuItemTap">Trykk på</string>
|
||||
<string id="MenuItemMenu">Meny</string>
|
||||
<string id="Confirm">Sikker?</string>
|
||||
<string id="NoPhone">Ingen telefonforbindelse</string>
|
||||
<string id="NoInternet">Ingen Internett-tilkobling</string>
|
||||
<string id="NoResponse">Ingen svar, sjekk Internett-tilkoblingen</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Wyłączony</string>
|
||||
<string id="MenuItemTap">Uzyskiwać</string>
|
||||
<string id="MenuItemMenu">Menu</string>
|
||||
<string id="Confirm">Jasne?</string>
|
||||
<string id="NoPhone">Brak połączenia telefonicznego</string>
|
||||
<string id="NoInternet">Brak połączenia z internetem</string>
|
||||
<string id="NoResponse">Brak odpowiedzi, sprawdź połączenie internetowe</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Desligado</string>
|
||||
<string id="MenuItemTap">Tocar</string>
|
||||
<string id="MenuItemMenu">Cardápio</string>
|
||||
<string id="Confirm">Claro?</string>
|
||||
<string id="NoPhone">Sem conexão telefônica</string>
|
||||
<string id="NoInternet">Sem conexão com a Internet</string>
|
||||
<string id="NoResponse">Sem resposta, verifique a conexão com a Internet</string>
|
||||
@ -31,7 +32,7 @@
|
||||
<string id="NoAPIKey">Nenhuma chave de API nas configurações do aplicativo</string>
|
||||
<string id="NoApiUrl">Nenhum URL de API nas configurações do aplicativo</string>
|
||||
<string id="NoConfigUrl">Nenhum URL de configuração nas configurações do aplicativo</string>
|
||||
<string id="ApiFlood">Chamadas de API muito rápidas. Por favor, diminua a velocidade de seus pedidos.</string>
|
||||
<string id="ApiFlood">Chamadas de API muito rápidas. Por favor, desacelere seus pedidos.</string>
|
||||
<string id="ApiUrlNotFound">URL não encontrado. Possível erro de URL da API nas configurações.</string>
|
||||
<string id="ConfigUrlNotFound">URL não encontrado. Possível erro de URL de configuração nas configurações.</string>
|
||||
<string id="UnhandledHttpErr">Solicitação HTTP retornou código de erro =</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Oprit</string>
|
||||
<string id="MenuItemTap">Atingeți</string>
|
||||
<string id="MenuItemMenu">Meniul</string>
|
||||
<string id="Confirm">Sigur?</string>
|
||||
<string id="NoPhone">Fără conexiune telefonică</string>
|
||||
<string id="NoInternet">Fără conexiune internet</string>
|
||||
<string id="NoResponse">Niciun răspuns, verificați conexiunea la internet</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Vypnuté</string>
|
||||
<string id="MenuItemTap">Klepnite</string>
|
||||
<string id="MenuItemMenu">Ponuka</string>
|
||||
<string id="Confirm">Samozrejme?</string>
|
||||
<string id="NoPhone">Žiadne telefónne spojenie</string>
|
||||
<string id="NoInternet">Žiadne internetové pripojenie</string>
|
||||
<string id="NoResponse">Žiadna odpoveď, skontrolujte internetové pripojenie</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Izključeno</string>
|
||||
<string id="MenuItemTap">Tapnite</string>
|
||||
<string id="MenuItemMenu">meni</string>
|
||||
<string id="Confirm">Seveda?</string>
|
||||
<string id="NoPhone">Ni telefonske povezave</string>
|
||||
<string id="NoInternet">Ni internetne povezave</string>
|
||||
<string id="NoResponse">Ni odgovora, preverite internetno povezavo</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Apagado</string>
|
||||
<string id="MenuItemTap">Grifo</string>
|
||||
<string id="MenuItemMenu">Menú</string>
|
||||
<string id="Confirm">¿Seguro?</string>
|
||||
<string id="NoPhone">Sin conexión telefónica</string>
|
||||
<string id="NoInternet">Sin conexión a Internet</string>
|
||||
<string id="NoResponse">No hay respuesta, verifique la conexión a Internet</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Av</string>
|
||||
<string id="MenuItemTap">Knacka</string>
|
||||
<string id="MenuItemMenu">Meny</string>
|
||||
<string id="Confirm">Säker?</string>
|
||||
<string id="NoPhone">Ingen telefonanslutning</string>
|
||||
<string id="NoInternet">Ingen internetanslutning</string>
|
||||
<string id="NoResponse">Inget svar, kontrollera internetanslutningen</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">ปิด</string>
|
||||
<string id="MenuItemTap">แตะ</string>
|
||||
<string id="MenuItemMenu">เมนู</string>
|
||||
<string id="Confirm">แน่นอน?</string>
|
||||
<string id="NoPhone">ไม่มีการเชื่อมต่อโทรศัพท์</string>
|
||||
<string id="NoInternet">ไม่มีการเชื่อมต่ออินเทอร์เน็ต</string>
|
||||
<string id="NoResponse">ไม่มีการตอบสนอง ตรวจสอบการเชื่อมต่ออินเทอร์เน็ต</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Kapalı</string>
|
||||
<string id="MenuItemTap">Musluk</string>
|
||||
<string id="MenuItemMenu">Menü</string>
|
||||
<string id="Confirm">Elbette?</string>
|
||||
<string id="NoPhone">Telefon bağlantısı yok</string>
|
||||
<string id="NoInternet">İnternet bağlantısı yok</string>
|
||||
<string id="NoResponse">Yanıt Yok, İnternet bağlantısını kontrol edin</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Вимкнено</string>
|
||||
<string id="MenuItemTap">Торкніться</string>
|
||||
<string id="MenuItemMenu">Меню</string>
|
||||
<string id="Confirm">Зрозуміло?</string>
|
||||
<string id="NoPhone">Немає телефонного зв'язку</string>
|
||||
<string id="NoInternet">Немає підключення до Інтернету</string>
|
||||
<string id="NoResponse">Немає відповіді, перевірте підключення до Інтернету</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Tắt</string>
|
||||
<string id="MenuItemTap">Vỗ nhẹ</string>
|
||||
<string id="MenuItemMenu">Thực đơn</string>
|
||||
<string id="Confirm">Chắc chắn?</string>
|
||||
<string id="NoPhone">Không có kết nối điện thoại</string>
|
||||
<string id="NoInternet">Không có kết nối Internet</string>
|
||||
<string id="NoResponse">Không có phản hồi, kiểm tra kết nối Internet</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">离开</string>
|
||||
<string id="MenuItemTap">轻敲</string>
|
||||
<string id="MenuItemMenu">菜单</string>
|
||||
<string id="Confirm">当然?</string>
|
||||
<string id="NoPhone">没有电话连接</string>
|
||||
<string id="NoInternet">没有网络连接</string>
|
||||
<string id="NoResponse">无响应,请检查互联网连接</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">離開</string>
|
||||
<string id="MenuItemTap">輕敲</string>
|
||||
<string id="MenuItemMenu">選單</string>
|
||||
<string id="Confirm">當然?</string>
|
||||
<string id="NoPhone">沒有電話連接</string>
|
||||
<string id="NoInternet">沒有網路連線</string>
|
||||
<string id="NoResponse">無響應,請檢查互聯網連接</string>
|
||||
|
@ -24,6 +24,7 @@
|
||||
<string id="MenuItemOff">Mati</string>
|
||||
<string id="MenuItemTap">Ketik</string>
|
||||
<string id="MenuItemMenu">Menu</string>
|
||||
<string id="Confirm">pasti?</string>
|
||||
<string id="NoPhone">Tiada sambungan Telefon</string>
|
||||
<string id="NoInternet">Tiada sambungan internet</string>
|
||||
<string id="NoResponse">Tiada Respons, semak sambungan Internet</string>
|
||||
|
@ -24,7 +24,20 @@
|
||||
<!-- Best be a public URL in order to work away from your home LAN and have a trusted HTTPS certificate -->
|
||||
<property id="config_url" type="string"></property>
|
||||
|
||||
<!--
|
||||
Application timeout in seconds, except 0 for no timeout (default). After this amount of elapsed time
|
||||
with no activity, exit the application.
|
||||
-->
|
||||
<property id="app_timeout" type="number">0</property>
|
||||
|
||||
<!--
|
||||
After this time (in seconds), a confirmation dialog for an action is automatically closed and the action is cancelled.
|
||||
Set to 0 to disable the timeout. The default value is 3 seconds.
|
||||
-->
|
||||
<property id="confirm_timeout" type="number">3</property>
|
||||
|
||||
<property id="types_representation" type="boolean"></property>
|
||||
|
||||
<property id="menu_alignment" type="boolean"></property>
|
||||
|
||||
</properties>
|
||||
|
@ -43,6 +43,26 @@
|
||||
/>
|
||||
</setting>
|
||||
|
||||
<setting
|
||||
propertyKey="@Properties.app_timeout"
|
||||
title="Timeout in seconds. Exit the application after this period of inactivity to save the device battery."
|
||||
>
|
||||
<settingConfig
|
||||
type="numeric"
|
||||
min="0"
|
||||
/>
|
||||
</setting>
|
||||
|
||||
<setting
|
||||
propertyKey="@Properties.confirm_timeout"
|
||||
title="After this time (in seconds), a confirmation dialog for an action is automatically closed and the action is cancelled. Set to 0 to disable the timeout."
|
||||
>
|
||||
<settingConfig
|
||||
type="numeric"
|
||||
min="0"
|
||||
/>
|
||||
</setting>
|
||||
|
||||
<setting
|
||||
propertyKey="@Properties.types_representation"
|
||||
title="Representing types with icons (off) or with labels (on)"
|
||||
@ -60,4 +80,5 @@
|
||||
type="boolean"
|
||||
/>
|
||||
</setting>
|
||||
|
||||
</settings>
|
||||
|
@ -18,6 +18,7 @@
|
||||
<string id="MenuItemOff">Off</string>
|
||||
<string id="MenuItemTap">Tap</string>
|
||||
<string id="MenuItemMenu">Menu</string>
|
||||
<string id="Confirm">Sure?</string>
|
||||
<string id="NoPhone">No Phone connection</string>
|
||||
<string id="NoInternet">No Internet connection</string>
|
||||
<string id="NoResponse">No Response, check Internet connection</string>
|
||||
|
@ -132,11 +132,13 @@ class AlertDelegate extends WatchUi.InputDelegate {
|
||||
|
||||
function onKey(evt) {
|
||||
mView.dismiss();
|
||||
getApp().getQuitTimer().reset();
|
||||
return true;
|
||||
}
|
||||
|
||||
function onTap(evt) {
|
||||
mView.dismiss();
|
||||
getApp().getQuitTimer().reset();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ class ErrorDelegate extends WatchUi.BehaviorDelegate {
|
||||
WatchUi.BehaviorDelegate.initialize();
|
||||
}
|
||||
function onBack() {
|
||||
getApp().getQuitTimer().reset();
|
||||
WatchUi.popView(WatchUi.SLIDE_DOWN);
|
||||
return true;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ using Toybox.Application.Properties;
|
||||
|
||||
class HomeAssistantApp extends Application.AppBase {
|
||||
private var mHaMenu;
|
||||
private var quitTimer as QuitTimer;
|
||||
private var strNoApiKey as Lang.String;
|
||||
private var strNoApiUrl as Lang.String;
|
||||
private var strNoConfigUrl as Lang.String;
|
||||
@ -52,14 +53,18 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
strConfigUrlNotFound = WatchUi.loadResource($.Rez.Strings.ConfigUrlNotFound);
|
||||
strUnhandledHttpErr = WatchUi.loadResource($.Rez.Strings.UnhandledHttpErr);
|
||||
strTrailingSlashErr = WatchUi.loadResource($.Rez.Strings.TrailingSlashErr);
|
||||
quitTimer = new QuitTimer();
|
||||
}
|
||||
|
||||
// onStart() is called on application start up
|
||||
function onStart(state as Lang.Dictionary?) as Void {
|
||||
quitTimer.begin();
|
||||
}
|
||||
|
||||
// onStop() is called when your application is exiting
|
||||
function onStop(state as Lang.Dictionary?) as Void {}
|
||||
function onStop(state as Lang.Dictionary?) as Void {
|
||||
quitTimer.stop();
|
||||
}
|
||||
|
||||
// Return the initial view of your application here
|
||||
function getInitialView() as Lang.Array<WatchUi.Views or WatchUi.InputDelegates>? {
|
||||
@ -174,6 +179,10 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
mNextItemToUpdate = (mNextItemToUpdate + 1) % itu.size();
|
||||
}
|
||||
|
||||
function getQuitTimer() as QuitTimer{
|
||||
return quitTimer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function getApp() as HomeAssistantApp {
|
||||
|
64
source/HomeAssistantConfirmation.mc
Normal file
64
source/HomeAssistantConfirmation.mc
Normal file
@ -0,0 +1,64 @@
|
||||
//-----------------------------------------------------------------------------------
|
||||
//
|
||||
// Distributed under MIT Licence
|
||||
// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
|
||||
//
|
||||
//-----------------------------------------------------------------------------------
|
||||
//
|
||||
// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
|
||||
// tested on a Venu 2 device. The source code is provided at:
|
||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||
//
|
||||
// P A Abbey & J D Abbey & SomeoneOnEarth, 19 November 2023
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
// Calling a Home Assistant confirmation dialogue view.
|
||||
//
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
using Toybox.Lang;
|
||||
// Required for callback method definition
|
||||
typedef Method as Toybox.Lang.Method;
|
||||
using Toybox.WatchUi;
|
||||
using Toybox.Timer;
|
||||
using Toybox.Application.Properties;
|
||||
|
||||
class HomeAssistantConfirmation extends WatchUi.Confirmation {
|
||||
function initialize() {
|
||||
WatchUi.Confirmation.initialize(WatchUi.loadResource($.Rez.Strings.Confirm));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class HomeAssistantConfirmationDelegate extends WatchUi.ConfirmationDelegate {
|
||||
private var confirmMethod;
|
||||
private var timeout;
|
||||
|
||||
function initialize(callback as Method() as Void) {
|
||||
WatchUi.ConfirmationDelegate.initialize();
|
||||
confirmMethod = callback;
|
||||
var timeoutSeconds = Properties.getValue("confirm_timeout") as Lang.Number;
|
||||
if (timeoutSeconds > 0) {
|
||||
timeout = new Timer.Timer();
|
||||
timeout.start(method(:onTimeout), timeoutSeconds * 1000, true);
|
||||
}
|
||||
}
|
||||
|
||||
function onResponse(response) as Lang.Boolean {
|
||||
getApp().getQuitTimer().reset();
|
||||
if (timeout) {
|
||||
timeout.stop();
|
||||
}
|
||||
if (response == WatchUi.CONFIRM_YES) {
|
||||
confirmMethod.invoke();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function onTimeout() as Void {
|
||||
timeout.stop();
|
||||
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||
}
|
||||
}
|
@ -21,17 +21,18 @@
|
||||
using Toybox.Lang;
|
||||
using Toybox.WatchUi;
|
||||
using Toybox.Graphics;
|
||||
using Toybox.Application.Properties;
|
||||
|
||||
class HomeAssistantIconMenuItem extends WatchUi.IconMenuItem {
|
||||
private var mHomeAssistantService as HomeAssistantService;
|
||||
private var mService as Lang.String;
|
||||
private var mConfirm as Lang.Boolean;
|
||||
|
||||
function initialize(
|
||||
label as Lang.String or Lang.Symbol,
|
||||
subLabel as Lang.String or Lang.Symbol or Null,
|
||||
identifier as Lang.Object or Null,
|
||||
service as Lang.String or Null,
|
||||
confirm as Lang.Boolean,
|
||||
icon as Graphics.BitmapType or WatchUi.Drawable,
|
||||
options as {
|
||||
:alignment as WatchUi.MenuItem.Alignment
|
||||
@ -49,9 +50,22 @@ class HomeAssistantIconMenuItem extends WatchUi.IconMenuItem {
|
||||
mHomeAssistantService = haService;
|
||||
mIdentifier = identifier;
|
||||
mService = service;
|
||||
mConfirm = confirm;
|
||||
}
|
||||
|
||||
function callService() as Void {
|
||||
if (mConfirm) {
|
||||
WatchUi.pushView(
|
||||
new HomeAssistantConfirmation(),
|
||||
new HomeAssistantConfirmationDelegate(method(:onConfirm)),
|
||||
WatchUi.SLIDE_IMMEDIATE
|
||||
);
|
||||
} else {
|
||||
onConfirm();
|
||||
}
|
||||
}
|
||||
|
||||
function onConfirm() as Void {
|
||||
mHomeAssistantService.call(mIdentifier as Lang.String, mService);
|
||||
}
|
||||
|
||||
|
@ -21,17 +21,18 @@
|
||||
using Toybox.Lang;
|
||||
using Toybox.WatchUi;
|
||||
using Toybox.Graphics;
|
||||
using Toybox.Application.Properties;
|
||||
|
||||
class HomeAssistantMenuItem extends WatchUi.MenuItem {
|
||||
private var mHomeAssistantService as HomeAssistantService;
|
||||
private var mService as Lang.String;
|
||||
private var mConfirm as Lang.Boolean;
|
||||
|
||||
function initialize(
|
||||
label as Lang.String or Lang.Symbol,
|
||||
subLabel as Lang.String or Lang.Symbol or Null,
|
||||
identifier as Lang.Object or Null,
|
||||
service as Lang.String or Null,
|
||||
confirm as Lang.Boolean,
|
||||
options as {
|
||||
:alignment as WatchUi.MenuItem.Alignment,
|
||||
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol
|
||||
@ -47,9 +48,22 @@ class HomeAssistantMenuItem extends WatchUi.MenuItem {
|
||||
|
||||
mHomeAssistantService = haService;
|
||||
mService = service;
|
||||
mConfirm = confirm;
|
||||
}
|
||||
|
||||
function callService() as Void {
|
||||
if (mConfirm) {
|
||||
WatchUi.pushView(
|
||||
new HomeAssistantConfirmation(),
|
||||
new HomeAssistantConfirmationDelegate(method(:onConfirm)),
|
||||
WatchUi.SLIDE_IMMEDIATE
|
||||
);
|
||||
} else {
|
||||
onConfirm();
|
||||
}
|
||||
}
|
||||
|
||||
function onConfirm() as Void {
|
||||
mHomeAssistantService.call(mIdentifier as Lang.String, mService);
|
||||
}
|
||||
|
||||
|
@ -89,13 +89,19 @@ class HomeAssistantMenuItemFactory {
|
||||
);
|
||||
}
|
||||
|
||||
function tap(label as Lang.String or Lang.Symbol, identifier as Lang.Object or Null, service as Lang.String or Null) as WatchUi.MenuItem {
|
||||
function tap(
|
||||
label as Lang.String or Lang.Symbol,
|
||||
identifier as Lang.Object or Null,
|
||||
service as Lang.String or Null,
|
||||
confirm as Lang.Boolean
|
||||
) as WatchUi.MenuItem {
|
||||
if (bRepresentTypesWithLabels) {
|
||||
return new HomeAssistantMenuItem(
|
||||
label,
|
||||
strMenuItemTap,
|
||||
identifier,
|
||||
service,
|
||||
confirm,
|
||||
mMenuItemOptions,
|
||||
mHomeAssistantService
|
||||
);
|
||||
@ -105,6 +111,7 @@ class HomeAssistantMenuItemFactory {
|
||||
null,
|
||||
identifier,
|
||||
service,
|
||||
confirm,
|
||||
mTapTypeIcon,
|
||||
mMenuItemOptions,
|
||||
mHomeAssistantService
|
||||
|
@ -48,17 +48,26 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
||||
|
||||
var items = definition.get("items") as Lang.Dictionary;
|
||||
for(var i = 0; i < items.size(); i++) {
|
||||
var type = items[i].get("type") as Lang.String or Null;
|
||||
var name = items[i].get("name") as Lang.String or Null;
|
||||
var entity = items[i].get("entity") as Lang.String or Null;
|
||||
var service = items[i].get("service") as Lang.String or Null;
|
||||
var type = items[i].get("type") as Lang.String or Null;
|
||||
var name = items[i].get("name") as Lang.String or Null;
|
||||
var entity = items[i].get("entity") as Lang.String or Null;
|
||||
var tap_action = items[i].get("tap_action") as Lang.Dictionary or Null;
|
||||
var service = items[i].get("service") as Lang.String or Null;
|
||||
var confirm = false as Lang.Boolean;
|
||||
if (tap_action != null) {
|
||||
service = tap_action.get("service");
|
||||
confirm = tap_action.get("confirm");
|
||||
if (confirm == null) {
|
||||
confirm = false;
|
||||
}
|
||||
}
|
||||
if (type != null && name != null && entity != null) {
|
||||
if (type.equals("toggle")) {
|
||||
var item = HomeAssistantMenuItemFactory.create().toggle(name, entity);
|
||||
addItem(item);
|
||||
mListToggleItems.add(item);
|
||||
} else if (type.equals("tap") && service != null) {
|
||||
addItem( HomeAssistantMenuItemFactory.create().tap(name, entity, service));
|
||||
addItem(HomeAssistantMenuItemFactory.create().tap(name, entity, service, confirm));
|
||||
} else if (type.equals("group")) {
|
||||
var item = HomeAssistantMenuItemFactory.create().group(items[i]);
|
||||
addItem(item);
|
||||
@ -98,7 +107,23 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
||||
Menu2InputDelegate.initialize();
|
||||
}
|
||||
|
||||
function onBack() {
|
||||
getApp().getQuitTimer().reset();
|
||||
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||
}
|
||||
|
||||
// Only for CheckboxMenu
|
||||
function onDone() {
|
||||
getApp().getQuitTimer().reset();
|
||||
}
|
||||
|
||||
// Only for CustomMenu
|
||||
function onFooter() {
|
||||
getApp().getQuitTimer().reset();
|
||||
}
|
||||
|
||||
function onSelect(item as WatchUi.MenuItem) as Void {
|
||||
getApp().getQuitTimer().reset();
|
||||
if (item instanceof HomeAssistantToggleMenuItem) {
|
||||
var haToggleItem = item as HomeAssistantToggleMenuItem;
|
||||
if (Globals.scDebug) {
|
||||
@ -138,8 +163,9 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
function onBack() {
|
||||
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||
// Only for CustomMenu
|
||||
function onTitle() {
|
||||
getApp().getQuitTimer().reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
56
source/QuitTimer.mc
Normal file
56
source/QuitTimer.mc
Normal file
@ -0,0 +1,56 @@
|
||||
//-----------------------------------------------------------------------------------
|
||||
//
|
||||
// Distributed under MIT Licence
|
||||
// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
|
||||
//
|
||||
//-----------------------------------------------------------------------------------
|
||||
//
|
||||
// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
|
||||
// tested on a Venu 2 device. The source code is provided at:
|
||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||
//
|
||||
// J D Abbey & P A Abbey, 28 December 2022
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
// Quit the application after a period of inactivity in order to save the battery.
|
||||
//
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
using Toybox.Lang;
|
||||
using Toybox.Timer;
|
||||
using Toybox.Application.Properties;
|
||||
using Toybox.WatchUi;
|
||||
|
||||
class QuitTimer extends Timer.Timer {
|
||||
private var api_timeout;
|
||||
|
||||
function initialize() {
|
||||
Timer.Timer.initialize();
|
||||
// Timer needs delay in milliseconds.
|
||||
api_timeout = (Properties.getValue("app_timeout") as Lang.Number) * 1000;
|
||||
}
|
||||
|
||||
function exitApp() as Void {
|
||||
if (Globals.scDebug) {
|
||||
System.println("QuitTimer exitApp(): Exiting");
|
||||
}
|
||||
// This will exit the system cleanly from any point within an app.
|
||||
System.exit();
|
||||
}
|
||||
|
||||
function begin() {
|
||||
if (api_timeout > 0) {
|
||||
start(method(:exitApp), api_timeout, false);
|
||||
}
|
||||
}
|
||||
|
||||
function reset() {
|
||||
if (Globals.scDebug) {
|
||||
System.println("QuitTimer reset(): Restarted quit timer");
|
||||
}
|
||||
stop();
|
||||
begin();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user