Compare commits

...

5 Commits

Author SHA1 Message Date
Philip Abbey
e9bce71748 Refactor HomeAssistantNumericPicker for improved value parsing (#345)
ref
https://github.com/house-of-abbey/GarminHomeAssistant/issues/238#issuecomment-3941469731

fix numberpicker issue
refactored with Amazon Q
tested on Vivoactive 5 (simulator and device)
tested on Venu2 (simulator only)
2026-03-01 08:24:58 +00:00
poaudet
adc04ea9a2 Refactor HomeAssistantNumericPicker to improve value parsing and initialization 2026-02-28 16:50:28 -05:00
poaudet
7daa07f52f first commit 2026-02-28 14:15:09 -05:00
Philip Abbey
6596b5fa5d Markdown documentation linting 2026-02-28 18:01:50 +00:00
Philip Abbey
188fb8feff Update Actions.md
Additional example and amended example.
2026-02-06 10:15:39 +00:00
7 changed files with 35 additions and 22 deletions

1
.gitignore vendored
View File

@@ -7,3 +7,4 @@ Thumbs.db
source/ClientId.mc
# Gemini API key for automated translations
gemini_api_key.txt
developer_key

View File

@@ -22,7 +22,7 @@ Thank you to all those who have provided positive feedback, code and language tr
> [!IMPORTANT]
> **The intended audience for this application are those comfortable with configuring a HomeAssistant** (e.g. editing the YAML configuration files) and debugging why URLs don't work. It does not require programming skills, but the menu is configured via JSON which feels like "coding" (more like "describing"). If you are not comfortable with this relatively low level of configuration, you may like to try other Garmin applications instead.
>
> [!IMPORTANT]
> Remember, you are expecting to define a customised menu making use of several options using your Home Assistant's custom entities on a small (portable) device. **There is no "_simple_" way to configure the menu with the ever increasing options demanded by the user community.** Was your Home Assistant trivial to setup? No!
>
@@ -392,9 +392,8 @@ Two words. Perhaps too lazy to consider why others gave rave reviews and ponder
<img src="images/etiquette/2026-01-21 GHA_Bad_Review.png" width="70%" title="Two words">
<hr>
---
Blaming the wrong application. Just rude. Please get your facts straight. And it was such a simple workaround for the Garmin Connect IQ app bug.
<img src="images/etiquette/2025-11-19%20GHA_Bad_Review.png" width="85%" title="Misplaced blame">
s

View File

@@ -11,6 +11,7 @@ The application is designed around a simple scrollable menu where menu items hav
**The intended audience for this application are those comfortable with configuring a HomeAssistant** (e.g. editing the YAML configuration files) and debugging why URLs don't work. It does not require programming skills, but the menu is configured via JSON which feels like "coding" (more like "describing"). If you are not comfortable with this relatively low level of configuration, you may like to try other Garmin applications instead.
**If you are struggling with getting the application to work, please consult the [troubleshooting guide](TroubleShooting.md) first.** Please also be aware of the [etiquette](Etiquette.md) the developers expect before:
1. Reaching out for help, in short read the instructions.
2. Reviewing the application publicly, in short be sure of your claims.
@@ -62,6 +63,7 @@ The following table lists the differences in functionality between the two. The
> Remember, you are expecting to define a customised menu making use of several options using your Home Assistant's custom entities on a small (portable) device. **There is no "_simple_" way to configure the menu with the ever increasing options demanded by the user community.** Was your Home Assistant trivial to setup? No!
>
> Therefore as developers we have two options:
>
> 1. Assistance via menu driven configuration with nested menus on a small screen whose implementation would expand the code beyond the capacity of smaller devices, or
> 2. As we have opted here, for assistance via some external configuration that is driven by code and can be authored using a more fully functional desktop or laptop PC.
>
@@ -314,6 +316,7 @@ A future move to v3.x will remove support for all deprecated JSON elements to si
## Editing the JSON file
You have options. The first is what we use.
1. **Best!** Use the GarminHomeAssistant [Web-based Editor](https://house-of-abbey.github.io/GarminHomeAssistant/web/) which includes `entity` and `action` name completion and validation by fetching data from your own HomeAssistant instance. _Pretty nifty eh?_ The other method listed below do not add this convenience and checking. NB. This has been tested in Microsoft Edge, Chrome and Firefox.
2. Use the [Studio Code Server](https://community.home-assistant.io/t/home-assistant-community-add-on-visual-studio-code/107863) addon for HomeAssistant. You can then edit your JSON file in place.
3. Locally installed VSCode, or if not installed, try
@@ -369,6 +372,7 @@ You may choose to cache your menu definition on your device in order to reduce t
**Summary:** The two cache options are therefore distinct, the **first is a manual** forced refresh (the old way). The menu is refreshed on start up and no restart is required. The **second enables automatic checking** after starting and after presenting a usable menu with no extra delay but then any detected changes require a restart.
Whilst it would be a smoother experience, there are no plans to make the menu definition update dynamically recreate the rendered menu items without a restart because:
1. Re-rendering the menu could change the selected item just as you action it.
2. V3.3 proved that older devices are now reaching their memory limits. If you have an old device with limited memory to spare you will probably find the App disables the automatic method for you. If your device crashes with this option turned on, best turn it off manually and let me know via a [Github issue](https://github.com/house-of-abbey/GarminHomeAssistant/issues). This will allow us to fine tune the conditions for insufficient memory. We will then ask you to perform a [small task to retrieve the debug information](https://developer.garmin.com/connect-iq/core-topics/debugging/) we need about memory usage.
3. Restarting is simple for the user and simpler for the code.

View File

@@ -18,7 +18,7 @@ With version 3.0 onwards the application now includes the ability to temporarily
5. On some Garmin devices, the HTTPS handshake is performed using **TLS 1.2**. If your server or proxy enforces a higher minimum (e.g., TLS 1.3), you will encounter an SSL handshake error with the message:
```
```text
HTTP request returned error code = 0
```

View File

@@ -1,9 +1,8 @@
[Home](../README.md) | [Switches](Switches.md) | [Actions](Actions.md) | [Templates](Templates.md) | [Numeric](Numeric.md) | [Glance](Glance.md) | [Background Service](../BackgroundService.md) | [Wi-Fi](../Wi-Fi.md) | [HTTP Headers](../HTTP_Headers.md) | [Trouble Shooting](../TroubleShooting.md) | [Version History](../HISTORY.md)
# Actions
A simple example using a scene as a `tap` menu item.
Two simple examples using a scene and a cover as `tap` menu items.
```json
{
@@ -14,6 +13,16 @@ A simple example using a scene as a `tap` menu item.
"action": "scene.turn_on"
}
},
{
"entity":"cover.patio_shutter",
"name":"Patio Door Shutter",
"type":"tap",
"content":"{{state_translated('cover.patio_shutter')}} - {{state_attr('cover.patio_shutter', 'current_position')}}",
"tap_action":{
"action":"cover.toggle",
"confirm":true
}
}
```
Any menu item with an action (`tap`, `template`, or `toggle`), may have a confirmation view added. For consistency this is always done via the `tap_action` JSON object, even though for a `toggle` menu item there will only ever be a single field inside. For the `toggle` menu item, the confirmation is presented on both `on` and `off` directions. There is no option for asymmetry, i.e. only in one direction.
@@ -30,15 +39,15 @@ For example:
```json
{
"entity": "switch.garage_door",
"name": "Garage Door",
"entity": "switch.flood_lights",
"name": "Flood Lights",
"type": "toggle",
"tap_action": {
"confirm": true
}
}
```
The `confirm` field may contain a string instead of a Boolean in order to provide a custom message to display instead of the default "Sure?" text.
```json

View File

@@ -4,7 +4,6 @@
Since [version 2.30](../History.md), it is possible to ovverride the text displayed on the Glance view. This page explains how to customise the text.
## Default View
The default view has always been to display the status of the menu and API availability to indicate if there's a problem. This view has now been updated to be more colourful.
@@ -13,7 +12,6 @@ The default view has always been to display the status of the menu and API avail
When either the API or the menu file is inaccessible, the fields will turn red.
## Customised View
In order to customise the Glance view you need to add a `glance` field to the top level of the JSON menu file as illustrated here:
@@ -68,7 +66,6 @@ It is possible to revert to the default glance content without deleting the temp
So the glance view object has a `type` field with two possible values: `info` and `status`. When the type is `status` the `content` field is not required.
## Displayed Errors
The following shows the default glance when the menu file is not available at the specified URL.

View File

@@ -32,15 +32,18 @@ class HomeAssistantNumericPicker extends WatchUi.Picker {
) {
mItem = haItem;
var picker = mItem.getPicker();
var min = (picker.get("min") as Lang.String).toFloat();
var step = (picker.get("step") as Lang.String).toFloat();
var minStr = picker.get("min");
var stepStr = picker.get("step");
var val = haItem.getValue();
if (min == null) {
min = 0.0;
var min = 0.0;
var step = 1.0;
if (minStr != null) {
min = (minStr as Lang.String).toFloat();
}
if (step == null) {
step = 1.0;
if (stepStr != null) {
step = (stepStr as Lang.String).toFloat();
}
WatchUi.Picker.initialize({