mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-11-08 18:48:14 +00:00
Merge pull request #53 from house-of-abbey/51-use-webhooks-for-reporting-battery-levels
Use webhooks for reporting battery
This commit is contained in:
@@ -2,91 +2,27 @@
|
||||
|
||||
From version 2.1 the application includes a background service to report the current device battery level and charging status back to Home Assistant. This is a feature that Garmin omitted to include with the Bluetooth connection.
|
||||
|
||||
We've had [a report](https://github.com/house-of-abbey/GarminHomeAssistant/issues/39) that this feature does not work without **administrator priviledges**. We've reviewed possible fixes and come up short. We are unable to fix this at present but invite those skilled in the art of Home Assistant to suggest a solution to us!
|
||||
|
||||
## Start Reporting
|
||||
|
||||
The main drawback of this solution is that the Garmin application must be run once with the feature enabled in the settings before reporting will start. Reporting continues after you have exited the application. This is a limit we cannot code around.
|
||||
|
||||
It should be as simple as that, there should be a new device in the mobile app integration called `Garmin Watch` with the battery level and charging status.
|
||||
|
||||
[](https://my.home-assistant.io/redirect/integration/?domain=mobile_app)
|
||||
|
||||
If this is not the case, head over to the [troubleshooting page](Troubleshooting.md#watch-battery-level-reporting).
|
||||
|
||||
## Stop Reporting
|
||||
|
||||
To stop the reporting, the option must be turned off in the settings and then the application run once. Running the application then removes the background service.
|
||||
|
||||
In both cases, the enable and repeat time settings can be changed whilst the application is running (i.e. live) and the background service will be amended.
|
||||
|
||||
## Listening for the `device_id`
|
||||
|
||||
Open the event viewer in Home Assistant and add `garmin.battery_level` as the event to listen to as shown below.
|
||||
|
||||
[](https://my.home-assistant.io/redirect/developer_events/)
|
||||
|
||||
<img src="images/Battery_Event_Screenshot.png" width="600" title="Listening for battery events"/>
|
||||
|
||||
```yaml
|
||||
event_type: garmin.battery_level
|
||||
data:
|
||||
level: 45.072266
|
||||
device_id: e1004acb747607bc205a6ff7bd05a4c12faf3d6d
|
||||
is_charging: false
|
||||
origin: REMOTE
|
||||
time_fired: "2024-01-01T18:15:35.900991+00:00"
|
||||
context:
|
||||
id: 01HK33T06WW4D9NEXJ9F6SRYNY
|
||||
parent_id: null
|
||||
user_id: 35e0e5a7e4bc49e9a328743697c58b90
|
||||
```
|
||||
|
||||
The `device_id` is consistent for our purposes. It does change between devices and also between the 'application' and 'widget' installations. Different device model simulators also vary the `device_id`. Here we want to extract `e1004acb747607bc205a6ff7bd05a4c12faf3d6d` for use in the sample YAML `trigger` above.
|
||||
|
||||
## Setting up the trigger to update the entity
|
||||
|
||||
The watch will send HTTP requests to HomeAssistant every 5+ minutes in a background service. The events produced by the HTTP requests can be listened for with a template entity. In this case we have two (battery level and is charging).
|
||||
|
||||
```yaml
|
||||
- trigger:
|
||||
- platform: "event"
|
||||
event_type: "garmin.battery_level"
|
||||
event_data:
|
||||
device_id: "<device-id>"
|
||||
sensor:
|
||||
- name: "<device-name> Battery Level"
|
||||
unique_id: "<uid-0>"
|
||||
device_class: "battery"
|
||||
unit_of_measurement: "%"
|
||||
state_class: "measurement"
|
||||
state: "{{ trigger.event['data']['level'] }}"
|
||||
icon: mdi:battery{% if trigger.event['data']['is_charging'] %}-charging{% endif %}{% if 0 < (trigger.event['data']['level'] | float / 10 ) | round(0) * 10 < 100 %}-{{ (trigger.event['data']['level'] | float / 10 ) | round(0) * 10 }}{% else %}{% if (trigger.event['data']['level'] | float / 10 ) | round(0) * 10 == 0 %}-outline{% else %}{% if trigger.event['data']['is_charging'] %}-100{% endif %}{% endif %}{% endif %}
|
||||
attributes:
|
||||
device_id: "<device-id>"
|
||||
- trigger:
|
||||
- platform: "event"
|
||||
event_type: "garmin.battery_level"
|
||||
event_data:
|
||||
device_id: "<device-id>"
|
||||
binary_sensor:
|
||||
- name: "<device-name> is Charging"
|
||||
unique_id: "<uid-1>"
|
||||
device_class: "battery_charging"
|
||||
state: "{{ trigger.event['data']['is_charging'] }}"
|
||||
attributes:
|
||||
device_id: "<device-id>"
|
||||
```
|
||||
|
||||
1. Copy this yaml to your `configuration.yaml`.
|
||||
2. Swap `<device-name>` for the name of your device (This can be anything and is purely for the UI). Swap `<uid-0>` and `<uid-1>` for two different unique identifiers (in the Studio Code Server these can be generated from the right click menu).
|
||||
3. Open the event dashboard and start listening for `garmin.battery_level` events and when your recieve one copy the device id and replace `<device-id>` with it (to speed up this process you can close and reopen the GarminHomeAssistant app).
|
||||
|
||||
[](https://my.home-assistant.io/redirect/developer_events/)
|
||||
|
||||
4. Restart HomeAssistant or reload the YAML.
|
||||
|
||||
[](https://my.home-assistant.io/redirect/server_controls/)
|
||||
|
||||
## Adding a sample Home Assistant UI widget
|
||||
|
||||
A gauge for battery level with a chargin icon making use of [mushroom cards](https://github.com/piitaya/lovelace-mushroom), [card_mod](https://github.com/thomasloven/lovelace-card-mod) and [stack-in-card](https://github.com/custom-cards/stack-in-card):
|
||||
A gauge for battery level with a charging icon making use of [mushroom cards](https://github.com/piitaya/lovelace-mushroom), [card_mod](https://github.com/thomasloven/lovelace-card-mod) and [stack-in-card](https://github.com/custom-cards/stack-in-card):
|
||||
|
||||
<img src="images/Battery_Guage_Screenshot.png" width="120" title="Battery Guage"/>
|
||||
<img src="images/Battery_Guage_Screenshot.png" width="120" title="Battery Gauge"/>
|
||||
|
||||
```yaml
|
||||
type: custom:stack-in-card
|
||||
@@ -103,7 +39,7 @@ cards:
|
||||
conditions:
|
||||
- condition: state
|
||||
entity: binary_sensor.<device>_is_charging
|
||||
state: 'on'
|
||||
state: "on"
|
||||
chip:
|
||||
type: entity
|
||||
icon_color: yellow
|
||||
@@ -119,7 +55,7 @@ cards:
|
||||
conditions:
|
||||
- condition: state
|
||||
entity: binary_sensor.<device>_is_charging
|
||||
state: 'off'
|
||||
state: "off"
|
||||
chip:
|
||||
type: entity
|
||||
entity: sensor.<device>_battery_level
|
||||
@@ -132,7 +68,7 @@ cards:
|
||||
}
|
||||
- type: gauge
|
||||
entity: sensor.<device>_battery_level
|
||||
unit: '%'
|
||||
unit: "%"
|
||||
name: Watch
|
||||
needle: false
|
||||
severity:
|
||||
|
||||
@@ -10,8 +10,8 @@ You can purchase cloud-based access to your Home Assistant from [Nabu Casa](http
|
||||
|
||||

|
||||
|
||||
* Your API URL would be of the format `https://<id>.ui.nabu.casa/api`
|
||||
* Your Garmin Watch Menu would be of the format Menu: `https://<id>.ui.nabu.casa/local/garmin/menu.json`
|
||||
- Your API URL would be of the format `https://<id>.ui.nabu.casa/api`
|
||||
- Your Garmin Watch Menu would be of the format Menu: `https://<id>.ui.nabu.casa/local/garmin/menu.json`
|
||||
|
||||
Where `<id>` is your personal Nabu Casa account ID.
|
||||
|
||||
@@ -23,11 +23,11 @@ Before Nabu Casa, or if you wanted to manage your own infrastructure, you might
|
||||
|
||||
Now you have to manage:
|
||||
|
||||
* Dynamic DNS
|
||||
* Public access via router port forwarding
|
||||
* Security via HTTPS and URL forwarding
|
||||
* Certificates for HTTPS via say [Let's Encrypt](https://letsencrypt.org/) (Nginx web server helps here)
|
||||
* Proxy allow list in `configuration.yaml` as follows:
|
||||
- Dynamic DNS
|
||||
- Public access via router port forwarding
|
||||
- Security via HTTPS and URL forwarding
|
||||
- Certificates for HTTPS via say [Let's Encrypt](https://letsencrypt.org/) (Nginx web server helps here)
|
||||
- Proxy allow list in `configuration.yaml` as follows:
|
||||
|
||||
```yaml
|
||||
http:
|
||||
@@ -110,7 +110,7 @@ There's an online way of testing the API URL too, thanks to [REQBIN](https://req
|
||||
|
||||
## Watch Battery Level Reporting
|
||||
|
||||
For this you will need to have already got the main application or widget working with a menu in order to prove that the API calls are successful. We have proven this works with both our home brew infrastructure as well as Nabu Casa. Now with a script similar to one of the following two, you should be able to fake the watch API call and verify receipt by Home Assistant in the Event logging as shown in '[Listening for the `device_id`](BatteryReporting.md#listening-for-the-device_id)'.
|
||||
For this you will need to have already got the main application or widget working with a menu in order to prove that the API calls are successful. We have proven this works with both our home brew infrastructure as well as Nabu Casa. Now with a script similar to one of the following two, you should be able to fake the watch API call and verify receipt by Home Assistant.
|
||||
|
||||
#### Battery: Linux, MacOS, UNIX, Cygwin etc
|
||||
|
||||
@@ -123,7 +123,7 @@ Assume a file called: `send_battery.bash`
|
||||
# ./send_battery.bash 19 0
|
||||
#
|
||||
|
||||
API_KEY="<Your API key>"
|
||||
WEBHOOK_ID="<Your Webhook ID>"
|
||||
URL="https://<Your Domain>/api"
|
||||
|
||||
level=${1:-50}
|
||||
@@ -138,10 +138,9 @@ echo "Battery Charging? = ${is_charging}"
|
||||
echo ""
|
||||
|
||||
curl -s -X POST \
|
||||
-H "Authorization: Bearer ${API_KEY}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"level": '${level}', "is_charging": '${is_charging}', "device_id": "Bash Script"}' \
|
||||
${URL}/events/garmin.battery_level
|
||||
-d '{ "type": "update_sensor_states", "data": [ {"state": ${level},"type": "sensor","unique_id": "battery_level"}, {"state": ${is_charging},"type": "binary_sensor","unique_id": "battery_is_charging"} ] }' \
|
||||
${URL}/webhook/${WEBHOOK_ID}
|
||||
```
|
||||
|
||||
Execute:
|
||||
@@ -156,7 +155,15 @@ The output looks like this:
|
||||
Battery Level = 45
|
||||
Battery Charging? = true
|
||||
|
||||
{"message":"Event garmin.battery_level fired."}
|
||||
{
|
||||
"battery_level": {
|
||||
"success": true
|
||||
},
|
||||
"battery_is_charging": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
NB. The device ID can be any string for the purposes of this testing. Your Garmin device will choose this ID for you when it submits the readings.
|
||||
@@ -171,7 +178,7 @@ rem battery% charging {0|1}
|
||||
rem ./home_assistant_battery_level 19 0
|
||||
rem
|
||||
|
||||
set API_KEY=<Your API key>FEt_fGzW_lV0xitvJPkaQHSLhGm90ADovgMbJxdHH2I
|
||||
set WEBHOOK_ID=<Your Webhook ID>
|
||||
set URL=https://<Your Domain>/api
|
||||
|
||||
if [%1] == [] (
|
||||
@@ -195,10 +202,9 @@ echo "Battery Charging? = %is_charging%"
|
||||
echo.
|
||||
|
||||
curl -s -X POST ^
|
||||
-H "Authorization: Bearer %API_KEY%" ^
|
||||
-H "Content-Type: application/json" ^
|
||||
-d "{\"level\": %level%, \"is_charging\": %is_charging%, \"device_id\": \"Batch File\"}" ^
|
||||
%URL%/events/garmin.battery_level
|
||||
-d "{ \"type\": \"update_sensor_states\", \"data\": [ {\"state\": %level%,\"type\": \"sensor\",\"unique_id\": \"battery_level\"}, {\"state\": %is_charging%,\"type\": \"binary_sensor\",\"unique_id\": \"battery_is_charging\"} ] }" ^
|
||||
%URL%/webhook/%WEBHOOK_ID%
|
||||
|
||||
echo.
|
||||
pause
|
||||
@@ -216,7 +222,15 @@ The output looks like this:
|
||||
"Battery Level = 41"
|
||||
"Battery Charging? = true"
|
||||
|
||||
{"message":"Event garmin.battery_level fired."}
|
||||
{
|
||||
"battery_level": {
|
||||
"success": true
|
||||
},
|
||||
"battery_is_charging": {
|
||||
"success": true
|
||||
}
|
||||
}
|
||||
|
||||
Press any key to continue . . .
|
||||
```
|
||||
|
||||
@@ -237,7 +251,21 @@ https://<Your Domain>/api/events/garmin.battery_level
|
||||
JSON for copy & paste:
|
||||
|
||||
```json
|
||||
{"level": 19, "is_charging": true, "device_id": "REQBIN"}
|
||||
{
|
||||
"type": "update_sensor_states",
|
||||
"data": [
|
||||
{
|
||||
"state": 19,
|
||||
"type": "sensor",
|
||||
"unique_id": "battery_level"
|
||||
},
|
||||
{
|
||||
"state": true,
|
||||
"type": "binary_sensor",
|
||||
"unique_id": "battery_is_charging"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
@@ -28,7 +28,8 @@ set SDK_PATH=%SDK_PATH:~0,-1%\bin
|
||||
rem Assume we can create and use this directory
|
||||
set DEST=export
|
||||
rem Device for simulation
|
||||
set DEVICE=venu2
|
||||
rem set DEVICE=venu2
|
||||
set DEVICE=vivoactive3
|
||||
|
||||
rem C:\>java -jar %SDK_PATH%\monkeybrains.jar -h
|
||||
rem usage: monkeyc [-a <arg>] [-b <arg>] [--build-stats <arg>] [-c <arg>] [-d <arg>]
|
||||
@@ -100,7 +101,8 @@ rem Compile PRG for a single device for side loading
|
||||
--jungles %SRC%\monkey.jungle ^
|
||||
--private-key %SRC%\..\developer_key ^
|
||||
--device %DEVICE%_sim ^
|
||||
--warn
|
||||
--warn ^
|
||||
--release
|
||||
|
||||
if %ERRORLEVEL% equ 0 (
|
||||
%SDK_PATH%\monkeydo.bat %SRC%\bin\HomeAssistant.prg %DEVICE%
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 100 KiB |
@@ -38,10 +38,11 @@
|
||||
<string id="NoJson">لم يتم إرجاع JSON من طلب HTTP.</string>
|
||||
<string id="UnhandledHttpErr">قام طلب HTTP بإرجاع رمز الخطأ =</string>
|
||||
<string id="TrailingSlashErr">يجب ألا يحتوي عنوان URL لواجهة برمجة التطبيقات على شرطة مائلة لاحقة '/'</string>
|
||||
<string id="WebhookFailed">فشل تسجيل Webhook</string>
|
||||
<string id="Available" scope="glance">متاح</string>
|
||||
<string id="Checking" scope="glance">تدقيق...</string>
|
||||
<string id="Unavailable" scope="glance">غير متوفره</string>
|
||||
<string id="Unconfigured" scope="glance">غير مهيأ</string>
|
||||
<string id="Unconfigured" scope="glance">غير مكون</string>
|
||||
<string id="Cached" scope="glance">مخبأة</string>
|
||||
<string id="GlanceMenu" scope="glance">قائمة طعام</string>
|
||||
<!-- لإعدادات واجهة المستخدم الرسومية -->
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Няма върнат JSON от HTTP заявка.</string>
|
||||
<string id="UnhandledHttpErr">HTTP заявката върна код на грешка =</string>
|
||||
<string id="TrailingSlashErr">URL адресът на API не трябва да има наклонена черта '/' в края</string>
|
||||
<string id="WebhookFailed">Неуспешно регистриране на Webhook</string>
|
||||
<string id="Available" scope="glance">На разположение</string>
|
||||
<string id="Checking" scope="glance">Проверка...</string>
|
||||
<string id="Unavailable" scope="glance">Недостъпен</string>
|
||||
@@ -53,7 +54,7 @@
|
||||
<string id="SettingsCacheConfig">Трябва ли приложението да кешира конфигурацията на менюто?</string>
|
||||
<string id="SettingsClearCache">Трябва ли приложението да изчисти съществуващия кеш при следващото стартиране?</string>
|
||||
<string id="SettingsAppTimeout">Изчакване в секунди. Излезте от приложението след този период на неактивност, за да запазите батерията на устройството.</string>
|
||||
<string id="SettingsConfirmTimeout">След това време (в секунди) диалоговият прозорец за потвърждение за действие се затваря автоматично и действието се отменя. Задайте 0, за да деактивирате изчакването.</string>
|
||||
<string id="SettingsConfirmTimeout">След това време (в секунди) диалоговият прозорец за потвърждение на действие се затваря автоматично и действието се отменя. Задайте 0, за да деактивирате изчакването.</string>
|
||||
<string id="SettingsMenuItemStyle">Стил на елемент от менюто.</string>
|
||||
<string id="SettingsMenuItemStyleIcons">Икони</string>
|
||||
<string id="SettingsMenuItemStyleText">Допълнителен текст</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Z požadavku HTTP se nevrátil žádný JSON.</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>
|
||||
<string id="WebhookFailed">Registrace Webhooku se nezdařila</string>
|
||||
<string id="Available" scope="glance">Dostupný</string>
|
||||
<string id="Checking" scope="glance">Kontrola...</string>
|
||||
<string id="Unavailable" scope="glance">Není k dispozici</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Ingen JSON returneret fra HTTP-anmodning.</string>
|
||||
<string id="UnhandledHttpErr">HTTP-anmodning returnerede fejlkode =</string>
|
||||
<string id="TrailingSlashErr">API URL må ikke have en efterfølgende skråstreg '/'</string>
|
||||
<string id="WebhookFailed">Kunne ikke registrere Webhook</string>
|
||||
<string id="Available" scope="glance">Ledig</string>
|
||||
<string id="Checking" scope="glance">Tjekker...</string>
|
||||
<string id="Unavailable" scope="glance">Ikke tilgængelig</string>
|
||||
@@ -57,7 +58,7 @@
|
||||
<string id="SettingsMenuItemStyle">Menupunkt stil.</string>
|
||||
<string id="SettingsMenuItemStyleIcons">Ikoner</string>
|
||||
<string id="SettingsMenuItemStyleText">Yderligere tekst</string>
|
||||
<string id="SettingsTextAlign">Venstre (fra) eller Højre (til) menujustering.</string>
|
||||
<string id="SettingsTextAlign">Venstre (fra) eller højre (til) menujustering.</string>
|
||||
<string id="LeftToRight">Venstre til højre</string>
|
||||
<string id="RightToLeft">Højre til venstre</string>
|
||||
<string id="SettingsWidgetStart">(Kun widget) Start automatisk applikationen fra widgetten uden at vente på et tryk.</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Von der HTTP-Anfrage wurde kein JSON zurückgegeben.</string>
|
||||
<string id="UnhandledHttpErr">Die HTTP-Anfrage gab folgenden Fehlercode zurück = </string>
|
||||
<string id="TrailingSlashErr">Die API-URL darf keinen abschließenden Schrägstrich „/“ enthalten.</string>
|
||||
<string id="WebhookFailed">Webhook konnte nicht registriert werden</string>
|
||||
<string id="Available" scope="glance">Verfügbar</string>
|
||||
<string id="Checking" scope="glance">Überprüfung...</string>
|
||||
<string id="Unavailable" scope="glance">Nicht verfügbar</string>
|
||||
|
||||
@@ -38,17 +38,18 @@
|
||||
<string id="NoJson">Er is geen JSON geretourneerd door een HTTP-verzoek.</string>
|
||||
<string id="UnhandledHttpErr">HTTP-verzoek retourneerde foutcode =</string>
|
||||
<string id="TrailingSlashErr">API-URL mag geen afsluitende slash '/' bevatten</string>
|
||||
<string id="WebhookFailed">Registreren van Webhook is mislukt</string>
|
||||
<string id="Available" scope="glance">Beschikbaar</string>
|
||||
<string id="Checking" scope="glance">Controleren...</string>
|
||||
<string id="Unavailable" scope="glance">Niet beschikbaar</string>
|
||||
<string id="Unconfigured" scope="glance">Niet geconfigureerd</string>
|
||||
<string id="Cached" scope="glance">In cache opgeslagen</string>
|
||||
<string id="GlanceMenu" scope="glance">Menu</string>
|
||||
<!-- Voor de instellingen-GUI -->
|
||||
<!-- Voor de instellingen GUI -->
|
||||
<string id="SettingsSelect">Selecteer...</string>
|
||||
<string id="SettingsApiKey">API-sleutel voor HomeAssistant.</string>
|
||||
<string id="SettingsApiKeyPrompt">Toegangstoken met lange levensduur.</string>
|
||||
<string id="SettingsApiUrl">URL voor HomeAssistant API.</string>
|
||||
<string id="SettingsApiUrl">URL voor HomeAssistant-API.</string>
|
||||
<string id="SettingsConfigUrl">URL voor menuconfiguratie (JSON).</string>
|
||||
<string id="SettingsCacheConfig">Moet de applicatie de menuconfiguratie in de cache opslaan?</string>
|
||||
<string id="SettingsClearCache">Moet de applicatie de volgende keer dat deze wordt gestart de bestaande cache wissen?</string>
|
||||
|
||||
@@ -35,9 +35,10 @@
|
||||
<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="NoJson">HTTP-päringust ei tagastatud ühtegi JSON-i.</string>
|
||||
<string id="NoJson">HTTP päringust ei tagastatud ühtegi JSON-i.</string>
|
||||
<string id="UnhandledHttpErr">HTTP päring tagastas veakoodi =</string>
|
||||
<string id="TrailingSlashErr">API URL-i lõpus ei tohi olla kaldkriipsu „/”</string>
|
||||
<string id="WebhookFailed">Webhaoki registreerimine ebaõnnestus</string>
|
||||
<string id="Available" scope="glance">Saadaval</string>
|
||||
<string id="Checking" scope="glance">Kontrollimine...</string>
|
||||
<string id="Unavailable" scope="glance">Pole saadaval</string>
|
||||
@@ -61,6 +62,6 @@
|
||||
<string id="LeftToRight">Vasakult paremale</string>
|
||||
<string id="RightToLeft">Paremalt vasakule</string>
|
||||
<string id="SettingsWidgetStart">(Ainult vidin) Käivitage rakendus automaatselt vidinast ilma puudutust ootamata.</string>
|
||||
<string id="SettingsEnableBatteryLevel">Lubage taustteenus, et saata Home Assistantile kella aku tase.</string>
|
||||
<string id="SettingsEnableBatteryLevel">Lubage taustateenus, et saata Home Assistantile kella aku tase.</string>
|
||||
<string id="SettingsBatteryLevelRefreshRate">Värskendussagedus (minutites), mille juures taustateenus peaks aku taseme saatmist kordama.</string>
|
||||
</strings>
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">HTTP-pyynnöstä ei palautettu JSON-tiedostoja.</string>
|
||||
<string id="UnhandledHttpErr">HTTP-pyyntö palautti virhekoodin =</string>
|
||||
<string id="TrailingSlashErr">API-URL-osoitteessa ei saa olla perässä olevaa kauttaviivaa '/'</string>
|
||||
<string id="WebhookFailed">Webhookin rekisteröinti epäonnistui</string>
|
||||
<string id="Available" scope="glance">Saatavilla</string>
|
||||
<string id="Checking" scope="glance">Tarkistetaan...</string>
|
||||
<string id="Unavailable" scope="glance">Ei saatavilla</string>
|
||||
@@ -53,7 +54,7 @@
|
||||
<string id="SettingsCacheConfig">Pitäisikö sovelluksen tallentaa valikon asetukset välimuistiin?</string>
|
||||
<string id="SettingsClearCache">Pitäisikö sovelluksen tyhjentää olemassa oleva välimuisti, kun se käynnistetään seuraavan kerran?</string>
|
||||
<string id="SettingsAppTimeout">Aikakatkaisu sekunneissa. Poistu sovelluksesta tämän käyttämättömyyden jälkeen säästääksesi laitteen akkua.</string>
|
||||
<string id="SettingsConfirmTimeout">Tämän ajan kuluttua (sekunneissa) toiminnon vahvistusikkuna suljetaan automaattisesti ja toiminto peruutetaan. Aseta arvoksi 0, jos haluat poistaa aikakatkaisun käytöstä.</string>
|
||||
<string id="SettingsConfirmTimeout">Tämän ajan kuluttua (sekunneissa) toiminnon vahvistusikkuna suljetaan automaattisesti ja toiminto peruutetaan. Aseta arvoksi 0 poistaaksesi aikakatkaisun käytöstä.</string>
|
||||
<string id="SettingsMenuItemStyle">Valikkokohdan tyyli.</string>
|
||||
<string id="SettingsMenuItemStyleIcons">Kuvakkeet</string>
|
||||
<string id="SettingsMenuItemStyleText">Lisäteksti</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Aucun JSON renvoyé par la requête HTTP.</string>
|
||||
<string id="UnhandledHttpErr">La requête HTTP a renvoyé un code d'erreur =</string>
|
||||
<string id="TrailingSlashErr">L'URL de l'API ne doit pas comporter de barre oblique finale '/'</string>
|
||||
<string id="WebhookFailed">Échec de l'enregistrement du Webhook</string>
|
||||
<string id="Available" scope="glance">Disponible</string>
|
||||
<string id="Checking" scope="glance">Vérification...</string>
|
||||
<string id="Unavailable" scope="glance">Indisponible</string>
|
||||
@@ -52,7 +53,7 @@
|
||||
<string id="SettingsConfigUrl">URL de configuration des menus (JSON).</string>
|
||||
<string id="SettingsCacheConfig">L'application doit-elle mettre en cache la configuration du menu ?</string>
|
||||
<string id="SettingsClearCache">L'application doit-elle vider le cache existant au prochain démarrage ?</string>
|
||||
<string id="SettingsAppTimeout">Délai d'expiration en secondes. Quittez l'application après cette période d'inactivité pour économiser la batterie de l'appareil.</string>
|
||||
<string id="SettingsAppTimeout">Délai d'attente en secondes. Quittez l'application après cette période d'inactivité pour économiser la batterie de l'appareil.</string>
|
||||
<string id="SettingsConfirmTimeout">Passé ce délai (en secondes), une boîte de dialogue de confirmation d'une action se ferme automatiquement et l'action est annulée. Réglez sur 0 pour désactiver le délai d'attente.</string>
|
||||
<string id="SettingsMenuItemStyle">Style des éléments de menu.</string>
|
||||
<string id="SettingsMenuItemStyleIcons">Icônes</string>
|
||||
|
||||
@@ -30,14 +30,15 @@
|
||||
<string id="NoInternet">Δεν υπάρχει σύνδεση στο διαδίκτυο</string>
|
||||
<string id="NoResponse">Καμία απάντηση, ελέγξτε τη σύνδεση στο Διαδίκτυο</string>
|
||||
<string id="NoAPIKey" scope="glance">Δεν υπάρχει κλειδί API στις ρυθμίσεις της εφαρμογής</string>
|
||||
<string id="NoApiUrl" scope="glance">Δεν υπάρχει URL API στις ρυθμίσεις της εφαρμογής</string>
|
||||
<string id="NoApiUrl" scope="glance">Δεν υπάρχει διεύθυνση URL API στις ρυθμίσεις της εφαρμογής</string>
|
||||
<string id="NoConfigUrl" scope="glance">Δεν υπάρχει διεύθυνση URL διαμόρφωσης στις ρυθμίσεις της εφαρμογής</string>
|
||||
<string id="ApiFlood">Κλήσεις API πολύ γρήγορες. Παρακαλώ επιβραδύνετε τα αιτήματά σας.</string>
|
||||
<string id="ApiUrlNotFound">Η διεύθυνση URL δεν βρέθηκε. Πιθανό σφάλμα διεύθυνσης URL API στις ρυθμίσεις.</string>
|
||||
<string id="ConfigUrlNotFound">Η διεύθυνση URL δεν βρέθηκε. Πιθανό σφάλμα διαμόρφωσης URL στις ρυθμίσεις.</string>
|
||||
<string id="NoJson">Δεν επιστράφηκε JSON από αίτημα HTTP.</string>
|
||||
<string id="UnhandledHttpErr">Το αίτημα HTTP επέστρεψε κωδικό σφάλματος =</string>
|
||||
<string id="TrailingSlashErr">Η διεύθυνση URL του API δεν πρέπει να έχει τελική κάθετο "/"</string>
|
||||
<string id="TrailingSlashErr">Η διεύθυνση URL του API δεν πρέπει να έχει κάθετο "/"</string>
|
||||
<string id="WebhookFailed">Η εγγραφή του Webhook απέτυχε</string>
|
||||
<string id="Available" scope="glance">Διαθέσιμος</string>
|
||||
<string id="Checking" scope="glance">Ελεγχος...</string>
|
||||
<string id="Unavailable" scope="glance">Μη διαθέσιμο</string>
|
||||
@@ -53,7 +54,7 @@
|
||||
<string id="SettingsCacheConfig">Πρέπει η εφαρμογή να αποθηκεύσει προσωρινά τη διαμόρφωση του μενού;</string>
|
||||
<string id="SettingsClearCache">Πρέπει η εφαρμογή να διαγράψει την υπάρχουσα προσωρινή μνήμη την επόμενη φορά που θα ξεκινήσει;</string>
|
||||
<string id="SettingsAppTimeout">Timeout σε δευτερόλεπτα. Κλείστε την εφαρμογή μετά από αυτήν την περίοδο αδράνειας για να εξοικονομήσετε την μπαταρία της συσκευής.</string>
|
||||
<string id="SettingsConfirmTimeout">Μετά από αυτό το χρονικό διάστημα (σε δευτερόλεπτα), ένα παράθυρο διαλόγου επιβεβαίωσης για μια ενέργεια κλείνει αυτόματα και η ενέργεια ακυρώνεται. Ορίστε στο 0 για να απενεργοποιήσετε το χρονικό όριο.</string>
|
||||
<string id="SettingsConfirmTimeout">Μετά από αυτό το διάστημα (σε δευτερόλεπτα), ένα παράθυρο διαλόγου επιβεβαίωσης για μια ενέργεια κλείνει αυτόματα και η ενέργεια ακυρώνεται. Ορίστε στο 0 για να απενεργοποιήσετε το χρονικό όριο.</string>
|
||||
<string id="SettingsMenuItemStyle">Στυλ στοιχείου μενού.</string>
|
||||
<string id="SettingsMenuItemStyleIcons">εικονίδια</string>
|
||||
<string id="SettingsMenuItemStyleText">Πρόσθετο Κείμενο</string>
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<string id="Executed" scope="glance">מְאוּשָׁר</string>
|
||||
<string id="NoPhone" scope="glance">אין חיבור לטלפון</string>
|
||||
<string id="NoInternet">אין חיבור אינטרנט</string>
|
||||
<string id="NoResponse">אין תגובה, בדוק חיבור לאינטרנט</string>
|
||||
<string id="NoResponse">אין תגובה, בדוק את חיבור האינטרנט</string>
|
||||
<string id="NoAPIKey" scope="glance">אין מפתח API בהגדרות האפליקציה</string>
|
||||
<string id="NoApiUrl" scope="glance">אין כתובת API בהגדרות האפליקציה</string>
|
||||
<string id="NoConfigUrl" scope="glance">אין כתובת URL לתצורה בהגדרות האפליקציה</string>
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">לא הוחזר JSON מבקשת HTTP.</string>
|
||||
<string id="UnhandledHttpErr">בקשת HTTP החזירה קוד שגיאה =</string>
|
||||
<string id="TrailingSlashErr">כתובת ה-API לא חייבת לכלול לוכסן אחורי '/'</string>
|
||||
<string id="WebhookFailed">רישום Webhook נכשל</string>
|
||||
<string id="Available" scope="glance">זמין</string>
|
||||
<string id="Checking" scope="glance">בודק...</string>
|
||||
<string id="Unavailable" scope="glance">אינו זמין</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">HTTP zahtjev nije vratio JSON.</string>
|
||||
<string id="UnhandledHttpErr">HTTP zahtjev vratio je kod greške =</string>
|
||||
<string id="TrailingSlashErr">API URL ne smije imati kosu crtu na kraju '/'</string>
|
||||
<string id="WebhookFailed">Registracija Webhooka nije uspjela</string>
|
||||
<string id="Available" scope="glance">Dostupno</string>
|
||||
<string id="Checking" scope="glance">Provjera...</string>
|
||||
<string id="Unavailable" scope="glance">Nedostupan</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">A HTTP-kérésből nem érkezett vissza JSON.</string>
|
||||
<string id="UnhandledHttpErr">A HTTP-kérés = hibakódot adott vissza</string>
|
||||
<string id="TrailingSlashErr">Az API URL-ben nem lehet perjel a „/”</string>
|
||||
<string id="WebhookFailed">Nem sikerült regisztrálni a Webhook-ot</string>
|
||||
<string id="Available" scope="glance">Elérhető</string>
|
||||
<string id="Checking" scope="glance">Ellenőrzés...</string>
|
||||
<string id="Unavailable" scope="glance">Nem érhető el</string>
|
||||
@@ -50,17 +51,17 @@
|
||||
<string id="SettingsApiKeyPrompt">Hosszú életű hozzáférési token.</string>
|
||||
<string id="SettingsApiUrl">A HomeAssistant API URL-je.</string>
|
||||
<string id="SettingsConfigUrl">URL a menükonfigurációhoz (JSON).</string>
|
||||
<string id="SettingsCacheConfig">Az alkalmazásnak gyorsítótárba kell helyeznie a menü konfigurációját?</string>
|
||||
<string id="SettingsCacheConfig">Az alkalmazásnak gyorsítótárba kell helyeznie a menükonfigurációt?</string>
|
||||
<string id="SettingsClearCache">Törölje az alkalmazásnak a meglévő gyorsítótárat a következő indításakor?</string>
|
||||
<string id="SettingsAppTimeout">Időtúllépés másodpercben. Az eszköz akkumulátorának kímélése érdekében lépjen ki az alkalmazásból ezen inaktivitási időszak után.</string>
|
||||
<string id="SettingsConfirmTimeout">Ezen idő elteltével (másodpercben) egy művelet megerősítő párbeszédpanele automatikusan bezárul, és a művelet megszakad. Állítsa 0-ra az időtúllépés letiltásához.</string>
|
||||
<string id="SettingsConfirmTimeout">Ezen idő letelte után (másodpercben) a művelet megerősítő párbeszédablakja automatikusan bezárul, és a művelet megszakad. Állítsa 0-ra az időtúllépés letiltásához.</string>
|
||||
<string id="SettingsMenuItemStyle">Menüelem stílusa.</string>
|
||||
<string id="SettingsMenuItemStyleIcons">Ikonok</string>
|
||||
<string id="SettingsMenuItemStyleText">Kiegészítő szöveg</string>
|
||||
<string id="SettingsTextAlign">Balra (ki) vagy Jobbra (be) Menüigazítás.</string>
|
||||
<string id="LeftToRight">Balról jobbra</string>
|
||||
<string id="RightToLeft">Jobbról balra</string>
|
||||
<string id="SettingsWidgetStart">(Csak Widget) Az alkalmazás automatikus indítása a widgetről anélkül, hogy egy érintésre várna.</string>
|
||||
<string id="SettingsWidgetStart">(Csak widget) Az alkalmazás automatikus indítása a widgetről anélkül, hogy egy érintésre várna.</string>
|
||||
<string id="SettingsEnableBatteryLevel">Engedélyezze a háttérszolgáltatást, hogy elküldje az óra töltöttségi szintjét a Home Assistantnek.</string>
|
||||
<string id="SettingsBatteryLevelRefreshRate">Az a frissítési gyakoriság (percben), amelynél a háttérszolgáltatásnak meg kell ismételnie az akkumulátor töltöttségi szintjének küldését.</string>
|
||||
</strings>
|
||||
@@ -31,13 +31,14 @@
|
||||
<string id="NoResponse">Tidak Ada Respon, periksa koneksi Internet</string>
|
||||
<string id="NoAPIKey" scope="glance">Tidak ada kunci API di pengaturan aplikasi</string>
|
||||
<string id="NoApiUrl" scope="glance">Tidak ada URL API di pengaturan aplikasi</string>
|
||||
<string id="NoConfigUrl" scope="glance">Tidak ada URL konfigurasi dalam pengaturan aplikasi</string>
|
||||
<string id="NoConfigUrl" scope="glance">Tidak ada URL konfigurasi di pengaturan aplikasi</string>
|
||||
<string id="ApiFlood">Panggilan API terlalu cepat. Harap memperlambat permintaan Anda.</string>
|
||||
<string id="ApiUrlNotFound">URL tidak ditemukan. Potensi kesalahan URL API dalam pengaturan.</string>
|
||||
<string id="ConfigUrlNotFound">URL tidak ditemukan. Potensi kesalahan URL Konfigurasi dalam pengaturan.</string>
|
||||
<string id="NoJson">Tidak ada JSON yang dikembalikan dari permintaan HTTP.</string>
|
||||
<string id="UnhandledHttpErr">Permintaan HTTP mengembalikan kode kesalahan =</string>
|
||||
<string id="TrailingSlashErr">URL API tidak boleh memiliki garis miring '/'</string>
|
||||
<string id="WebhookFailed">Gagal mendaftarkan Webhook</string>
|
||||
<string id="Available" scope="glance">Tersedia</string>
|
||||
<string id="Checking" scope="glance">Memeriksa...</string>
|
||||
<string id="Unavailable" scope="glance">Tidak tersedia</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Nessun JSON restituito dalla richiesta HTTP.</string>
|
||||
<string id="UnhandledHttpErr">La richiesta HTTP ha restituito il codice di errore =</string>
|
||||
<string id="TrailingSlashErr">L'URL dell'API non deve avere una barra finale "/"</string>
|
||||
<string id="WebhookFailed">Impossibile registrare il Webhook</string>
|
||||
<string id="Available" scope="glance">Disponibile</string>
|
||||
<string id="Checking" scope="glance">Controllo...</string>
|
||||
<string id="Unavailable" scope="glance">Non disponibile</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">HTTP リクエストから JSON が返されませんでした。</string>
|
||||
<string id="UnhandledHttpErr">HTTP リクエストがエラー コードを返しました =</string>
|
||||
<string id="TrailingSlashErr">API URL の末尾にスラッシュ「/」を含めることはできません</string>
|
||||
<string id="WebhookFailed">Webhookの登録に失敗しました</string>
|
||||
<string id="Available" scope="glance">利用可能</string>
|
||||
<string id="Checking" scope="glance">チェック中...</string>
|
||||
<string id="Unavailable" scope="glance">利用不可</string>
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
<string id="ConfigUrlNotFound">URL을 찾을 수 없습니다. 설정에 잠재적인 구성 URL 오류가 있습니다.</string>
|
||||
<string id="NoJson">HTTP 요청에서 JSON이 반환되지 않았습니다.</string>
|
||||
<string id="UnhandledHttpErr">HTTP 요청이 오류 코드를 반환했습니다 =</string>
|
||||
<string id="TrailingSlashErr">API URL에는 후행 슬래시 '/'가 있어서는 안 됩니다.</string>
|
||||
<string id="TrailingSlashErr">API URL에는 후행 슬래시 '/'가 없어야 합니다.</string>
|
||||
<string id="WebhookFailed">웹훅 등록 실패</string>
|
||||
<string id="Available" scope="glance">사용 가능</string>
|
||||
<string id="Checking" scope="glance">확인 중...</string>
|
||||
<string id="Unavailable" scope="glance">없는</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">No HTTP pieprasījuma netika atgriezts neviens JSON fails.</string>
|
||||
<string id="UnhandledHttpErr">HTTP pieprasījums atgrieza kļūdas kodu =</string>
|
||||
<string id="TrailingSlashErr">API URL beigās nedrīkst būt slīpsvītra “/”</string>
|
||||
<string id="WebhookFailed">Neizdevās reģistrēt Web aizķeri</string>
|
||||
<string id="Available" scope="glance">Pieejams</string>
|
||||
<string id="Checking" scope="glance">Notiek pārbaude...</string>
|
||||
<string id="Unavailable" scope="glance">Nav pieejams</string>
|
||||
@@ -57,7 +58,7 @@
|
||||
<string id="SettingsMenuItemStyle">Izvēlnes vienuma stils.</string>
|
||||
<string id="SettingsMenuItemStyleIcons">Ikonas</string>
|
||||
<string id="SettingsMenuItemStyleText">Papildu teksts</string>
|
||||
<string id="SettingsTextAlign">Kreisā (izslēgta) vai labā (ieslēgta) izvēlnes izlīdzināšana.</string>
|
||||
<string id="SettingsTextAlign">Kreisā (izslēgta) vai labā (ieslēgta) izvēlnes līdzināšana.</string>
|
||||
<string id="LeftToRight">No kreisās uz labo</string>
|
||||
<string id="RightToLeft">No labās uz kreiso</string>
|
||||
<string id="SettingsWidgetStart">(tikai logrīkam) Automātiski startējiet lietojumprogrammu no logrīka, negaidot pieskārienu.</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Joks JSON negrąžintas iš HTTP užklausos.</string>
|
||||
<string id="UnhandledHttpErr">HTTP užklausa grąžino klaidos kodą =</string>
|
||||
<string id="TrailingSlashErr">API URL pabaigoje negali būti pasvirojo brūkšnio „/“</string>
|
||||
<string id="WebhookFailed">Nepavyko užregistruoti Webhook</string>
|
||||
<string id="Available" scope="glance">Yra</string>
|
||||
<string id="Checking" scope="glance">Tikrinama...</string>
|
||||
<string id="Unavailable" scope="glance">Nepasiekiamas</string>
|
||||
@@ -46,11 +47,11 @@
|
||||
<string id="GlanceMenu" scope="glance">Meniu</string>
|
||||
<!-- Dėl nustatymų GUI -->
|
||||
<string id="SettingsSelect">Pasirinkite...</string>
|
||||
<string id="SettingsApiKey">API raktas, skirtas „HomeAssistant“.</string>
|
||||
<string id="SettingsApiKey">API raktas, skirtas HomeAssistant.</string>
|
||||
<string id="SettingsApiKeyPrompt">Ilgalaikis prieigos raktas.</string>
|
||||
<string id="SettingsApiUrl">„HomeAssistant“ API URL.</string>
|
||||
<string id="SettingsConfigUrl">Meniu konfigūravimo URL (JSON).</string>
|
||||
<string id="SettingsCacheConfig">Ar programa turėtų talpykloje išsaugoti meniu konfigūraciją?</string>
|
||||
<string id="SettingsCacheConfig">Ar programa turėtų išsaugoti meniu konfigūraciją talpykloje?</string>
|
||||
<string id="SettingsClearCache">Ar programa turėtų išvalyti esamą talpyklą kitą kartą paleidus?</string>
|
||||
<string id="SettingsAppTimeout">Skirtasis laikas sekundėmis. Po šio neveiklumo laikotarpio išeikite iš programos, kad taupytumėte įrenginio akumuliatorių.</string>
|
||||
<string id="SettingsConfirmTimeout">Praėjus šiam laikui (sekundėmis), veiksmo patvirtinimo dialogo langas automatiškai uždaromas ir veiksmas atšaukiamas. Nustatykite 0, kad išjungtumėte skirtąjį laiką.</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Ingen JSON returnert fra HTTP-forespørsel.</string>
|
||||
<string id="UnhandledHttpErr">HTTP-forespørsel returnerte feilkode =</string>
|
||||
<string id="TrailingSlashErr">API URL må ikke ha en etterfølgende skråstrek '/'</string>
|
||||
<string id="WebhookFailed">Kunne ikke registrere Webhook</string>
|
||||
<string id="Available" scope="glance">Tilgjengelig</string>
|
||||
<string id="Checking" scope="glance">Sjekker...</string>
|
||||
<string id="Unavailable" scope="glance">Utilgjengelig</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Z żądania HTTP nie zwrócono żadnego kodu JSON.</string>
|
||||
<string id="UnhandledHttpErr">Żądanie HTTP zwróciło kod błędu =</string>
|
||||
<string id="TrailingSlashErr">Adres URL interfejsu API nie może zawierać końcowego ukośnika „/”</string>
|
||||
<string id="WebhookFailed">Nie udało się zarejestrować webhooka</string>
|
||||
<string id="Available" scope="glance">Dostępny</string>
|
||||
<string id="Checking" scope="glance">Kontrola...</string>
|
||||
<string id="Unavailable" scope="glance">Niedostępne</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Nenhum JSON foi retornado da solicitação HTTP.</string>
|
||||
<string id="UnhandledHttpErr">Solicitação HTTP retornou código de erro =</string>
|
||||
<string id="TrailingSlashErr">O URL da API não deve ter uma barra final '/'</string>
|
||||
<string id="WebhookFailed">Falha ao registrar o Webhook</string>
|
||||
<string id="Available" scope="glance">Disponível</string>
|
||||
<string id="Checking" scope="glance">Verificando...</string>
|
||||
<string id="Unavailable" scope="glance">Indisponível</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Niciun JSON nu a fost returnat de la solicitarea HTTP.</string>
|
||||
<string id="UnhandledHttpErr">Solicitarea HTTP a returnat codul de eroare =</string>
|
||||
<string id="TrailingSlashErr">Adresa URL API nu trebuie să aibă o bară oblică „/”</string>
|
||||
<string id="WebhookFailed">Nu s-a putut înregistra Webhook</string>
|
||||
<string id="Available" scope="glance">Disponibil</string>
|
||||
<string id="Checking" scope="glance">Control...</string>
|
||||
<string id="Unavailable" scope="glance">Indisponibil</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Z požiadavky HTTP sa nevrátil žiadny JSON.</string>
|
||||
<string id="UnhandledHttpErr">Požiadavka HTTP vrátila kód chyby =</string>
|
||||
<string id="TrailingSlashErr">Adresa URL rozhrania API nesmie obsahovať koncovú lomku „/“</string>
|
||||
<string id="WebhookFailed">Registrácia Webhooku zlyhala</string>
|
||||
<string id="Available" scope="glance">Dostupné</string>
|
||||
<string id="Checking" scope="glance">Prebieha kontrola...</string>
|
||||
<string id="Unavailable" scope="glance">nedostupné</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Zahteva HTTP ni vrnila JSON.</string>
|
||||
<string id="UnhandledHttpErr">Zahteva HTTP je vrnila kodo napake =</string>
|
||||
<string id="TrailingSlashErr">URL API-ja ne sme imeti končne poševnice '/'</string>
|
||||
<string id="WebhookFailed">Webhooka ni bilo mogoče registrirati</string>
|
||||
<string id="Available" scope="glance">Na voljo</string>
|
||||
<string id="Checking" scope="glance">Preverjanje ...</string>
|
||||
<string id="Unavailable" scope="glance">Ni na voljo</string>
|
||||
@@ -48,7 +49,7 @@
|
||||
<string id="SettingsSelect">Izberite ...</string>
|
||||
<string id="SettingsApiKey">API ključ za HomeAssistant.</string>
|
||||
<string id="SettingsApiKeyPrompt">Dolgoživ dostopni žeton.</string>
|
||||
<string id="SettingsApiUrl">URL za API HomeAssistant.</string>
|
||||
<string id="SettingsApiUrl">URL za HomeAssistant API.</string>
|
||||
<string id="SettingsConfigUrl">URL za konfiguracijo menija (JSON).</string>
|
||||
<string id="SettingsCacheConfig">Ali naj aplikacija predpomni konfiguracijo menija?</string>
|
||||
<string id="SettingsClearCache">Ali naj aplikacija ob naslednjem zagonu počisti obstoječi predpomnilnik?</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">No se devolvió ningún JSON de la solicitud HTTP.</string>
|
||||
<string id="UnhandledHttpErr">La solicitud HTTP devolvió el código de error =</string>
|
||||
<string id="TrailingSlashErr">La URL de API no debe tener una barra diagonal '/'</string>
|
||||
<string id="WebhookFailed">No se pudo registrar el webhook</string>
|
||||
<string id="Available" scope="glance">Disponible</string>
|
||||
<string id="Checking" scope="glance">Comprobación...</string>
|
||||
<string id="Unavailable" scope="glance">Indisponible</string>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<!--
|
||||
Generated by Google Translate: English to Swedish
|
||||
Genereras av Google Translate från engelska
|
||||
Genererad av Google Translate från engelska
|
||||
-->
|
||||
|
||||
<strings>
|
||||
@@ -35,9 +35,10 @@
|
||||
<string id="ApiFlood">API-anrop för snabba. Vänligen sakta ner dina förfrågningar.</string>
|
||||
<string id="ApiUrlNotFound">Webbadressen hittades inte. Potentiellt API-URL-fel i inställningarna.</string>
|
||||
<string id="ConfigUrlNotFound">Webbadressen hittades inte. Potentiellt konfigurations-URL-fel i inställningarna.</string>
|
||||
<string id="NoJson">Ingen JSON returnerades från HTTP-begäran.</string>
|
||||
<string id="NoJson">Ingen JSON returnerades från HTTP-förfrågan.</string>
|
||||
<string id="UnhandledHttpErr">HTTP-begäran returnerade felkod =</string>
|
||||
<string id="TrailingSlashErr">API-URL får inte ha ett snedstreck '/'</string>
|
||||
<string id="WebhookFailed">Det gick inte att registrera Webhook</string>
|
||||
<string id="Available" scope="glance">Tillgängliga</string>
|
||||
<string id="Checking" scope="glance">Kontroll...</string>
|
||||
<string id="Unavailable" scope="glance">Inte tillgänglig</string>
|
||||
@@ -52,7 +53,7 @@
|
||||
<string id="SettingsConfigUrl">URL för menykonfiguration (JSON).</string>
|
||||
<string id="SettingsCacheConfig">Ska programmet cachelagra menykonfigurationen?</string>
|
||||
<string id="SettingsClearCache">Ska programmet rensa den befintliga cachen nästa gång den startas?</string>
|
||||
<string id="SettingsAppTimeout">Timeout på sekunder. Avsluta programmet efter denna period av inaktivitet för att spara enhetens batteri.</string>
|
||||
<string id="SettingsAppTimeout">Timeout i sekunder. Avsluta programmet efter denna period av inaktivitet för att spara enhetens batteri.</string>
|
||||
<string id="SettingsConfirmTimeout">Efter denna tid (i sekunder) stängs en bekräftelsedialog för en åtgärd automatiskt och åtgärden avbryts. Ställ in på 0 för att inaktivera timeout.</string>
|
||||
<string id="SettingsMenuItemStyle">Menyalternativ stil.</string>
|
||||
<string id="SettingsMenuItemStyleIcons">Ikoner</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">ไม่มี JSON ที่ส่งคืนจากคำขอ HTTP</string>
|
||||
<string id="UnhandledHttpErr">คำขอ HTTP ส่งคืนรหัสข้อผิดพลาด =</string>
|
||||
<string id="TrailingSlashErr">URL ของ API ต้องไม่มีเครื่องหมายทับต่อท้าย '/'</string>
|
||||
<string id="WebhookFailed">ลงทะเบียน Webhook.dll ไม่สำเร็จ</string>
|
||||
<string id="Available" scope="glance">มีอยู่</string>
|
||||
<string id="Checking" scope="glance">กำลังตรวจสอบ...</string>
|
||||
<string id="Unavailable" scope="glance">ไม่พร้อมใช้งาน</string>
|
||||
|
||||
@@ -37,7 +37,8 @@
|
||||
<string id="ConfigUrlNotFound">URL bulunamadı. Ayarlarda Olası Yapılandırma URL'si hatası.</string>
|
||||
<string id="NoJson">HTTP isteğinden JSON döndürülmedi.</string>
|
||||
<string id="UnhandledHttpErr">HTTP isteği hata kodunu döndürdü =</string>
|
||||
<string id="TrailingSlashErr">API URL'sinin sonunda '/' eğik çizgi olmamalıdır</string>
|
||||
<string id="TrailingSlashErr">API URL'sinin sonunda eğik çizgi '/' olmamalıdır</string>
|
||||
<string id="WebhookFailed">Webhook kaydedilemedi</string>
|
||||
<string id="Available" scope="glance">Mevcut</string>
|
||||
<string id="Checking" scope="glance">Kontrol etme...</string>
|
||||
<string id="Unavailable" scope="glance">Kullanım dışı</string>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<!--
|
||||
Generated by Google Translate: English to Ukrainian
|
||||
Створено Google Translate з англійської
|
||||
Згенеровано Google Translate з англійської
|
||||
-->
|
||||
|
||||
<strings>
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Запит HTTP не повертає JSON.</string>
|
||||
<string id="UnhandledHttpErr">Запит HTTP повернув код помилки =</string>
|
||||
<string id="TrailingSlashErr">URL-адреса API не повинна містити косу риску '/'</string>
|
||||
<string id="WebhookFailed">Не вдалося зареєструвати Webhook</string>
|
||||
<string id="Available" scope="glance">в наявності</string>
|
||||
<string id="Checking" scope="glance">Перевірка...</string>
|
||||
<string id="Unavailable" scope="glance">Недоступний</string>
|
||||
@@ -49,7 +50,7 @@
|
||||
<string id="SettingsApiKey">Ключ API для HomeAssistant.</string>
|
||||
<string id="SettingsApiKeyPrompt">Довговічний маркер доступу.</string>
|
||||
<string id="SettingsApiUrl">URL для HomeAssistant API.</string>
|
||||
<string id="SettingsConfigUrl">URL для налаштування меню (JSON).</string>
|
||||
<string id="SettingsConfigUrl">URL-адреса для налаштування меню (JSON).</string>
|
||||
<string id="SettingsCacheConfig">Чи має програма кешувати конфігурацію меню?</string>
|
||||
<string id="SettingsClearCache">Чи слід програмі очистити наявний кеш під час наступного запуску?</string>
|
||||
<string id="SettingsAppTimeout">Час очікування в секундах. Вийдіть із програми після цього періоду бездіяльності, щоб заощадити батарею пристрою.</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Không có JSON nào được trả về từ yêu cầu HTTP.</string>
|
||||
<string id="UnhandledHttpErr">Yêu cầu HTTP trả về mã lỗi =</string>
|
||||
<string id="TrailingSlashErr">URL API không được có dấu gạch chéo ở cuối '/'</string>
|
||||
<string id="WebhookFailed">Không đăng ký được Webhook</string>
|
||||
<string id="Available" scope="glance">Có sẵn</string>
|
||||
<string id="Checking" scope="glance">Đang kiểm tra...</string>
|
||||
<string id="Unavailable" scope="glance">Không có sẵn</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">HTTP 请求未返回 JSON。</string>
|
||||
<string id="UnhandledHttpErr">HTTP请求返回错误码=</string>
|
||||
<string id="TrailingSlashErr">API URL 不得有尾部斜杠“/”</string>
|
||||
<string id="WebhookFailed">注册Webhook失败</string>
|
||||
<string id="Available" scope="glance">可用的</string>
|
||||
<string id="Checking" scope="glance">检查...</string>
|
||||
<string id="Unavailable" scope="glance">不可用</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">HTTP 請求未傳回 JSON。</string>
|
||||
<string id="UnhandledHttpErr">HTTP請求回傳錯誤碼=</string>
|
||||
<string id="TrailingSlashErr">API URL 不得有尾部斜線“/”</string>
|
||||
<string id="WebhookFailed">註冊Webhook失敗</string>
|
||||
<string id="Available" scope="glance">可用的</string>
|
||||
<string id="Checking" scope="glance">檢查...</string>
|
||||
<string id="Unavailable" scope="glance">不可用</string>
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<string id="NoJson">Tiada JSON dikembalikan daripada permintaan HTTP.</string>
|
||||
<string id="UnhandledHttpErr">Permintaan HTTP mengembalikan kod ralat =</string>
|
||||
<string id="TrailingSlashErr">URL API tidak boleh mempunyai garis miring '/'</string>
|
||||
<string id="WebhookFailed">Gagal mendaftar Webhook</string>
|
||||
<string id="Available" scope="glance">Tersedia</string>
|
||||
<string id="Checking" scope="glance">Menyemak...</string>
|
||||
<string id="Unavailable" scope="glance">Tidak ada</string>
|
||||
|
||||
@@ -15,30 +15,48 @@
|
||||
<properties>
|
||||
<property id="api_key" type="string"></property>
|
||||
|
||||
<!--
|
||||
The webhook ID is the last part of the webhook URL.
|
||||
It is secret and should not be shared.
|
||||
It will not be set in settings but will be
|
||||
generated by the application and stored in
|
||||
persistent storage.
|
||||
-->
|
||||
<property id="webhook_id" type="string"></property>
|
||||
|
||||
<!--
|
||||
Internal URL "https://homeassistant.local/api"
|
||||
External URL "https://<dynamic DNS>/api"
|
||||
-->
|
||||
<property id="api_url" type="string"></property>
|
||||
|
||||
<!-- Best be a public URL in order to work away from your home LAN and have a trusted HTTPS certificate -->
|
||||
<!--
|
||||
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>
|
||||
|
||||
<!-- Decide if the menu configuration should be cached. -->
|
||||
<property id="cache_config" type="boolean">false</property>
|
||||
|
||||
<!-- Clear the menu configuration on next application start, and refetch, then set this back to false -->
|
||||
<!--
|
||||
Clear the menu configuration on next application start,
|
||||
and refetch, then set this back to false
|
||||
-->
|
||||
<property id="clear_cache" type="boolean">false</property>
|
||||
|
||||
<!--
|
||||
Application timeout in seconds, except 0 for no timeout (default). After this amount of elapsed time
|
||||
with no activity, exit the application.
|
||||
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.
|
||||
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>
|
||||
|
||||
@@ -55,8 +73,8 @@
|
||||
<!--
|
||||
Widget specific setting:
|
||||
As soon as the menu has been fetched start show the menu of items.
|
||||
This behaviour is inconsistent with the standard Garmin User Interface, but has been
|
||||
requested by users so has been made the non-default option.
|
||||
This behaviour is inconsistent with the standard Garmin User Interface,
|
||||
but has been requested by users so has been made the non-default option.
|
||||
-->
|
||||
<property id="widget_start_no_tap" type="boolean">false</property>
|
||||
|
||||
@@ -66,8 +84,8 @@
|
||||
<property id="enable_battery_level" type="boolean">false</property>
|
||||
|
||||
<!--
|
||||
If enabled by 'enable_battery_level', the refresh rate (in minutes) at which the background service
|
||||
should repeat sending the battery level.
|
||||
If enabled by 'enable_battery_level', the refresh rate (in minutes) at
|
||||
which the background service should repeat sending the battery level.
|
||||
-->
|
||||
<property id="battery_level_refresh_rate" type="number">15</property>
|
||||
|
||||
|
||||
@@ -107,4 +107,10 @@
|
||||
<settingConfig type="numeric" min="5" />
|
||||
</setting>
|
||||
|
||||
<setting
|
||||
propertyKey="@Properties.webhook_id"
|
||||
title="Webhook ID"
|
||||
>
|
||||
<settingConfig type="alphaNumeric" />
|
||||
</setting>
|
||||
</settings>
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<string id="NoJson">No JSON returned from HTTP request.</string>
|
||||
<string id="UnhandledHttpErr">HTTP request returned error code = </string>
|
||||
<string id="TrailingSlashErr">API URL must not have a trailing slash '/'</string>
|
||||
<string id="WebhookFailed">Failed to register Webhook</string>
|
||||
<string id="Available" scope="glance">Available</string>
|
||||
<string id="Checking" scope="glance">Checking...</string>
|
||||
<string id="Unavailable" scope="glance">Unavailable</string>
|
||||
|
||||
@@ -51,17 +51,26 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
|
||||
} else {
|
||||
// Don't use Settings.* here as the object lasts < 30 secs and is recreated each time the background service is run
|
||||
Communications.makeWebRequest(
|
||||
(Properties.getValue("api_url") as Lang.String) + "/events/garmin.battery_level",
|
||||
(Properties.getValue("api_url") as Lang.String) + "/webhook/" + (Properties.getValue("webhook_id") as Lang.String),
|
||||
{
|
||||
"level" => System.getSystemStats().battery,
|
||||
"is_charging" => System.getSystemStats().charging,
|
||||
"device_id" => System.getDeviceSettings().uniqueIdentifier
|
||||
"type" => "update_sensor_states",
|
||||
"data" => [
|
||||
{
|
||||
"state" => System.getSystemStats().battery,
|
||||
"type" => "sensor",
|
||||
"unique_id" => "battery_level"
|
||||
},
|
||||
{
|
||||
"state" => System.getSystemStats().charging,
|
||||
"type" => "binary_sensor",
|
||||
"unique_id" => "battery_is_charging"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
:method => Communications.HTTP_REQUEST_METHOD_POST,
|
||||
:headers => {
|
||||
"Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON,
|
||||
"Authorization" => "Bearer " + (Properties.getValue("api_key") as Lang.String)
|
||||
"Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON
|
||||
},
|
||||
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
|
||||
},
|
||||
|
||||
@@ -47,6 +47,7 @@ class RezStrings {
|
||||
private static var strNoJson as Lang.String or Null;
|
||||
private static var strUnhandledHttpErr as Lang.String or Null;
|
||||
private static var strTrailingSlashErr as Lang.String or Null;
|
||||
private static var strWebhookFailed as Lang.String or Null;
|
||||
(:glance)
|
||||
private static var strAvailable as Lang.String or Null;
|
||||
(:glance)
|
||||
@@ -98,6 +99,7 @@ class RezStrings {
|
||||
strNoJson = WatchUi.loadResource($.Rez.Strings.NoJson);
|
||||
strUnhandledHttpErr = WatchUi.loadResource($.Rez.Strings.UnhandledHttpErr);
|
||||
strTrailingSlashErr = WatchUi.loadResource($.Rez.Strings.TrailingSlashErr);
|
||||
strWebhookFailed = WatchUi.loadResource($.Rez.Strings.WebhookFailed);
|
||||
strAvailable = WatchUi.loadResource($.Rez.Strings.Available);
|
||||
strChecking = WatchUi.loadResource($.Rez.Strings.Checking);
|
||||
strUnavailable = WatchUi.loadResource($.Rez.Strings.Unavailable);
|
||||
@@ -178,6 +180,10 @@ class RezStrings {
|
||||
return strTrailingSlashErr;
|
||||
}
|
||||
|
||||
static function getWebhookFailed() as Lang.String {
|
||||
return strWebhookFailed;
|
||||
}
|
||||
|
||||
static function getAvailable() as Lang.String {
|
||||
return strAvailable;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ class Settings {
|
||||
public static const MENU_STYLE_TEXT = 1;
|
||||
|
||||
private static var mApiKey as Lang.String = "";
|
||||
private static var mWebhookId as Lang.String = "";
|
||||
private static var mApiUrl as Lang.String = "";
|
||||
private static var mConfigUrl as Lang.String = "";
|
||||
private static var mCacheConfig as Lang.Boolean = false;
|
||||
@@ -45,10 +46,14 @@ class Settings {
|
||||
private static var mBatteryRefreshRate as Lang.Number = 15; // minutes
|
||||
private static var mIsApp as Lang.Boolean = false;
|
||||
|
||||
// Must keep the object so it doesn't get garbage collected.
|
||||
private static var mWebhookManager as WebhookManager or Null;
|
||||
|
||||
// Called on application start and then whenever the settings are changed.
|
||||
static function update() {
|
||||
mIsApp = getApp().getIsApp();
|
||||
mApiKey = Properties.getValue("api_key");
|
||||
mWebhookId = Properties.getValue("webhook_id");
|
||||
mApiUrl = Properties.getValue("api_url");
|
||||
mConfigUrl = Properties.getValue("config_url");
|
||||
mCacheConfig = Properties.getValue("cache_config");
|
||||
@@ -64,7 +69,12 @@ class Settings {
|
||||
// Manage this inside the application or widget only (not a glance or background service process)
|
||||
if (mIsApp) {
|
||||
if (mIsBatteryLevelEnabled) {
|
||||
if ((System has :ServiceDelegate) and
|
||||
if (getWebhookId().equals("")) {
|
||||
mWebhookManager = new WebhookManager();
|
||||
mWebhookManager.requestWebhookId();
|
||||
}
|
||||
if (!getWebhookId().equals("") and
|
||||
(System has :ServiceDelegate) and
|
||||
((Background.getTemporalEventRegisteredTime() == null) or
|
||||
(Background.getTemporalEventRegisteredTime() != (mBatteryRefreshRate * 60)))) {
|
||||
Background.registerForTemporalEvent(new Time.Duration(mBatteryRefreshRate * 60)); // Convert to seconds
|
||||
@@ -90,6 +100,20 @@ class Settings {
|
||||
return mApiKey;
|
||||
}
|
||||
|
||||
static function getWebhookId() as Lang.String {
|
||||
return mWebhookId;
|
||||
}
|
||||
|
||||
static function setWebhookId(webhookId as Lang.String) {
|
||||
mWebhookId = webhookId;
|
||||
Properties.setValue("webhook_id", mWebhookId);
|
||||
}
|
||||
|
||||
static function removeWebhookId() {
|
||||
mWebhookId = "";
|
||||
Properties.setValue("webhook_id", mWebhookId);
|
||||
}
|
||||
|
||||
static function getApiUrl() as Lang.String {
|
||||
return mApiUrl;
|
||||
}
|
||||
@@ -131,4 +155,11 @@ class Settings {
|
||||
return mIsWidgetStartNoTap;
|
||||
}
|
||||
|
||||
static function disableBatteryLevel() {
|
||||
mIsBatteryLevelEnabled = false;
|
||||
Properties.setValue("enable_battery_level", mIsBatteryLevelEnabled);
|
||||
if ((System has :ServiceDelegate) and (Background.getTemporalEventRegisteredTime() != null)) {
|
||||
Background.deleteTemporalEvent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
223
source/WebhookManager.mc
Normal file
223
source/WebhookManager.mc
Normal file
@@ -0,0 +1,223 @@
|
||||
using Toybox.Lang;
|
||||
using Toybox.Communications;
|
||||
using Toybox.System;
|
||||
|
||||
// Can use push view so must never be run in a glance context
|
||||
class WebhookManager {
|
||||
function onReturnRequestWebhookId(responseCode as Lang.Number, data as Null or Lang.Dictionary or Lang.String) as Void {
|
||||
switch (responseCode) {
|
||||
case Communications.BLE_HOST_TIMEOUT:
|
||||
case Communications.BLE_CONNECTION_UNAVAILABLE:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRequestWebhookId() Response Code: BLE_HOST_TIMEOUT or BLE_CONNECTION_UNAVAILABLE, Bluetooth connection severed.");
|
||||
}
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getNoPhone() + ".");
|
||||
break;
|
||||
|
||||
case Communications.BLE_QUEUE_FULL:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRequestWebhookId() Response Code: BLE_QUEUE_FULL, API calls too rapid.");
|
||||
}
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getApiFlood());
|
||||
break;
|
||||
|
||||
case Communications.NETWORK_REQUEST_TIMED_OUT:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRequestWebhookId() Response Code: NETWORK_REQUEST_TIMED_OUT, check Internet connection.");
|
||||
}
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getNoResponse());
|
||||
break;
|
||||
|
||||
case Communications.NETWORK_RESPONSE_OUT_OF_MEMORY:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRequestWebhookId() Response Code: NETWORK_RESPONSE_OUT_OF_MEMORY, are we going too fast?");
|
||||
}
|
||||
// Ignore and see if we can carry on
|
||||
break;
|
||||
case Communications.INVALID_HTTP_BODY_IN_NETWORK_RESPONSE:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRequestWebhookId() Response Code: INVALID_HTTP_BODY_IN_NETWORK_RESPONSE, check JSON is returned.");
|
||||
}
|
||||
Settings.disableBatteryLevel();
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getNoJson());
|
||||
break;
|
||||
|
||||
case 404:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRequestWebhookId() Response Code: 404, page not found. Check API URL setting.");
|
||||
}
|
||||
Settings.disableBatteryLevel();
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getApiUrlNotFound());
|
||||
break;
|
||||
|
||||
case 201:
|
||||
var id = data.get("webhook_id") as Lang.String or Null;
|
||||
if (id != null) {
|
||||
Settings.setWebhookId(id);
|
||||
registerWebhookSensor({
|
||||
"device_class" => "battery",
|
||||
"name" => "Battery Level",
|
||||
"state" => System.getSystemStats().battery,
|
||||
"type" => "sensor",
|
||||
"unique_id" => "battery_level",
|
||||
"unit_of_measurement" => "%",
|
||||
"state_class" => "measurement",
|
||||
"entity_category" => "diagnostic",
|
||||
"disabled" => false
|
||||
});
|
||||
registerWebhookSensor({
|
||||
"device_class" => "battery_charging",
|
||||
"name" => "Battery is Charging",
|
||||
"state" => System.getSystemStats().charging,
|
||||
"type" => "binary_sensor",
|
||||
"unique_id" => "battery_is_charging",
|
||||
"entity_category" => "diagnostic",
|
||||
"disabled" => false
|
||||
});
|
||||
} else {
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRequestWebhookId(): No webhook id in response data.");
|
||||
}
|
||||
Settings.disableBatteryLevel();
|
||||
ErrorView.show(RezStrings.getWebhookFailed());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRequestWebhookId(): Unhandled HTTP response code = " + responseCode);
|
||||
}
|
||||
Settings.disableBatteryLevel();
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getUnhandledHttpErr() + responseCode);
|
||||
}
|
||||
}
|
||||
|
||||
function requestWebhookId() {
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager requestWebhookId(): Requesting webhook id");
|
||||
}
|
||||
Communications.makeWebRequest(
|
||||
Settings.getApiUrl() + "/mobile_app/registrations",
|
||||
{
|
||||
"device_id" => System.getDeviceSettings().uniqueIdentifier,
|
||||
"app_id" => "garmin_home_assistant",
|
||||
"app_name" => RezStrings.getAppName(),
|
||||
"app_version" => "",
|
||||
"device_name" => "Garmin Watch",
|
||||
"manufacturer" => "Garmin",
|
||||
"model" => "",
|
||||
"os_name" => "",
|
||||
"os_version" => Lang.format("$1$.$2$", System.getDeviceSettings().firmwareVersion),
|
||||
"supports_encryption" => false,
|
||||
"app_data" => {}
|
||||
},
|
||||
{
|
||||
:method => Communications.HTTP_REQUEST_METHOD_POST,
|
||||
:headers => {
|
||||
"Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON,
|
||||
"Authorization" => "Bearer " + Settings.getApiKey()
|
||||
},
|
||||
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
|
||||
},
|
||||
method(:onReturnRequestWebhookId)
|
||||
);
|
||||
}
|
||||
|
||||
function onReturnRegisterWebhookSensor(responseCode as Lang.Number, data as Null or Lang.Dictionary or Lang.String) as Void {
|
||||
switch (responseCode) {
|
||||
case Communications.BLE_HOST_TIMEOUT:
|
||||
case Communications.BLE_CONNECTION_UNAVAILABLE:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRegisterWebhookSensor() Response Code: BLE_HOST_TIMEOUT or BLE_CONNECTION_UNAVAILABLE, Bluetooth connection severed.");
|
||||
}
|
||||
Settings.removeWebhookId();
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getNoPhone() + ".");
|
||||
break;
|
||||
|
||||
case Communications.BLE_QUEUE_FULL:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRegisterWebhookSensor() Response Code: BLE_QUEUE_FULL, API calls too rapid.");
|
||||
}
|
||||
Settings.removeWebhookId();
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getApiFlood());
|
||||
break;
|
||||
|
||||
case Communications.NETWORK_REQUEST_TIMED_OUT:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRegisterWebhookSensor() Response Code: NETWORK_REQUEST_TIMED_OUT, check Internet connection.");
|
||||
}
|
||||
Settings.removeWebhookId();
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getNoResponse());
|
||||
break;
|
||||
|
||||
case Communications.NETWORK_RESPONSE_OUT_OF_MEMORY:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRegisterWebhookSensor() Response Code: NETWORK_RESPONSE_OUT_OF_MEMORY, are we going too fast?");
|
||||
}
|
||||
Settings.removeWebhookId();
|
||||
// Ignore and see if we can carry on
|
||||
break;
|
||||
case Communications.INVALID_HTTP_BODY_IN_NETWORK_RESPONSE:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRegisterWebhookSensor() Response Code: INVALID_HTTP_BODY_IN_NETWORK_RESPONSE, check JSON is returned.");
|
||||
}
|
||||
Settings.removeWebhookId();
|
||||
Settings.disableBatteryLevel();
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getNoJson());
|
||||
break;
|
||||
|
||||
case 404:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRequestWebhookId() Response Code: 404, page not found. Check API URL setting.");
|
||||
}
|
||||
Settings.removeWebhookId();
|
||||
Settings.disableBatteryLevel();
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getApiUrlNotFound());
|
||||
break;
|
||||
|
||||
case 201:
|
||||
if ((data.get("success") as Lang.Boolean or Null) == true) {
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRegisterWebhookSensor(): Success");
|
||||
}
|
||||
} else {
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRegisterWebhookSensor(): Failure");
|
||||
}
|
||||
Settings.removeWebhookId();
|
||||
Settings.disableBatteryLevel();
|
||||
ErrorView.show(RezStrings.getWebhookFailed());
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager onReturnRequestWebhookId(): Unhandled HTTP response code = " + responseCode);
|
||||
}
|
||||
Settings.removeWebhookId();
|
||||
Settings.disableBatteryLevel();
|
||||
ErrorView.show(RezStrings.getWebhookFailed() + "\n" + RezStrings.getUnhandledHttpErr() + responseCode);
|
||||
}
|
||||
}
|
||||
|
||||
function registerWebhookSensor(sensor as Lang.Object) {
|
||||
if (Globals.scDebug) {
|
||||
System.println("WebhookManager registerWebhookSensor(): Registering webhook sensor: " + sensor.toString());
|
||||
}
|
||||
Communications.makeWebRequest(
|
||||
Settings.getApiUrl() + "/webhook/" + Settings.getWebhookId(),
|
||||
{
|
||||
"type" => "register_sensor",
|
||||
"data" => sensor
|
||||
},
|
||||
{
|
||||
:method => Communications.HTTP_REQUEST_METHOD_POST,
|
||||
:headers => {
|
||||
"Content-Type" => Communications.REQUEST_CONTENT_TYPE_JSON
|
||||
},
|
||||
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON
|
||||
},
|
||||
method(:onReturnRegisterWebhookSensor)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user