diff --git a/BackgroundService.md b/BackgroundService.md
index 5311867..222370d 100644
--- a/BackgroundService.md
+++ b/BackgroundService.md
@@ -1,4 +1,4 @@
-[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
+[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Numeric](examples/Numeric.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
# Background Service
diff --git a/HISTORY.md b/HISTORY.md
index 571d871..f5d7e15 100644
--- a/HISTORY.md
+++ b/HISTORY.md
@@ -1,4 +1,4 @@
-[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
+[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Numeric](examples/Numeric.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
# Version History
@@ -51,3 +51,4 @@
| 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 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.6 | Added numeric menu item type thanks to @thmichel. This allows you to select a numeric value for a tap action. |
diff --git a/HTTP_Headers.md b/HTTP_Headers.md
index 22d07f5..dae717e 100644
--- a/HTTP_Headers.md
+++ b/HTTP_Headers.md
@@ -1,4 +1,4 @@
-[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
+[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Numeric](examples/Numeric.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
# User Specified Custom HTTP Headers
diff --git a/README.md b/README.md
index d7e3b91..2a9a5cb 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
+[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Numeric](examples/Numeric.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
# GarminHomeAssistant
@@ -145,22 +145,21 @@ Example schema:
}
},
{
- "name": "Heating",
- "content": "{{ ' %.1f' | format(state_attr('climate.myheating','temperature')) }}",
- "type": "numeric",
- "entity": "climate.myheating",
- "tap_action": {
- "service": "climate.set_temperature",
- "data": {
- "step": "0.5",
- "start": "10",
- "stop": "30",
- "valueLabel": "temperature",
- "formatString": "%.1f"
- }
- },
- "pin": false
- } ,
+ "name": "Heating",
+ "content": "{{ ' %.1f' | format(state_attr('climate.room','temperature')) }}",
+ "type": "numeric",
+ "entity": "climate.room",
+ "tap_action": {
+ "service": "climate.set_temperature",
+ "picker": {
+ "step": 0.5,
+ "start": 10,
+ "stop": 30,
+ "attribute": "temperature",
+ "data_attribute": "temperature"
+ }
+ }
+ }
]
}
```
@@ -174,25 +173,28 @@ The example above illustrates how to configure:
* Script invocation (`tap`)
* Service invocation, e.g. Scene setting, (`tap`)
* A sub-menu to open (`group`)
-* A numeric item (`numeric`), which allows you to set a numeric value e.g. for heating or a dimmer. ValueLabel defines the variable to return. You can optionally set the minimum (start) and maximum (stop) value as well as the step to increase/decrease and a tepmlate how to format the value.
+* A numeric item (`numeric`), which allows you to set a numeric value e.g. for heating or a dimmer. This is [explained more fully](examples/Numeric.md) in its own examples page.
* You can also display the status of devices (`info`) which is essentially a `tap` with no action
* All menu items can display the results of evaluating [templates](examples/Templates.md).
The following table indicates how HomeAssistant entity types can map to the Garmin applications menu types. Presently, an automation is the only one that can be either a `tap` or a `toggle`.
-| HA Entity Type | Tap | Toggle | Info (status)|
-|------------------|:---:|:------:|:------------:|
-| Switch | ❌ | ✅ | ✅ |
-| Light | ❌ | ✅ | ✅ |
-| Automation | ✅ | ✅ | ❌ |
-| Script | ✅ | ❌ | ❌ |
-| Scene | ✅ | ❌ | ❌ |
-| Sensor | ❌ | ❌ | ✅ |
-| Binary Sensor | ❌ | ❌ | ✅ |
-| Any other entity | ❌ | ❌ | ✅ |
-| Any service | ✅ | ❌ | ❌ |
+| HA Entity Type | Tap | Toggle | Info (status)| Numeric |
+|------------------|:---:|:------:|:------------:|:-------:|
+| Switch | ❌ | ✅ | ✅ | ❌ |
+| Switched Light | ❌ | ✅ | ✅ | ❌ |
+| Dimmer Light | ❌ | ❌ | ✅ | ✅ |
+| Automation | ✅ | ✅ | ❌ | ❌ |
+| Script | ✅ | ❌ | ❌ | ❌ |
+| Scene | ✅ | ❌ | ❌ | ❌ |
+| Sensor | ❌ | ❌ | ✅ | ❌ |
+| Binary Sensor | ❌ | ❌ | ✅ | ❌ |
+| Thermostat | ❌ | ❌ | ✅ | ✅ |
+| Amplifier | ❌ | ❌ | ✅ | ✅ |
+| Any other entity | ❌ | ❌ | ✅ | ❌ |
+| Any service | ✅ | ❌ | ❌ | ❌ |
-Multiple templates are evaluated in a single HTTP request to update their status. Only the toggle items have the on/off
icon. NB. All `tap` items must specify a `service` tag in the `tap_action` object (see example below).
+Multiple templates are evaluated in a single HTTP request to update their status. Only the toggle items have the on/off
icon. NB. All `tap` and `numeric` items must specify a `service` tag in the `tap_action` object (see example below).
You can now specify alternative texts to use instead of "On" and "Off", e.g. "Locked" and "Unlocked" or "Open" and "Closed" through the use of a [template menu item](examples/Templates.md). But wouldn't having locks operated from your watch be a security concern ;-) ?
diff --git a/TroubleShooting.md b/TroubleShooting.md
index d01ee62..b484222 100644
--- a/TroubleShooting.md
+++ b/TroubleShooting.md
@@ -1,4 +1,4 @@
-[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
+[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Numeric](examples/Numeric.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
# Troubleshooting Guides
diff --git a/Wi-Fi.md b/Wi-Fi.md
index dd4ca3a..311363c 100644
--- a/Wi-Fi.md
+++ b/Wi-Fi.md
@@ -1,4 +1,4 @@
-[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
+[Home](README.md) | [Switches](examples/Switches.md) | [Actions](examples/Actions.md) | [Templates](examples/Templates.md) | [Numeric](examples/Numeric.md) | [Glance](examples/Glance.md) | [Background Service](BackgroundService.md) | [Wi-Fi](Wi-Fi.md) | [HTTP Headers](HTTP_Headers.md) | [Trouble Shooting](TroubleShooting.md) | [Version History](HISTORY.md)
# Wi-Fi & LTE
diff --git a/examples/Actions.md b/examples/Actions.md
index 942b264..822d46c 100644
--- a/examples/Actions.md
+++ b/examples/Actions.md
@@ -1,4 +1,4 @@
-[Home](../README.md) | [Switches](Switches.md) | [Actions](Actions.md) | [Templates](Templates.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)
+[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
diff --git a/examples/Glance.md b/examples/Glance.md
index e48e82b..6ea2839 100644
--- a/examples/Glance.md
+++ b/examples/Glance.md
@@ -1,4 +1,4 @@
-[Home](../README.md) | [Switches](Switches.md) | [Actions](Actions.md) | [Templates](Templates.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)
+[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)
# Glance
diff --git a/examples/Numeric.md b/examples/Numeric.md
new file mode 100644
index 0000000..ba16bd9
--- /dev/null
+++ b/examples/Numeric.md
@@ -0,0 +1,139 @@
+[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)
+
+# Numeric
+
+Provides a number picker in order to adjust a numeric value of an entity.
+
+## Thermostat
+
+An example using a thermostat as a `numeric` menu item.
+
+```json
+{
+ "name": "Heating",
+ "content": "{{ ' %.1f' | format(state_attr('climate.room','temperature')) }}",
+ "type": "numeric",
+ "entity": "climate.room",
+ "tap_action": {
+ "service": "climate.set_temperature",
+ "picker": {
+ "step": 0.5,
+ "min": 10,
+ "max": 30,
+ "attribute": "temperature",
+ "data_attribute": "temperature"
+ }
+ }
+}
+```
+
+This needs some explanation. The `tap_action` object needs a `picker` object to specify the numeric menu item's behaviour. The `picker` object is described in the table below.
+
+Field | Purpose | Mandatory |
+-----------------|----------------------------------------------------------------|-----------|
+`step` | The increment or decrement step size. | Yes |
+`min` | The minimum 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 |
+`data_attribute` | The attribute on the `service` 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.
+
+## Helper
+
+You might define a "helper" entity as follows in Home Assistant:
+
+
+
+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.
+
+```json
+{
+ "name": "My Float",
+ "content": "Currently {{ states('input_number.my_float') }}",
+ "type": "numeric",
+ "entity": "input_number.my_float",
+ "tap_action": {
+ "service": "input_number.set_value",
+ "picker": {
+ "step": 0.5,
+ "min": -10.0,
+ "max": 10.0,
+ "data_attribute": "value"
+ }
+ }
+}
+```
+
+## Amplifier
+
+The complication here is this amplifier uses one scale for changing the value, a range 0.0 to 1.0, and another to render the volume on the display, dB. So the template does some scale conversion, but the number picker has to use the 0.0 to 1.0 range which is annoying.
+
+```json
+{
+ "name": "Amplifer Volume",
+ "content": "{{ '%.1f' | format(state_attr('media_player.amplifier','volume_level') * 100 -80) }} dB ({{ state_attr('media_player.amplifier','volume_level') }})",
+ "type": "numeric",
+ "entity": "media_player.amplifier",
+ "tap_action": {
+ "service": "media_player.volume_set",
+ "picker": {
+ "step": 0.005,
+ "min": 0.2,
+ "max": 0.6,
+ "attribute": "volume_level",
+ "data_attribute": "volume_level"
+ }
+ }
+}
+```
+
+The above is a little awkward to change the volume as the picker's scale is unfamiliar. To make life easier you might choose to implement a "Template number" in Home Assistant as defined in the following dialogue box.
+
+
+
+For copy and paste, the Jinja2 fields are as follows:
+
+1. Template rendering with conversion to dB:
+
+```
+{{ state_attr('media_player.amplifier','volume_level') * 100 -80 }}
+```
+
+2. Conversion from dB to range 0.0 to 1.0:
+
+```
+{{ (value+80)/100 }}
+```
+
+3. Availability template:
+
+```
+{{ not is_state('media_player.amplifier','unavailable') }}
+```
+
+The JSON menu definition can now use dB with the new template number as follows.
+
+```json
+{
+ "name": "Amplifier Volume",
+ "content": "{% if is_state('media_player.amplifier','unavailable') %}Off{% else %}{{ '%.1f' | format(states('number.amplifier_db') | float) }} dB{% endif %}",
+ "type": "numeric",
+ "entity": "number.amplifier_db",
+ "tap_action": {
+ "service": "number.set_value",
+ "picker": {
+ "step": 0.5,
+ "min": -60.0,
+ "max": -15.0,
+ "data_attribute": "value"
+ }
+ }
+},
+```
+
+## Trouble Shooting
+
+Specific to this menu item:
+
+1. If the number picker does not initialise with the correct value, amend the `attribute` field. Just because your template renders does not mean the application has extracted the numeric valueas the `content` template is rendered on the Home Assistant server.
diff --git a/examples/Switches.md b/examples/Switches.md
index c5834d4..3f9bc23 100644
--- a/examples/Switches.md
+++ b/examples/Switches.md
@@ -1,4 +1,4 @@
-[Home](../README.md) | [Switches](Switches.md) | [Actions](Actions.md) | [Templates](Templates.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)
+[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)
# Switches
diff --git a/examples/Templates.md b/examples/Templates.md
index 92132e0..bc18205 100644
--- a/examples/Templates.md
+++ b/examples/Templates.md
@@ -1,4 +1,4 @@
-[Home](../README.md) | [Switches](Switches.md) | [Actions](Actions.md) | [Templates](Templates.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)
+[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)
# Templates
diff --git a/images/my_float.png b/images/my_float.png
new file mode 100644
index 0000000..8411668
Binary files /dev/null and b/images/my_float.png differ
diff --git a/images/template_number.png b/images/template_number.png
new file mode 100644
index 0000000..335f265
Binary files /dev/null and b/images/template_number.png differ
diff --git a/source/BackgroundServiceDelegate.mc b/source/BackgroundServiceDelegate.mc
index feaa4d4..bbd5005 100644
--- a/source/BackgroundServiceDelegate.mc
+++ b/source/BackgroundServiceDelegate.mc
@@ -133,20 +133,20 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
var data = { "gps_accuracy" => accuracy };
// Only add the non-null fields as all the values are optional in Home Assistant, and it avoid submitting fake values.
if (position.position != null) {
- data.put("gps", position.position.toDegrees());
+ data["gps"] = position.position.toDegrees();
}
if (position.speed != null) {
- data.put("speed", Math.round(position.speed));
+ data["speed"] = Math.round(position.speed);
}
if (position.heading != null) {
var heading = Math.round(position.heading * 180 / Math.PI);
while (heading < 0) {
heading += 360;
}
- data.put("course", heading);
+ data["course"] = heading;
}
if (position.altitude != null) {
- data.put("altitude", Math.round(position.altitude));
+ data["altitude"] = Math.round(position.altitude);
}
// System.println("BackgroundServiceDelegate onTemporalEvent(): data = " + data.toString());
diff --git a/source/HomeAssistantApp.mc b/source/HomeAssistantApp.mc
index 87fa8a9..4fd0318 100644
--- a/source/HomeAssistantApp.mc
+++ b/source/HomeAssistantApp.mc
@@ -720,19 +720,13 @@ class HomeAssistantApp extends Application.AppBase {
var item = mItemsToUpdate[i];
var template = item.getTemplate();
if (template != null) {
- mTemplates.put(i.toString(), {
- "template" => template
- });
+ mTemplates[i.toString()] = { "template" => template };
}
if (item instanceof HomeAssistantToggleMenuItem) {
- mTemplates.put(i.toString() + "t", {
- "template" => (item as HomeAssistantToggleMenuItem).getToggleTemplate()
- });
+ mTemplates[i.toString() + "t"] = { "template" => (item as HomeAssistantToggleMenuItem).getToggleTemplate() };
}
if (item instanceof HomeAssistantNumericMenuItem) {
- mTemplates.put(i.toString() + "n", {
- "template" => (item as HomeAssistantNumericMenuItem).getNumericTemplate()
- });
+ mTemplates[i.toString() + "n"] = { "template" => (item as HomeAssistantNumericMenuItem).getNumericTemplate() };
}
}
}
diff --git a/source/HomeAssistantGroupMenuItem.mc b/source/HomeAssistantGroupMenuItem.mc
index 4b0f20c..c5aa5e1 100644
--- a/source/HomeAssistantGroupMenuItem.mc
+++ b/source/HomeAssistantGroupMenuItem.mc
@@ -33,7 +33,7 @@ class HomeAssistantGroupMenuItem extends HomeAssistantMenuItem {
}?
) {
if (options != null) {
- options.put(:icon, icon);
+ options[:icon] = icon;
} else {
options = { :icon => icon };
}
diff --git a/source/HomeAssistantMenuItemFactory.mc b/source/HomeAssistantMenuItemFactory.mc
index a64b69d..ad77594 100644
--- a/source/HomeAssistantMenuItemFactory.mc
+++ b/source/HomeAssistantMenuItemFactory.mc
@@ -31,9 +31,7 @@ class HomeAssistantMenuItemFactory {
//! Class Constructor
//
private function initialize() {
- mMenuItemOptions = {
- :alignment => Settings.getMenuAlignment()
- };
+ mMenuItemOptions = { :alignment => Settings.getMenuAlignment() };
mTapTypeIcon = new WatchUi.Bitmap({
:rezId => $.Rez.Drawables.TapTypeIcon,
@@ -84,7 +82,7 @@ class HomeAssistantMenuItemFactory {
) as WatchUi.MenuItem {
var keys = mMenuItemOptions.keys();
for (var i = 0; i < keys.size(); i++) {
- options.put(keys[i], mMenuItemOptions.get(keys[i]));
+ options[keys[i]] = mMenuItemOptions.get(keys[i]);
}
return new HomeAssistantToggleMenuItem(
label,
@@ -119,15 +117,15 @@ class HomeAssistantMenuItemFactory {
if (data == null) {
data = { "entity_id" => entity_id };
} else {
- data.put("entity_id", entity_id);
+ data["entity_id"] = entity_id;
}
}
var keys = mMenuItemOptions.keys();
for (var i = 0; i < keys.size(); i++) {
- options.put(keys[i], mMenuItemOptions.get(keys[i]));
+ options[keys[i]] = mMenuItemOptions.get(keys[i]);
}
if (service != null) {
- options.put(:icon, mTapTypeIcon);
+ options[:icon] = mTapTypeIcon;
return new HomeAssistantTapMenuItem(
label,
template,
@@ -137,7 +135,7 @@ class HomeAssistantMenuItemFactory {
mHomeAssistantService
);
} else {
- options.put(:icon, mInfoTypeIcon);
+ options[:icon] = mInfoTypeIcon;
return new HomeAssistantTapMenuItem(
label,
template,
@@ -172,9 +170,9 @@ class HomeAssistantMenuItemFactory {
}
var keys = mMenuItemOptions.keys();
for (var i = 0; i < keys.size(); i++) {
- options.put(keys[i], mMenuItemOptions.get(keys[i]));
+ options[keys[i]] = mMenuItemOptions.get(keys[i]);
}
- options.put(:icon, mTapTypeIcon);
+ options[:icon] = mTapTypeIcon;
return new HomeAssistantNumericMenuItem(
label,
template,
diff --git a/source/HomeAssistantView.mc b/source/HomeAssistantView.mc
index c5d7814..08b4141 100644
--- a/source/HomeAssistantView.mc
+++ b/source/HomeAssistantView.mc
@@ -35,7 +35,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
if (options == null) {
options = { :title => definition.get("title") as Lang.String };
} else {
- options.put(:title, definition.get("title") as Lang.String);
+ options[:title] = definition.get("title") as Lang.String;
}
WatchUi.Menu2.initialize(options);