mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-16 11:28:40 +00:00
Compare commits
19 Commits
v2.24
...
5f34f870d9
Author | SHA1 | Date | |
---|---|---|---|
5f34f870d9 | |||
ada18f8323 | |||
f74a3168de | |||
7e58e5416d | |||
1f7090092f | |||
4ed132b9ca | |||
fd213cc210 | |||
7423e609d8 | |||
9df43cdb01 | |||
5ee8a6cc6a | |||
5e35276628 | |||
28f4ffc70b | |||
e8f2c0d3bb | |||
71cba8c21c | |||
236a4969d7 | |||
e41f451fbc | |||
c13e898e59 | |||
a77870c2eb | |||
155649f162 |
@ -37,3 +37,7 @@
|
||||
| 2.22 | Major feature release adding an optional PIN to menu items. This significant new feature has been provided by [moesterheld](https://github.com/moesterheld). Please do not rely on this application for security. Use at your own risk! |
|
||||
| 2.23 | Added "info" menu item for displaying information via a template without a tap or toggle. Essentially like the old 'template' type that was deprecated when all items were amended to display evaluated templates. That action removed the display only items too hastily. Added 5 new devices in the model range Instinct 3 and Instinct E. |
|
||||
| 2.24 | Experiment to prevent new Webhook IDs being created unnecessarily. Reduced the latency for the first menu update. Added 4 new devices: approachs50, descentg2, descentmk1, and gpsmap66. |
|
||||
| 2.25 | 2 Bug fixes. First time startup issues caused by v2.24 change and a fix for pure numbers in returned templates. |
|
||||
| 2.26 | Retry responsive menu fix failed in v2.24. Cosmetic internal class changes. |
|
||||
| 2.27 | Trivial bug fix for the glance view to prevent the "Unconfigured" result being erroneously displayed because the settings were not yet pulled from persistent storage. |
|
||||
| 2.28 | Added support for Vivoactive 6 device which also required an SDK update to 8.1.0. |
|
||||
|
@ -120,6 +120,32 @@ There's an online way of testing the API URL too, thanks to [REQBIN](https://req
|
||||
|
||||

|
||||
|
||||
#### SSL Certificate Chain
|
||||
|
||||
With thanks to [@ziceva](https://github.com/ziceva) for solving this problem. The symptoms are:
|
||||
1. Using an API URL with SSL (HTTPS), the [web-based editor](https://house-of-abbey.github.io/GarminHomeAssistant/web/) running in a browser on the same phone running Garmin Connect works well.
|
||||
2. The exact same configuration is set in the Garmin Home Assistant application.
|
||||
3. The Garmin Home Assistant application reports:
|
||||
```
|
||||
API: not available
|
||||
Menu: not available
|
||||
```
|
||||
|
||||
**Solution: Make sure you use a _full chain_ certificate in your HTTPS proxy as some watches might be unable to validate the site certificate alone.**
|
||||
|
||||
Most web browsers and OSes probably have the latest Certificate Authorities (CAs) trusted out-of-the-box and so they do not need the full chain to verify the certificates. Garmin watches may not have the latest CAs and that is why the Troubleshooting web page does not catch this problem. E.g. It turns out some Garmin watches do not have the LetsEncrypt CA marked as trusted.
|
||||
|
||||
To verify if you have this issue you can use a tool like [SSL Shoppers's SSL Checker](https://www.sslshopper.com/ssl-checker.html), which will catch this issue. The following two screen captures illustrate the difference between partial and full chain certificates respectively.
|
||||
|
||||
##### Partial Chain Certificate
|
||||
|
||||

|
||||
|
||||
##### Full Chain Certificate
|
||||
|
||||

|
||||
|
||||
|
||||
### Top Problems
|
||||
|
||||
1. Failure to copy & paste keys and URLs leading to minor and hard to see errors in strings, even with protestations they are the same! (No they weren't...)
|
||||
|
81
export.cmd
81
export.cmd
@ -29,45 +29,49 @@ rem Assume we can create and use this directory
|
||||
set DEST=export
|
||||
set IQ=HomeAssistant-app.iq
|
||||
|
||||
rem C:\>java -jar %SDK_PATH%\monkeybrains.jar -h
|
||||
rem usage: monkeyc [-a <arg>] [-b <arg>] [--build-stats <arg>] [-c <arg>] [-d <arg>]
|
||||
rem [--debug-log-level <arg>] [--debug-log-output <arg>] [-e]
|
||||
rem usage: monkeyc [-a <arg>] [-b <arg>] [--build-stats <arg>] [-d <arg>]
|
||||
rem [--debug-log-level <arg>] [--debug-log-output <arg>]
|
||||
rem [--disable-api-has-check-removal] [--disable-v2-opcodes] [-e]
|
||||
rem [--Eno-invalid-symbol] [-f <arg>] [-g] [-h] [-i <arg>] [-k] [-l <arg>]
|
||||
rem [-m <arg>] [--no-gen-styles] [-o <arg>] [-O <arg>] [-p <arg>] [-r] [-s
|
||||
rem <arg>] [-t] [-u <arg>] [-v] [-w] [-x <arg>] [-y <arg>] [-z <arg>]
|
||||
rem -a,--apidb <arg> API import file
|
||||
rem -b,--apimir <arg> API MIR file
|
||||
rem --build-stats <arg> Print build stats [0=basic]
|
||||
rem -c,--api-level <arg> API Level to target
|
||||
rem -d,--device <arg> Target device
|
||||
rem --debug-log-level <arg> Debug logging verbosity [0=errors, 1=basic,
|
||||
rem 2=intermediate, 3=verbose]
|
||||
rem --debug-log-output <arg>Output log zip file
|
||||
rem -e,--package-app Create an application package.
|
||||
rem --Eno-invalid-symbol Do not error when a symbol is found to be invalid
|
||||
rem -f,--jungles <arg> Jungle files
|
||||
rem -g,--debug Print debug output
|
||||
rem -h,--help Prints help information
|
||||
rem -i,--import-dbg <arg> Import api.debug.xml
|
||||
rem -k,--profile Enable profiling support
|
||||
rem -l,--typecheck <arg> Type check [0=off, 1=gradual, 2=informative,
|
||||
rem 3=strict]
|
||||
rem -m,--manifest <arg> Manifest file (deprecated)
|
||||
rem --no-gen-styles Do not generate Rez.Styles module
|
||||
rem -o,--output <arg> Output file to create
|
||||
rem -O,--optimization <arg> Optimization level [0=none, 1=basic, 2=fast
|
||||
rem optimizations, 3=slow optimizations] [p=optimize
|
||||
rem performance, z=optimize code space]
|
||||
rem -p,--project-info <arg> projectInfo.xml file to use when compiling
|
||||
rem -r,--release Strip debug information
|
||||
rem -s,--sdk-version <arg> SDK version to target (deprecated, use -c
|
||||
rem -t,--unit-test Enables compilation of unit tests
|
||||
rem -u,--devices <arg> devices.xml file to use when compiling (deprecated)
|
||||
rem -v,--version Prints the compiler version
|
||||
rem -w,--warn Show compiler warnings
|
||||
rem -x,--excludes <arg> Add annotations to the exclude list (deprecated)
|
||||
rem -y,--private-key <arg> Private key to sign builds with
|
||||
rem -z,--rez <arg> Resource files (deprecated)
|
||||
rem [-m <arg>] [--no-gen-styles] [-o <arg>] [-O <arg>] [-p <arg>] [-r] [-t]
|
||||
rem [-u <arg>] [-v] [-w] [-x <arg>] [-y <arg>] [-z <arg>]
|
||||
rem -a,--apidb <arg> API import file
|
||||
rem -b,--apimir <arg> API MIR file
|
||||
rem --build-stats <arg> Print build stats [0=basic]
|
||||
rem -d,--device <arg> Target device
|
||||
rem --debug-log-level <arg> Debug logging verbosity [0=errors, 1=basic,
|
||||
rem 2=intermediate, 3=verbose]
|
||||
rem --debug-log-output <arg> Output log zip file
|
||||
rem --disable-api-has-check-removalDo not optimize out API has checks
|
||||
rem --disable-v2-opcodes Do not use the v2 opcodes
|
||||
rem -e,--package-app Create an application package.
|
||||
rem --Eno-invalid-symbol Do not error when a symbol is found to be
|
||||
rem invalid
|
||||
rem -f,--jungles <arg> Jungle files
|
||||
rem -g,--debug Print debug output
|
||||
rem -h,--help Prints help information
|
||||
rem -i,--import-dbg <arg> Import api.debug.xml
|
||||
rem -k,--profile Enable profiling support
|
||||
rem -l,--typecheck <arg> Type check [0=off, 1=gradual, 2=informative,
|
||||
rem 3=strict]
|
||||
rem -m,--manifest <arg> Manifest file (deprecated)
|
||||
rem --no-gen-styles Do not generate Rez.Styles module
|
||||
rem -o,--output <arg> Output file to create
|
||||
rem -O,--optimization <arg> Optimization level [0=none, 1=basic, 2=fast
|
||||
rem optimizations, 3=slow optimizations]
|
||||
rem [p=optimize performance, z=optimize code
|
||||
rem space]
|
||||
rem -p,--project-info <arg> projectInfo.xml file to use when compiling
|
||||
rem -r,--release Strip debug information
|
||||
rem -t,--unit-test Enables compilation of unit tests
|
||||
rem -u,--devices <arg> devices.xml file to use when compiling
|
||||
rem (deprecated)
|
||||
rem -v,--version Prints the compiler version
|
||||
rem -w,--warn Show compiler warnings
|
||||
rem -x,--excludes <arg> Add annotations to the exclude list
|
||||
rem (deprecated)
|
||||
rem -y,--private-key <arg> Private key to sign builds with
|
||||
rem -z,--rez <arg> Resource files (deprecated)
|
||||
|
||||
title Exporting Garmin Home Assistant Application
|
||||
|
||||
@ -96,7 +100,6 @@ echo.
|
||||
-Dfile.encoding=UTF-8 ^
|
||||
-Dapple.awt.UIElement=true ^
|
||||
-jar %SDK_PATH%\monkeybrains.jar ^
|
||||
--api-level 3.1.0 ^
|
||||
--output %IQ% ^
|
||||
--jungles %SRC%\monkey.jungle ^
|
||||
--private-key %SRC%\..\developer_key ^
|
||||
|
BIN
images/HTTPS_full_chain.png
Normal file
BIN
images/HTTPS_full_chain.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 65 KiB |
BIN
images/HTTPS_partial_chain.png
Normal file
BIN
images/HTTPS_partial_chain.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 72 KiB |
@ -159,6 +159,7 @@
|
||||
<iq:product id="vivoactive4"/>
|
||||
<iq:product id="vivoactive4s"/>
|
||||
<iq:product id="vivoactive5"/>
|
||||
<iq:product id="vivoactive6"/>
|
||||
</iq:products>
|
||||
<!--
|
||||
Use "Monkey C: Edit Permissions" from the Visual Studio Code command
|
||||
|
@ -241,5 +241,7 @@ vivoactive3mlte.resourcePath = $(vivoactive3mlte.resourcePath);resources-launche
|
||||
vivoactive4.resourcePath = $(vivoactive4.resourcePath);resources-launcher-35-35;resources-icons-30
|
||||
# Screen Size 218x218 launcher icon size 30x30
|
||||
vivoactive4s.resourcePath = $(vivoactive4s.resourcePath);resources-launcher-30-30;resources-icons-26
|
||||
# Screen Size 390x390 launcher icon size 70x70
|
||||
vivoactive5.resourcePath = $(vivoactive5.resourcePath);resources-launcher-70-70;resources-icons-46
|
||||
# Screen Size 390x390 launcher icon size 56x56
|
||||
vivoactive5.resourcePath = $(vivoactive5.resourcePath);resources-launcher-56-56;resources-icons-46
|
||||
# Screen Size 390x390 launcher icon size 54x54
|
||||
vivoactive6.resourcePath = $(vivoactive6.resourcePath);resources-launcher-54-54;resources-icons-46
|
||||
|
@ -9,7 +9,7 @@
|
||||
// tested on a Venu 2 device. The source code is provided at:
|
||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||
//
|
||||
// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
|
||||
// P A Abbey & J D Abbey & Someone0nEarth & moesterheld, 31 October 2023
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
|
@ -9,7 +9,7 @@
|
||||
// tested on a Venu 2 device. The source code is provided at:
|
||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||
//
|
||||
// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
|
||||
// P A Abbey & J D Abbey & Someone0nEarth & moesterheld, 31 October 2023
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
@ -212,7 +212,7 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
// asynchronous and affects how the views are managed.
|
||||
(:glance)
|
||||
function fetchMenuConfig() as Lang.Boolean {
|
||||
// System.println("URL = " + Settings.getConfigUrl());
|
||||
// System.println("Menu URL = " + Settings.getConfigUrl());
|
||||
if (Settings.getConfigUrl().equals("")) {
|
||||
mMenuStatus = WatchUi.loadResource($.Rez.Strings.Unconfigured) as Lang.String;
|
||||
WatchUi.requestUpdate();
|
||||
@ -266,7 +266,9 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
private function buildMenu(menu as Lang.Dictionary) {
|
||||
mHaMenu = new HomeAssistantView(menu, null);
|
||||
mQuitTimer.begin();
|
||||
startUpdates();
|
||||
if (!Settings.getWebhookId().equals("")) {
|
||||
startUpdates();
|
||||
} // If not, this will be done via a chain in Settings.webhook() and mWebhookManager.requestWebhookId() that registers the sensors.
|
||||
}
|
||||
|
||||
function startUpdates() {
|
||||
@ -466,6 +468,7 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
|
||||
(:glance)
|
||||
function fetchApiStatus() as Void {
|
||||
// System.println("API URL = " + Settings.getApiUrl());
|
||||
if (Settings.getApiUrl().equals("")) {
|
||||
mApiStatus = WatchUi.loadResource($.Rez.Strings.Unconfigured) as Lang.String;
|
||||
WatchUi.requestUpdate();
|
||||
@ -544,8 +547,8 @@ class HomeAssistantApp extends Application.AppBase {
|
||||
mIsGlance = true;
|
||||
mApiStatus = WatchUi.loadResource($.Rez.Strings.Checking) as Lang.String;
|
||||
mMenuStatus = WatchUi.loadResource($.Rez.Strings.Checking) as Lang.String;
|
||||
updateStatus();
|
||||
Settings.update();
|
||||
updateStatus();
|
||||
mGlanceTimer = new Timer.Timer();
|
||||
mGlanceTimer.start(method(:updateStatus), Globals.scApiBackoff, true);
|
||||
return [new HomeAssistantGlanceView(self)];
|
||||
|
@ -22,8 +22,7 @@
|
||||
using Toybox.Lang;
|
||||
using Toybox.WatchUi;
|
||||
|
||||
class HomeAssistantGroupMenuItem extends WatchUi.IconMenuItem {
|
||||
private var mTemplate as Lang.String or Null;
|
||||
class HomeAssistantGroupMenuItem extends HomeAssistantMenuItem {
|
||||
private var mMenu as HomeAssistantView;
|
||||
|
||||
function initialize(
|
||||
@ -34,48 +33,23 @@ class HomeAssistantGroupMenuItem extends WatchUi.IconMenuItem {
|
||||
:alignment as WatchUi.MenuItem.Alignment
|
||||
} or Null
|
||||
) {
|
||||
if (options != null) {
|
||||
options.put(:icon, icon);
|
||||
} else {
|
||||
options = { :icon => icon };
|
||||
}
|
||||
|
||||
WatchUi.IconMenuItem.initialize(
|
||||
HomeAssistantMenuItem.initialize(
|
||||
definition.get("name") as Lang.String,
|
||||
null,
|
||||
null,
|
||||
icon,
|
||||
template,
|
||||
options
|
||||
);
|
||||
|
||||
mTemplate = template;
|
||||
mMenu = new HomeAssistantView(definition, null);
|
||||
}
|
||||
|
||||
function buildTemplate() as Lang.String or Null {
|
||||
return mTemplate;
|
||||
}
|
||||
|
||||
function updateState(data as Lang.String or Lang.Dictionary or Null) as Void {
|
||||
if (data == null) {
|
||||
setSubLabel(null);
|
||||
} else if(data instanceof Lang.String) {
|
||||
setSubLabel(data);
|
||||
} else if(data instanceof Lang.Dictionary) {
|
||||
// System.println("HomeAsistantGroupMenuItem updateState() data = " + data);
|
||||
if (data.get("error") != null) {
|
||||
setSubLabel($.Rez.Strings.TemplateError);
|
||||
} else {
|
||||
setSubLabel($.Rez.Strings.PotentialError);
|
||||
}
|
||||
} else {
|
||||
// The template must return a Lang.String, a number can be either integer or float and hence cannot be formatted locally without error.
|
||||
setSubLabel(WatchUi.loadResource($.Rez.Strings.TemplateError) as Lang.String);
|
||||
}
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
|
||||
function getMenuView() as HomeAssistantView {
|
||||
return mMenu;
|
||||
}
|
||||
|
||||
function hasTemplate() as Lang.Boolean {
|
||||
return mTemplate != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
79
source/HomeAssistantMenuItem.mc
Normal file
79
source/HomeAssistantMenuItem.mc
Normal file
@ -0,0 +1,79 @@
|
||||
//-----------------------------------------------------------------------------------
|
||||
//
|
||||
// Distributed under MIT Licence
|
||||
// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
|
||||
//
|
||||
//-----------------------------------------------------------------------------------
|
||||
//
|
||||
// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
|
||||
// tested on a Venu 2 device. The source code is provided at:
|
||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||
//
|
||||
// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
//
|
||||
// Generic menu button with an icon that optionally renders a Home Assistant Template.
|
||||
//
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
using Toybox.Lang;
|
||||
using Toybox.WatchUi;
|
||||
using Toybox.Graphics;
|
||||
|
||||
class HomeAssistantMenuItem extends WatchUi.IconMenuItem {
|
||||
private var mTemplate as Lang.String or Null;
|
||||
|
||||
function initialize(
|
||||
label as Lang.String or Lang.Symbol,
|
||||
template as Lang.String,
|
||||
options as {
|
||||
:alignment as WatchUi.MenuItem.Alignment,
|
||||
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol
|
||||
} or Null
|
||||
) {
|
||||
WatchUi.IconMenuItem.initialize(
|
||||
label,
|
||||
null,
|
||||
null,
|
||||
options.get(:icon),
|
||||
options
|
||||
);
|
||||
mTemplate = template;
|
||||
}
|
||||
|
||||
function hasTemplate() as Lang.Boolean {
|
||||
return mTemplate != null;
|
||||
}
|
||||
|
||||
function buildTemplate() as Lang.String or Null {
|
||||
return mTemplate;
|
||||
}
|
||||
|
||||
function updateState(data as Lang.String or Lang.Dictionary or Lang.Number or Lang.Float or Null) as Void {
|
||||
if (data == null) {
|
||||
setSubLabel($.Rez.Strings.Empty);
|
||||
} else if(data instanceof Lang.String) {
|
||||
setSubLabel(data);
|
||||
} else if(data instanceof Lang.Number) {
|
||||
var d = data as Lang.Number;
|
||||
setSubLabel(d.format("%d"));
|
||||
} else if(data instanceof Lang.Float) {
|
||||
var f = data as Lang.Float;
|
||||
setSubLabel(f.format("%f"));
|
||||
} else if(data instanceof Lang.Dictionary) {
|
||||
// System.println("HomeAssistantMenuItem updateState() data = " + data);
|
||||
if (data.get("error") != null) {
|
||||
setSubLabel($.Rez.Strings.TemplateError);
|
||||
} else {
|
||||
setSubLabel($.Rez.Strings.PotentialError);
|
||||
}
|
||||
} else {
|
||||
// The template must return a Lang.String, Number or Float, or the item cannot be formatted locally without error.
|
||||
setSubLabel(WatchUi.loadResource($.Rez.Strings.TemplateError) as Lang.String);
|
||||
}
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,7 @@
|
||||
// tested on a Venu 2 device. The source code is provided at:
|
||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||
//
|
||||
// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
|
||||
// P A Abbey & J D Abbey & Someone0nEarth & moesterheld, 31 October 2023
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
|
@ -9,7 +9,7 @@
|
||||
// tested on a Venu 2 device. The source code is provided at:
|
||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||
//
|
||||
// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
|
||||
// P A Abbey & J D Abbey & Someone0nEarth & moesterheld, 31 October 2023
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
@ -22,9 +22,8 @@ using Toybox.Lang;
|
||||
using Toybox.WatchUi;
|
||||
using Toybox.Graphics;
|
||||
|
||||
class HomeAssistantTapMenuItem extends WatchUi.IconMenuItem {
|
||||
class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
|
||||
private var mHomeAssistantService as HomeAssistantService;
|
||||
private var mTemplate as Lang.String;
|
||||
private var mService as Lang.String or Null;
|
||||
private var mConfirm as Lang.Boolean;
|
||||
private var mPin as Lang.Boolean;
|
||||
@ -39,53 +38,30 @@ class HomeAssistantTapMenuItem extends WatchUi.IconMenuItem {
|
||||
data as Lang.Dictionary or Null,
|
||||
icon as Graphics.BitmapType or WatchUi.Drawable,
|
||||
options as {
|
||||
:alignment as WatchUi.MenuItem.Alignment
|
||||
:alignment as WatchUi.MenuItem.Alignment,
|
||||
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol
|
||||
} or Null,
|
||||
haService as HomeAssistantService
|
||||
) {
|
||||
WatchUi.IconMenuItem.initialize(
|
||||
if (options != null) {
|
||||
options.put(:icon, icon);
|
||||
} else {
|
||||
options = { :icon => icon };
|
||||
}
|
||||
|
||||
HomeAssistantMenuItem.initialize(
|
||||
label,
|
||||
null,
|
||||
null,
|
||||
icon,
|
||||
template,
|
||||
options
|
||||
);
|
||||
|
||||
mHomeAssistantService = haService;
|
||||
mTemplate = template;
|
||||
mService = service;
|
||||
mConfirm = confirm;
|
||||
mPin = pin;
|
||||
mData = data;
|
||||
}
|
||||
|
||||
function hasTemplate() as Lang.Boolean {
|
||||
return mTemplate != null;
|
||||
}
|
||||
|
||||
function buildTemplate() as Lang.String or Null {
|
||||
return mTemplate;
|
||||
}
|
||||
|
||||
function updateState(data as Lang.String or Lang.Dictionary or Null) as Void {
|
||||
if (data == null) {
|
||||
setSubLabel($.Rez.Strings.Empty);
|
||||
} else if(data instanceof Lang.String) {
|
||||
setSubLabel(data);
|
||||
} else if(data instanceof Lang.Dictionary) {
|
||||
// System.println("HomeAsistantTemplateMenuItem updateState() data = " + data);
|
||||
if (data.get("error") != null) {
|
||||
setSubLabel($.Rez.Strings.TemplateError);
|
||||
} else {
|
||||
setSubLabel($.Rez.Strings.PotentialError);
|
||||
}
|
||||
} else {
|
||||
// The template must return a Lang.String, a number can be either integer or float and hence cannot be formatted locally without error.
|
||||
setSubLabel(WatchUi.loadResource($.Rez.Strings.TemplateError) as Lang.String);
|
||||
}
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
|
||||
function callService() as Void {
|
||||
var hasTouchScreen = System.getDeviceSettings().isTouchScreen;
|
||||
if (mPin && hasTouchScreen) {
|
||||
|
@ -9,7 +9,7 @@
|
||||
// tested on a Venu 2 device. The source code is provided at:
|
||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||
//
|
||||
// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
|
||||
// P A Abbey & J D Abbey & Someone0nEarth & moesterheld, 31 October 2023
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
@ -42,7 +42,13 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
||||
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol
|
||||
} or Null
|
||||
) {
|
||||
WatchUi.ToggleMenuItem.initialize(label, null, null, false, options);
|
||||
WatchUi.ToggleMenuItem.initialize(
|
||||
label,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
options
|
||||
);
|
||||
if (Attention has :vibrate) {
|
||||
mHasVibrate = true;
|
||||
}
|
||||
@ -69,24 +75,31 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
||||
return "{{states('" + mData.get("entity_id") + "')}}";
|
||||
}
|
||||
|
||||
function updateState(data as Lang.String or Lang.Dictionary or Null) as Void {
|
||||
function updateState(data as Lang.String or Lang.Dictionary or Lang.Number or Lang.Float or Null) as Void {
|
||||
if (data == null) {
|
||||
setSubLabel(null);
|
||||
} else if(data instanceof Lang.String) {
|
||||
setSubLabel(data);
|
||||
} else if(data instanceof Lang.Number) {
|
||||
var d = data as Lang.Number;
|
||||
setSubLabel(d.format("%d"));
|
||||
} else if(data instanceof Lang.Float) {
|
||||
var f = data as Lang.Float;
|
||||
setSubLabel(f.format("%f"));
|
||||
} else if(data instanceof Lang.Dictionary) {
|
||||
// System.println("HomeAsistantToggleMenuItem updateState() data = " + data);
|
||||
// System.println("HomeAssistantToggleMenuItem updateState() data = " + data);
|
||||
if (data.get("error") != null) {
|
||||
setSubLabel($.Rez.Strings.TemplateError);
|
||||
} else {
|
||||
setSubLabel($.Rez.Strings.PotentialError);
|
||||
}
|
||||
} else {
|
||||
// The template must return a Lang.String, a number can be either integer or float and hence cannot be formatted locally without error.
|
||||
// The template must return a Lang.String, Number or Float, or the item cannot be formatted locally without error.
|
||||
setSubLabel(WatchUi.loadResource($.Rez.Strings.TemplateError) as Lang.String);
|
||||
}
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
|
||||
function updateToggleState(data as Lang.String or Lang.Dictionary or Null) as Void {
|
||||
if (data == null) {
|
||||
setUiToggle("off");
|
||||
@ -96,7 +109,7 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
||||
setSubLabel($.Rez.Strings.Unavailable);
|
||||
}
|
||||
} else if(data instanceof Lang.Dictionary) {
|
||||
// System.println("HomeAsistantToggleMenuItem updateState() data = " + data);
|
||||
// System.println("HomeAssistantToggleMenuItem updateState() data = " + data);
|
||||
if (mTemplate == null) {
|
||||
if (data.get("error") != null) {
|
||||
setSubLabel($.Rez.Strings.TemplateError);
|
||||
|
@ -9,7 +9,7 @@
|
||||
// tested on a Venu 2 device. The source code is provided at:
|
||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||
//
|
||||
// P A Abbey & J D Abbey & Someone0nEarth, 31 October 2023
|
||||
// P A Abbey & J D Abbey & Someone0nEarth & moesterheld, 31 October 2023
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
|
@ -9,7 +9,7 @@
|
||||
// tested on a Venu 2 device. The source code is provided at:
|
||||
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||
//
|
||||
// P A Abbey & J D Abbey, SomeoneOnEarth, 23 November 2023
|
||||
// P A Abbey & J D Abbey, SomeoneOnEarth & moesterheld, 23 November 2023
|
||||
//
|
||||
//
|
||||
// Description:
|
||||
|
@ -7,13 +7,13 @@
|
||||
<link
|
||||
rel="stylesheet"
|
||||
data-name="vs/editor/editor.main"
|
||||
href="https://unpkg.com/monaco-editor@0.45.0/min/vs/editor/editor.main.css" />
|
||||
href="https://www.unpkg.com/monaco-editor@0.45.0/min/vs/editor/editor.main.css" />
|
||||
<link
|
||||
rel="stylesheet"
|
||||
type="text/css"
|
||||
href="https://unpkg.com/toastify-js@1.12.0/src/toastify.css" />
|
||||
href="https://www.unpkg.com/toastify-js@1.12.0/src/toastify.css" />
|
||||
<style>
|
||||
@import url('https://unpkg.com/@catppuccin/palette/css/catppuccin.css');
|
||||
@import url('https://www.unpkg.com/@catppuccin/palette/css/catppuccin.css');
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
@ -441,9 +441,9 @@ http:
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
<script src="https://unpkg.com/monaco-editor@0.45.0/min/vs/loader.js"></script>
|
||||
<script src="https://unpkg.com/json-ast-comments@1.1.1/lib/json.js"></script>
|
||||
<script src="https://unpkg.com/toastify-js@1.12.0/src/toastify.js"></script>
|
||||
<script src="https://www.unpkg.com/monaco-editor@0.45.0/min/vs/loader.js"></script>
|
||||
<script src="https://www.unpkg.com/json-ast-comments@1.1.1/lib/json.js"></script>
|
||||
<script src="https://www.unpkg.com/toastify-js@1.12.0/src/toastify.js"></script>
|
||||
<script type="module" src="./main.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -451,7 +451,7 @@ loadSchema();
|
||||
// require is provided by loader.min.js.
|
||||
require.config({
|
||||
paths: {
|
||||
vs: 'https://unpkg.com/monaco-editor@0.45.0/min/vs',
|
||||
vs: 'https://www.unpkg.com/monaco-editor@0.45.0/min/vs',
|
||||
},
|
||||
});
|
||||
require(['vs/editor/editor.main'], async () => {
|
||||
|
Reference in New Issue
Block a user