Compare commits

..

6 Commits

Author SHA1 Message Date
Joseph Abbey
75045b19d9 Fix for numeric menu items over Wi-Fi/LTE (#318)
Turns out the sync service will not run unless the picker has not only
been popped but the display also updated.

v3.7 needs a swift turnaround as its a bug reported by a user.
2025-11-07 23:23:42 +00:00
Philip Abbey
d6e32b777f Update HISTORY.md
Added v3.7 text.
2025-11-07 09:10:47 +00:00
Philip Abbey
1e17d93310 Fix for numeric menu items over Wi-Fi/LTE
Turns out the sync service will not run unless the picker has not only been popped but the display also updated.
2025-11-07 09:05:22 +00:00
Philip Abbey
cc53b25508 Update HomeAssistantTapMenuItem.mc
Code tidy only.
2025-11-07 09:03:05 +00:00
Philip Abbey
098dc81236 Space alignment in code (tidy) and v3.6 history amendment 2025-11-06 20:40:43 +00:00
Philip Abbey
5ab8229602 Update Numeric.md
Changed 'service' to 'action'. Careless omission for new documentation.

Signed-off-by: Philip Abbey <philipabbey@users.noreply.github.com>
2025-11-06 18:15:09 +00:00
7 changed files with 51 additions and 51 deletions

View File

@@ -51,4 +51,5 @@
| 3.3 | Providing automatic detection for menu definition updates, but still requires an application restart. | | 3.3 | Providing automatic detection for menu definition updates, but still requires an application restart. |
| 3.4 | Fixed a bug where templates failed to display in toggle menu items (at least on some devices). Fixed a bug where a menu item requesting to exit on completion appeared to indicate failure when using Wi-Fi or LTE. The fix uses a delay in exiting the application modelled as sufficient for a Venu 2 device, so this might need tweaking for other devices. Attempt to fixed an "Out of Memory" bug caused by v3.3 by making automatic checking for menu updates both optional and automatically turned off when insufficient memory is available. This last bug is device dependent and may require another attempt. Internationalisation improvements with thanks to [@krzys_h](https://github.com/krzys-h) for a new automated translations script. | | 3.4 | Fixed a bug where templates failed to display in toggle menu items (at least on some devices). Fixed a bug where a menu item requesting to exit on completion appeared to indicate failure when using Wi-Fi or LTE. The fix uses a delay in exiting the application modelled as sufficient for a Venu 2 device, so this might need tweaking for other devices. Attempt to fixed an "Out of Memory" bug caused by v3.3 by making automatic checking for menu updates both optional and automatically turned off when insufficient memory is available. This last bug is device dependent and may require another attempt. Internationalisation improvements with thanks to [@krzys_h](https://github.com/krzys-h) for a new automated translations script. |
| 3.5 | Added support for Edge 550, 850 & MTB, Fenix 8 Pro 47mm, GPSMAP H1, Instinct Crossover AMOLED, Venu 4 41mm & 45mm, & Venu X1 devices which also required an SDK update to 8.3.0. The simulation of the Edge 850 device was off, as it failed to update the display and text was the wrong colour, but the buttons menu items operated HA correctly. The assumption is the simulation model is buggy until someone [reports](https://github.com/house-of-abbey/GarminHomeAssistant/issues) otherwise. | | 3.5 | Added support for Edge 550, 850 & MTB, Fenix 8 Pro 47mm, GPSMAP H1, Instinct Crossover AMOLED, Venu 4 41mm & 45mm, & Venu X1 devices which also required an SDK update to 8.3.0. The simulation of the Edge 850 device was off, as it failed to update the display and text was the wrong colour, but the buttons menu items operated HA correctly. The assumption is the simulation model is buggy until someone [reports](https://github.com/house-of-abbey/GarminHomeAssistant/issues) otherwise. |
| 3.6 | Added `numeric` menu item type thanks to [@thmichel](https://github.com/thmichel). This allows you to select a numeric value to set for an entity. Confirmations can now display a user supplied message. [Schema update](README.md#old-deprecated-formats) to keep pace with HomeAssistant and correct a previous decision. | | 3.6 | Added `numeric` menu item type thanks to [@thmichel](https://github.com/thmichel). This allows you to select a numeric value to set for an entity. Confirmations can now display a user supplied message. [Schema update](README.md#old-deprecated-formats) to keep pace with HomeAssistant and correct a previous decision. Schema changes for consistency. |
| 3.7 | Bug fix for `numeric` menu items not working over Wi-Fi & LTE. |

View File

@@ -15,7 +15,7 @@ An example using a thermostat as a `numeric` menu item.
"type": "numeric", "type": "numeric",
"entity": "climate.room", "entity": "climate.room",
"tap_action": { "tap_action": {
"service": "climate.set_temperature", "action": "climate.set_temperature",
"picker": { "picker": {
"step": 0.5, "step": 0.5,
"min": 10, "min": 10,
@@ -35,7 +35,7 @@ Field | Purpose
`min` | The minimum value the numeric entity can take. | Yes | `min` | The minimum value the numeric entity can take. | Yes |
`max` | The maximum value the numeric entity can take. | Yes | `max` | The maximum value the numeric entity can take. | Yes |
`attribute` | The attribute on the `entity` that holds the state to be read. | No | `attribute` | The attribute on the `entity` that holds the state to be read. | No |
`data_attribute` | The attribute on the `service` call that sets the state. | Yes | `data_attribute` | The attribute on the `action` call that sets the state. | Yes |
It may well be the case that often `attribute` and `data_attribute` are the same attribute, as with this example. It may well be the case that often `attribute` and `data_attribute` are the same attribute, as with this example.
@@ -45,7 +45,7 @@ You might define a "helper" entity as follows in HomeAssistant:
<img src="../images/my_float.png" width="400" title="HomeAssistant Helper definition for an 'input_number'." style="margin:5px"/> <img src="../images/my_float.png" width="400" title="HomeAssistant Helper definition for an 'input_number'." style="margin:5px"/>
In this case, the state is the actual value, so the template uses `states(..)` instead of `state_attr(..)`, you must not set the optional `attribute` value in the JSON definition so that the application uses the correct template internally for querying the HA server for its present value. Your own template definition in the `content` field will need to follow suit too. The `data_attribute` must be set to `value` for the service call that sets the chosen value from the number carousel. In this case, the state is the actual value, so the template uses `states(..)` instead of `state_attr(..)`, you must not set the optional `attribute` value in the JSON definition so that the application uses the correct template internally for querying the HA server for its present value. Your own template definition in the `content` field will need to follow suit too. The `data_attribute` must be set to `value` for the `action` call that sets the chosen value from the number carousel.
```json ```json
{ {
@@ -54,7 +54,7 @@ In this case, the state is the actual value, so the template uses `states(..)` i
"type": "numeric", "type": "numeric",
"entity": "input_number.my_float", "entity": "input_number.my_float",
"tap_action": { "tap_action": {
"service": "input_number.set_value", "action": "input_number.set_value",
"picker": { "picker": {
"step": 0.5, "step": 0.5,
"min": -10.0, "min": -10.0,
@@ -76,7 +76,7 @@ The complication here is this amplifier uses one scale for changing the value, a
"type": "numeric", "type": "numeric",
"entity": "media_player.amplifier", "entity": "media_player.amplifier",
"tap_action": { "tap_action": {
"service": "media_player.volume_set", "action": "media_player.volume_set",
"picker": { "picker": {
"step": 0.005, "step": 0.005,
"min": 0.2, "min": 0.2,
@@ -149,7 +149,7 @@ The JSON menu definition can now use dB with the new template number as follows.
"type": "numeric", "type": "numeric",
"entity": "number.amplifier_db", "entity": "number.amplifier_db",
"tap_action": { "tap_action": {
"service": "number.set_value", "action": "number.set_value",
"picker": { "picker": {
"step": 0.5, "step": 0.5,
"min": -60.0, "min": -60.0,

View File

@@ -154,18 +154,16 @@ class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
//! @param b Ignored. It is included in order to match the expected function prototype of the callback method. //! @param b Ignored. It is included in order to match the expected function prototype of the callback method.
// //
function onConfirm(b as Lang.Boolean) as Void { function onConfirm(b as Lang.Boolean) as Void {
var dataAttribute = mPicker["data_attribute"]; var dataAttribute = mPicker["data_attribute"] as Lang.String?;
if (dataAttribute == null) { var entity_id = mData["entity_id"] as Lang.String?;
//return without call action if no data attribute is set to avoid crash
WatchUi.popView(WatchUi.SLIDE_RIGHT);
return;
}
var entity_id = mData["entity_id"];
if (entity_id == null) {
//return without call action if no entity_id is set to avoid crash
WatchUi.popView(WatchUi.SLIDE_RIGHT); WatchUi.popView(WatchUi.SLIDE_RIGHT);
WatchUi.requestUpdate();
if (dataAttribute == null or entity_id == null) {
// Return without service call if no data attribute or entity ID is set to avoid crash.
return; return;
} }
if (mAction != null) {
mHomeAssistantService.call( mHomeAssistantService.call(
mAction, mAction,
{ {
@@ -174,7 +172,7 @@ class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
}, },
mExit mExit
); );
WatchUi.popView(WatchUi.SLIDE_RIGHT); }
} }
//! Return a numeric menu item's fetch state template. //! Return a numeric menu item's fetch state template.
@@ -182,8 +180,9 @@ class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
//! @return A string with the menu item's template definition (or null). //! @return A string with the menu item's template definition (or null).
// //
function getNumericTemplate() as Lang.String? { function getNumericTemplate() as Lang.String? {
var entity_id = mData["entity_id"]; var entity_id = mData["entity_id"] as Lang.String?;
var attribute = mPicker["attribute"] as Lang.String?; var attribute = mPicker["attribute"] as Lang.String?;
if (entity_id == null) { if (entity_id == null) {
return null; return null;
} else { } else {