Removed timer based update mechanism

Instead chaining calls from the previous update is a slightly close coupled way that might need to be refined.
This commit is contained in:
Philip Abbey
2023-11-11 20:00:26 +00:00
parent fde270ff34
commit 765d7f7f50
40 changed files with 79 additions and 58 deletions

View File

@ -7,7 +7,7 @@ A Garmin application to provide a "dashboard" to control your devices via [Home
The application is designed around a simple scrollable menu where menu items have been extended to interface with the [Home Assistant API](https://developers.home-assistant.io/docs/api/rest/), e.g. to get the status of switches or lights for display on the toggle menu item. It is possible to nest menus, so there is a menu item to open a sub-menu. This can be
arbitrarily deep and nested in the format of a tree of items, although you need to consider if reaching for your phone becomes quicker to select the device what you want to control.
It is important to note that your homeassistant instance will need to be accessible via HTTPS with public SSL or all requests from the Garmin will not work. This cannot be a self-signed certificate, it must be a public certificate (You can get one for free from Let's Encrypt or you can pay for homeassistant cloud).
It is important to note that your Home Assistant instance will need to be accessible via HTTPS with public SSL or all requests from the Garmin will not work. This cannot be a self-signed certificate, it must be a public certificate (You can get one for free from [Let's Encrypt](https://letsencrypt.org/) or you can pay for [Home Assistant cloud](https://www.nabucasa.com/)).
## Application Installation
@ -15,7 +15,7 @@ Head over to the [GarminHomeAssistant](https://apps.garmin.com/en-US/apps/61c91d
## Dashboard Definition
Setup for this menu is more complicated than the Connect IQ settings menu really allows you to specify. In order to make the dashboard easily configurable and easy to change, we have provided an external mechanism for specifying the menu layout, a JSON file you write, retrieved from a URL you specify. JSON was chosen over YAML because Garmin can parse JSON HTTP GET responses into its own internal dictionary, it cannot parse YAML, hence a choice of one really. We recommend you take advantage of [Home Assistant's own web server](https://www.home-assistant.io/integrations/http/#hosting-files) to provide the JSON definition. The advantage here are:
Setup for this menu is more complicated than the Connect IQ settings menu really allows you to specify. In order to make the dashboard easily configurable and easy to change, we have provided an external mechanism for specifying the menu layout, a JSON file you write, retrieved from a URL you specify. JSON was chosen over YAML because Garmin can parse JSON HTTP GET responses into its own internal dictionary, it cannot parse YAML, hence a choice of one really. Note that JSON and YAML are essentially a 1:1 format mapping except JSON does not have comments. We recommend you take advantage of [Home Assistant's own web server](https://www.home-assistant.io/integrations/http/#hosting-files) to provide the JSON definition. The advantage here are:
1. the file is as public as you make your Home Assistant,
2. the file is editable within Home Assistant via "Studio Code Server", and
@ -76,9 +76,15 @@ Example schema as shown in the images:
"type": "toggle"
},
{
"entity": "switch.crnr_tbl_usbs",
"name": "Corner Table USBs",
"entity": "automation.garage_door_check",
"name": "Garage Door Check",
"type": "toggle"
},
{
"entity": "scene.tv_light",
"name": "TV Lights Scene",
"type": "tap",
"service": "scene.turn_on"
}
]
}
@ -86,6 +92,16 @@ Example schema as shown in the images:
NB. Entity names are not real in case anyone's a hacker.
The example above illustrates how to configure:
* Light or switch toggles
* Automation enable toggles
* Script invocation (tap)
* Service invocation, e.g. Scene setting, (tap)
* A sub-menu to open (tap)
Possible future extensions might include specifying the alternative texts to use instead of "On" and "Off", e.g. "Locked" and "Unlocked" (but wouldn't having locks operated from your watch be a security concern ;-))
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.
## API Key Creation
@ -116,8 +132,21 @@ The application will display a 'toast' showing Home Assistant's friendly name of
## External Device Changes
Home Assistant will inevitably change the state of devices you are also controlling via your Garmin. The Garmin application does not maintain a web socket to listen for changes. Instead it must poll the Home Assistant API with your key. Therefore the application is not responsive to changes, instead there will be a delay of about 5 seconds to pick up state changes. The thinking here is that the watch application will only ever be open briefly not persistently, so the delay in picking up state changes won't be observed often for any race condition between two controllers.
Home Assistant will inevitably change the state of devices you are also controlling via your Garmin. The Garmin application does not maintain a web socket to listen for changes. Instead it must poll the Home Assistant API with your key. Therefore the application is not that responsive to changes. Instead there will be a delay of multiples of 100 ms per item whose status needs to be checked and amended.
The per toggle item delay is caused by a queue of responses to web requests filling up a queue and giving a [Communications](https://developer.garmin.com/connect-iq/api-docs/Toybox/Communications.html).`BLE_QUEUE_FULL` response code. For a Venu 2 Garmin watch an API call delay of 600 ms was found to be sustainable (500 ms was still too fast). The code now chains a sequence of updates, so as one finishes it invokes the next item's update. The more items requiring a status update that you pack into your dashboard, the slower each individual item will be updated!
The thinking here is that the watch application will only ever be open briefly not persistently, so the delay in picking up state changes won't be observed often for any race condition between two controllers.
As a consequence of this update mechanism, if you request changes too quickly you will be notified that your device cannot keep up with the rate of API responses and you will have to dismiss the error in order to continue. The is a _feature not a bug_!
## Changes to the (JSON) Dashboard Definition
When you change the JSON file defining your dashboard, you must exit the application and the reopen it. It only takes a matter of a few seconds to pick up the new definition, but it is not automatic.
## Version History
| Version | Comment |
|:-------:|---------|
| 1.0 | Initial release for 26 devices. |
| 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. |

View File

@ -21,7 +21,7 @@
Use "Monkey C: Edit Application" from the Visual Studio Code command palette
to update the application attributes.
-->
<iq:application id="98c36259-498a-4458-9cef-74a273ad2bc3" type="watch-app" name="@Strings.AppName" entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.3.0">
<iq:application id="40131e87-31ff-454b-a8e2-92276ee399d6" type="watch-app" name="@Strings.AppName" entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.3.0">
<!--
Use the following from the Visual Studio Code comand palette to edit
the build targets:

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">لا يوجد مفتاح API في إعدادات التطبيق</string>
<string id="NoApiUrl">لا يوجد عنوان URL لواجهة برمجة التطبيقات في إعدادات التطبيق</string>
<string id="NoConfigUrl">لا يوجد عنوان URL للتكوين في إعدادات التطبيق</string>
<string id="ApiFlood">مكالمات API سريعة جدًا. يرجى الإبلاغ عن هذا الخطأ مع تفاصيل الجهاز.</string>
<string id="ApiFlood">مكالمات API سريعة جدًا. يرجى إبطاء طلباتك.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Няма API ключ в настройките на приложението</string>
<string id="NoApiUrl">Няма URL адрес на API в настройките на приложението</string>
<string id="NoConfigUrl">Няма конфигурационен URL адрес в настройките на приложението</string>
<string id="ApiFlood">Извикванията на API са твърде бързи. Моля, докладвайте тази грешка с подробности за устройството.</string>
<string id="ApiFlood">Извикванията на API са твърде бързи. Моля, забавете вашите заявки.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">V nastavení aplikace není žádný klíč API</string>
<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. Nahlaste tuto chybu s podrobnostmi o zařízení.</string>
<string id="ApiFlood">Příliš rychlá volání API. Zpomalte prosím své požadavky.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Ingen API-nøgle i applikationsindstillingerne</string>
<string id="NoApiUrl">Ingen API-URL i applikationsindstillingerne</string>
<string id="NoConfigUrl">Ingen konfigurations-URL i applikationsindstillingerne</string>
<string id="ApiFlood">API-kald for hurtigt. Rapportér venligst denne fejl med enhedsoplysninger.</string>
<string id="ApiFlood">API-kald for hurtigt. Sænk venligst dine anmodninger.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Kein API-Schlüssel in den Anwendungseinstellungen</string>
<string id="NoApiUrl">Keine API-URL in den Anwendungseinstellungen</string>
<string id="NoConfigUrl">Keine Konfigurations-URL in den Anwendungseinstellungen</string>
<string id="ApiFlood">API-Aufrufe zu schnell. Bitte melden Sie diesen Fehler mit Gerätedetails.</string>
<string id="ApiFlood">API-Aufrufe zu schnell. Bitte verlangsamen Sie Ihre Anfragen.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Geen API-sleutel in de applicatie-instellingen</string>
<string id="NoApiUrl">Geen API-URL in de applicatie-instellingen</string>
<string id="NoConfigUrl">Geen configuratie-URL in de applicatie-instellingen</string>
<string id="ApiFlood">API-aanroepen te snel. Rapporteer deze fout met apparaatgegevens.</string>
<string id="ApiFlood">API-aanroepen te snel. Vertraag uw verzoeken.</string>
</strings>

View File

@ -29,5 +29,5 @@
<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-kutsed liiga kiired. Teatage sellest veast koos seadme üksikasjadega.</string>
<string id="ApiFlood">API-kutsed liiga kiired. Palun aeglustage taotluste esitamist.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Sovellusasetuksissa ei ole API-avainta</string>
<string id="NoApiUrl">Sovellusasetuksissa ei ole API URL-osoitetta</string>
<string id="NoConfigUrl">Sovelluksen asetuksissa ei ole konfigurointi-URL-osoitetta</string>
<string id="ApiFlood">API-kutsut liian nopeita. Ilmoita tästä virheestä laitteen tiedoilla.</string>
<string id="ApiFlood">API-kutsut liian nopeita. Hidasta pyyntöjäsi.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Pas de clé API dans les paramètres de l'application</string>
<string id="NoApiUrl">Aucune URL API dans les paramètres de l'application</string>
<string id="NoConfigUrl">Aucune URL de configuration dans les paramètres de l'application</string>
<string id="ApiFlood">Appels API trop rapides. Veuillez signaler cette erreur avec les détails de l'appareil.</string>
<string id="ApiFlood">Appels API trop rapides. Veuillez ralentir vos demandes.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Δεν υπάρχει κλειδί API στις ρυθμίσεις της εφαρμογής</string>
<string id="NoApiUrl">Δεν υπάρχει URL API στις ρυθμίσεις της εφαρμογής</string>
<string id="NoConfigUrl">Δεν υπάρχει διεύθυνση URL διαμόρφωσης στις ρυθμίσεις της εφαρμογής</string>
<string id="ApiFlood">Κλήσεις API πολύ γρήγορες. Αναφέρετε αυτό το σφάλμα με τα στοιχεία της συσκευής.</string>
<string id="ApiFlood">Κλήσεις API πολύ γρήγορες. Παρακαλώ επιβραδύνετε τα αιτήματά σας.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">אין מפתח API בהגדרות האפליקציה</string>
<string id="NoApiUrl">אין כתובת API בהגדרות האפליקציה</string>
<string id="NoConfigUrl">אין כתובת אתר תצורה בהגדרות האפליקציה</string>
<string id="ApiFlood">קריאות API מהירות מדי. אנא דווח על שגיאה זו עם פרטי המכשיר.</string>
<string id="ApiFlood">קריאות API מהירות מדי. נא להאט את הבקשות שלך.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Nema API ključa u postavkama aplikacije</string>
<string id="NoApiUrl">Nema API URL-a u postavkama aplikacije</string>
<string id="NoConfigUrl">Nema konfiguracijskog URL-a u postavkama aplikacije</string>
<string id="ApiFlood">API pozivi su prebrzi. Prijavite ovu pogrešku s pojedinostima o uređaju.</string>
<string id="ApiFlood">API pozivi su prebrzi. Molimo usporite svoje zahtjeve.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Nincs API kulcs az alkalmazás beállításaiban</string>
<string id="NoApiUrl">Nincs API URL az alkalmazás beállításai között</string>
<string id="NoConfigUrl">Nincs konfigurációs URL az alkalmazás beállításai között</string>
<string id="ApiFlood">Az API-hívások túl gyorsak. Kérjük, jelentse ezt a hibát az eszköz részleteivel.</string>
<string id="ApiFlood">Az API-hívások túl gyorsak. Kérjük, lassítsa a kérések teljesítését.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Tidak ada kunci API di pengaturan aplikasi</string>
<string id="NoApiUrl">Tidak ada URL API di pengaturan aplikasi</string>
<string id="NoConfigUrl">Tidak ada URL konfigurasi di pengaturan aplikasi</string>
<string id="ApiFlood">Panggilan API terlalu cepat. Silakan laporkan kesalahan ini dengan detail perangkat.</string>
<string id="ApiFlood">Panggilan API terlalu cepat. Harap memperlambat permintaan Anda.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Nessuna chiave API nelle impostazioni dell'applicazione</string>
<string id="NoApiUrl">Nessun URL API nelle impostazioni dell'applicazione</string>
<string id="NoConfigUrl">Nessun URL di configurazione nelle impostazioni dell'applicazione</string>
<string id="ApiFlood">Chiamate API troppo rapide. Segnala questo errore con i dettagli del dispositivo.</string>
<string id="ApiFlood">Chiamate API troppo rapide. Per favore rallenta le tue richieste.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">アプリケーション設定に API キーがありません</string>
<string id="NoApiUrl">アプリケーション設定に API URL がありません</string>
<string id="NoConfigUrl">アプリケーション設定に構成 URL がありません</string>
<string id="ApiFlood">API 呼び出しが速すぎます。このエラーをデバイスの詳細とともに報告してください。</string>
<string id="ApiFlood">API 呼び出しが速すぎます。リクエストは遅くしてください。</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">애플리케이션 설정에 API 키가 없습니다.</string>
<string id="NoApiUrl">애플리케이션 설정에 API URL이 없습니다.</string>
<string id="NoConfigUrl">애플리케이션 설정에 구성 URL이 없습니다.</string>
<string id="ApiFlood">API 호출이 너무 빠릅니다. 기기 세부정보와 함께 이 오류를 신고해 주세요.</string>
<string id="ApiFlood">API 호출이 너무 빠릅니다. 요청 속도를 늦추시기 바랍니다.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Lietojumprogrammas iestatījumos nav API atslēgas</string>
<string id="NoApiUrl">Lietojumprogrammas iestatījumos nav API URL</string>
<string id="NoConfigUrl">Lietojumprogrammas iestatījumos nav konfigurācijas URL</string>
<string id="ApiFlood">API izsaukumi ir pārāk ātri. Lūdzu, ziņojiet par šo kļūdu, norādot informāciju par ierīci.</string>
<string id="ApiFlood">API izsaukumi ir pārāk ātri. Lūdzu, palēniniet pieprasījumu izpildi.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Programos nustatymuose nėra API rakto</string>
<string id="NoApiUrl">Programos nustatymuose nėra API URL</string>
<string id="NoConfigUrl">Programos nustatymuose nėra konfigūracijos URL</string>
<string id="ApiFlood">API skambučiai per greiti. Praneškite apie šią klaidą pateikdami išsamią įrenginio informaciją.</string>
<string id="ApiFlood">API skambučiai per greiti. Sulėtinkite prašymų vykdymą.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Ingen API-nøkkel i applikasjonsinnstillingene</string>
<string id="NoApiUrl">Ingen API-URL i applikasjonsinnstillingene</string>
<string id="NoConfigUrl">Ingen konfigurasjons-URL i applikasjonsinnstillingene</string>
<string id="ApiFlood">API-kall for raske. Rapporter denne feilen med enhetsdetaljer.</string>
<string id="ApiFlood">API-kall for raske. Vennligst senke forespørslene dine.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Brak klucza API w ustawieniach aplikacji</string>
<string id="NoApiUrl">Brak adresu API w ustawieniach aplikacji</string>
<string id="NoConfigUrl">Brak adresu URL konfiguracji w ustawieniach aplikacji</string>
<string id="ApiFlood">Wywołania API są zbyt szybkie. Zgłoś ten błąd, podając szczegóły urządzenia.</string>
<string id="ApiFlood">Wywołania API są zbyt szybkie. Proszę spowolnić swoje żądania.</string>
</strings>

View File

@ -29,5 +29,5 @@
<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, relate este erro com detalhes do dispositivo.</string>
<string id="ApiFlood">Chamadas de API muito rápidas. Por favor, diminua a velocidade de seus pedidos.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Nicio cheie API în setările aplicației</string>
<string id="NoApiUrl">Nicio adresă URL API în setările aplicației</string>
<string id="NoConfigUrl">Nicio adresă URL de configurare în setările aplicației</string>
<string id="ApiFlood">Apeluri API prea rapide. Vă rugăm să raportați această eroare cu detaliile dispozitivului.</string>
<string id="ApiFlood">Apeluri API prea rapide. Vă rugăm să vă încetiniți solicitările.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">V nastaveniach aplikácie nie je žiadny kľúč API</string>
<string id="NoApiUrl">V nastaveniach aplikácie nie je žiadna adresa URL rozhrania API</string>
<string id="NoConfigUrl">V nastaveniach aplikácie nie je žiadna konfiguračná URL</string>
<string id="ApiFlood">Volania API sú príliš rýchle. Nahláste túto chybu s podrobnosťami o zariadení.</string>
<string id="ApiFlood">Volania API sú príliš rýchle. Spomaľte svoje požiadavky.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">V nastavitvah aplikacije ni ključa API</string>
<string id="NoApiUrl">V nastavitvah aplikacije ni URL-ja API-ja</string>
<string id="NoConfigUrl">V nastavitvah aplikacije ni konfiguracijskega URL-ja</string>
<string id="ApiFlood">API klici so prehitri. Prijavite to napako s podrobnostmi o napravi.</string>
<string id="ApiFlood">API klici so prehitri. Prosim, upočasnite svoje zahteve.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Sin clave API en la configuración de la aplicación</string>
<string id="NoApiUrl">No hay URL de API en la configuración de la aplicación</string>
<string id="NoConfigUrl">No hay URL de configuración en la configuración de la aplicación.</string>
<string id="ApiFlood">Llamadas API demasiado rápidas. Informe este error con los detalles del dispositivo.</string>
<string id="ApiFlood">Llamadas API demasiado rápidas. Por favor, ralentice sus solicitudes.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Ingen API-nyckel i applikationsinställningarna</string>
<string id="NoApiUrl">Ingen API-URL i applikationsinställningarna</string>
<string id="NoConfigUrl">Ingen konfigurations-URL i programinställningarna</string>
<string id="ApiFlood">API-anrop för snabba. Rapportera detta fel med enhetsinformation.</string>
<string id="ApiFlood">API-anrop för snabba. Vänligen sakta ner dina förfrågningar.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">ไม่มีคีย์ API ในการตั้งค่าแอปพลิเคชัน</string>
<string id="NoApiUrl">ไม่มี URL API ในการตั้งค่าแอปพลิเคชัน</string>
<string id="NoConfigUrl">ไม่มี URL การกำหนดค่าในการตั้งค่าแอปพลิเคชัน</string>
<string id="ApiFlood">การเรียก API เร็วเกินไป โปรดรายงานข้อผิดพลาดนี้พร้อมรายละเอียดอุปกรณ์</string>
<string id="ApiFlood">การเรียก API เร็วเกินไป กรุณาชะลอคำขอของคุณ</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Uygulama ayarlarında API anahtarı yok</string>
<string id="NoApiUrl">Uygulama ayarlarında API URL'si yok</string>
<string id="NoConfigUrl">Uygulama ayarlarında yapılandırma URL'si yok</string>
<string id="ApiFlood">API çağrıları çok hızlı. Lütfen bu hatayı cihaz ayrıntılarıyla birlikte bildirin.</string>
<string id="ApiFlood">API çağrıları çok hızlı. Lütfen isteklerinizi yavaşlatın.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">У налаштуваннях програми немає ключа API</string>
<string id="NoApiUrl">У налаштуваннях програми немає URL-адреси API</string>
<string id="NoConfigUrl">У налаштуваннях програми немає URL-адреси конфігурації</string>
<string id="ApiFlood">Надто швидкі виклики API. Повідомте про цю помилку з деталями пристрою.</string>
<string id="ApiFlood">Надто швидкі виклики API. Будь ласка, сповільніть свої запити.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Không có khóa API trong cài đặt ứng dụng</string>
<string id="NoApiUrl">Không có URL API trong cài đặt ứng dụng</string>
<string id="NoConfigUrl">Không có URL cấu hình trong cài đặt ứng dụng</string>
<string id="ApiFlood">Cuộc gọi API quá nhanh. Vui lòng báo cáo lỗi này với các chi tiết thiết bị.</string>
<string id="ApiFlood">Cuộc gọi API quá nhanh. Hãy làm chậm yêu cầu của bạn.</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">应用程序设置中没有 API 密钥</string>
<string id="NoApiUrl">应用程序设置中没有 API URL</string>
<string id="NoConfigUrl">应用程序设置中没有配置 URL</string>
<string id="ApiFlood">API 调用速度太快。请报告此错误并提供设备详细信息</string>
<string id="ApiFlood">API 调用速度太快。请放慢您的请求</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">應用程式設定中沒有 API 金鑰</string>
<string id="NoApiUrl">應用程式設定中沒有 API URL</string>
<string id="NoConfigUrl">應用程式設定中沒有配置 URL</string>
<string id="ApiFlood">API 呼叫速度太快。請報告此錯誤並提供設備詳細資訊</string>
<string id="ApiFlood">API 呼叫速度太快。請放慢您的請求</string>
</strings>

View File

@ -29,5 +29,5 @@
<string id="NoAPIKey">Tiada kunci API dalam tetapan aplikasi</string>
<string id="NoApiUrl">Tiada URL API dalam tetapan aplikasi</string>
<string id="NoConfigUrl">Tiada URL konfigurasi dalam tetapan aplikasi</string>
<string id="ApiFlood">Panggilan API terlalu pantas. Sila laporkan ralat ini dengan butiran peranti.</string>
<string id="ApiFlood">Panggilan API terlalu pantas. Sila perlahankan permintaan anda.</string>
</strings>

View File

@ -23,5 +23,5 @@
<string id="NoAPIKey">No API key in the application settings</string>
<string id="NoApiUrl">No API URL in the application settings</string>
<string id="NoConfigUrl">No configuration URL in the application settings</string>
<string id="ApiFlood">API calls too rapid. Please report this error with device details.</string>
<string id="ApiFlood">API calls too rapid. Please slow down your requests.</string>
</strings>

View File

@ -23,9 +23,7 @@ using Toybox.Lang;
class Globals {
// Enable printing of messages to the debug console (don't make this a Property
// as the messages can't be read from a watch!)
static const scDebug = false;
// There's a danger this time is device sensitive.
static const scMenuItemUpdateInterval = 100; // ms, 100 ms seems okay for Venu2
static const scAlertTimeout = 2000; // ms
static const scTapTimeout = 1000; // ms
static const scDebug = false;
static const scAlertTimeout = 2000; // ms
static const scTapTimeout = 1000; // ms
}

View File

@ -32,7 +32,6 @@ class HomeAssistantApp extends Application.AppBase {
hidden var strNoInternet as Lang.String;
hidden var strNoMenu as Lang.String;
hidden var strApiFlood as Lang.String;
hidden var mTimer as Timer.Timer;
hidden var mItemsToUpdate; // Array initialised by onReturnFetchMenuConfig()
hidden var mNextItemToUpdate = 0; // Index into the above array
@ -44,7 +43,6 @@ class HomeAssistantApp extends Application.AppBase {
strNoInternet = WatchUi.loadResource($.Rez.Strings.NoInternet);
strNoMenu = WatchUi.loadResource($.Rez.Strings.NoMenu);
strApiFlood = WatchUi.loadResource($.Rez.Strings.ApiFlood);
mTimer = new Timer.Timer();
}
// onStart() is called on application start up
@ -52,11 +50,7 @@ class HomeAssistantApp extends Application.AppBase {
}
// onStop() is called when your application is exiting
function onStop(state as Lang.Dictionary?) as Void {
if (mTimer != null) {
mTimer.stop();
}
}
function onStop(state as Lang.Dictionary?) as Void {}
// Return the initial view of your application here
function getInitialView() as Lang.Array<WatchUi.Views or WatchUi.InputDelegates>? {
@ -106,11 +100,9 @@ class HomeAssistantApp extends Application.AppBase {
mHaMenu = new HomeAssistantView(data, null);
WatchUi.switchToView(mHaMenu, new HomeAssistantViewDelegate(), WatchUi.SLIDE_IMMEDIATE);
mItemsToUpdate = mHaMenu.getItemsToUpdate();
mTimer.start(
method(:updateNextMenuItem),
Globals.scMenuItemUpdateInterval,
true
);
// Start the continuous update process that continues for as long as the application is running.
// The chain of functions from 'updateNextMenuItem()' calls 'updateNextMenuItem()' on completion.
updateNextMenuItem();
} else if (responseCode == -300) {
if (Globals.scDebug) {
System.println("HomeAssistantApp Note - onReturnFetchMenuConfig(): Network request timeout.");

View File

@ -85,6 +85,8 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
}
setUiToggle(state);
}
// Now this feels very "closely coupled" to the application, but it is the most reliable method instead of using a timer.
getApp().updateNextMenuItem();
}
function getState() as Void {