mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-11-21 08:08:14 +00:00
Compare commits
11 Commits
f64bed5058
...
f9253e8cf0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f9253e8cf0 | ||
|
|
3528080ec3 | ||
|
|
cc321899f4 | ||
|
|
5a44765ac9 | ||
|
|
9eb791c68b | ||
|
|
2fca0ef3a3 | ||
|
|
fc0320aef6 | ||
|
|
0d3c76ef2e | ||
|
|
4c946d584a | ||
|
|
6e3cf73ab3 | ||
|
|
14186b7992 |
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -49,5 +49,6 @@
|
||||
| 3.1 | Added the ability for users to provide [custom HTTP headers](HTTP_Headers.md) for their HomeAssistant server. Improved German language translations. Thanks to [@tispokes](https://github.com/tispokes) for assisting with both of those. Removed all groups in settings as the SDK is buggy. Fixed a bug with templates in glances causing application crash on startup. |
|
||||
| 3.2 | Only enable or disable sensors on HomeAssistant when the background service options is changed, i.e. do not call the API to enable on start up every time. |
|
||||
| 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.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.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. |
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
63
README.md
63
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 <img src="images/toggle_icon.png" height="20"> 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 <img src="images/toggle_icon.png" height="20"> 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 ;-) ?
|
||||
|
||||
@@ -231,6 +233,7 @@ This allows the `confirm` and `pin` fields to be accommodated in the `tap_action
|
||||
* [Switches](examples/Switches.md)
|
||||
* [Actions](examples/Actions.md)
|
||||
* [Templates](examples/Templates.md)
|
||||
* [Numeric](examples/Numeric.md)
|
||||
|
||||
## Editing the JSON file
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
2
Wi-Fi.md
2
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
|
||||
|
||||
|
||||
@@ -275,7 +275,51 @@
|
||||
"$ref": "#/$defs/content"
|
||||
},
|
||||
"tap_action": {
|
||||
"$ref": "#/$defs/tap_action"
|
||||
"$ref": "#/$defs/tap_action",
|
||||
"properties": {
|
||||
"service": {
|
||||
"$ref": "#/$defs/service"
|
||||
},
|
||||
"picker": {
|
||||
"type": "object",
|
||||
"title": "Number picker configuration",
|
||||
"description": "'attribute' field is optional.",
|
||||
"properties": {
|
||||
"min": {
|
||||
"type": "number",
|
||||
"title": "Minimum Value"
|
||||
},
|
||||
"max": {
|
||||
"type": "number",
|
||||
"title": "Maximum Value"
|
||||
},
|
||||
"step": {
|
||||
"type": "number",
|
||||
"title": "Step Size"
|
||||
},
|
||||
"attribute": {
|
||||
"type": "string",
|
||||
"title": "Attribute on the entity",
|
||||
"description": "Attribute on the entity with the current numeric value. To use the state of the entity, do not specify."
|
||||
},
|
||||
"data_attribute": {
|
||||
"type": "string",
|
||||
"title": "Attribute on the service data",
|
||||
"description": "Attribute on the service data for the value to set."
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"min",
|
||||
"max",
|
||||
"step",
|
||||
"data_attribute"
|
||||
]
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"service",
|
||||
"picker"
|
||||
]
|
||||
},
|
||||
"enabled": {
|
||||
"$ref": "#/$defs/enabled"
|
||||
@@ -290,7 +334,8 @@
|
||||
"required": [
|
||||
"name",
|
||||
"type",
|
||||
"entity"
|
||||
"entity",
|
||||
"tap_action"
|
||||
],
|
||||
"additionalProperties": false
|
||||
},
|
||||
@@ -309,21 +354,29 @@
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "brightness"
|
||||
},
|
||||
"service": {
|
||||
"const": "light.turn_on"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "brightness"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 255,
|
||||
"description": "Lights are not a percentage."
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"service": {
|
||||
"const": "light.turn_on"
|
||||
},
|
||||
"picker": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "brightness"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "brightness"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 255,
|
||||
"description": "Lights are not a percentage."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -337,20 +390,25 @@
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "value"
|
||||
},
|
||||
"service": {
|
||||
"const": "input_number.set_value"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "value"
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"service": {
|
||||
"const": "input_number.set_value"
|
||||
},
|
||||
"picker": {
|
||||
"properties": {
|
||||
"data_attribute": {
|
||||
"const": "value"
|
||||
}
|
||||
},
|
||||
"not": {
|
||||
"required": [
|
||||
"attribute"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"not": {
|
||||
"required": [
|
||||
"attribute"
|
||||
]
|
||||
}
|
||||
},
|
||||
"else": {
|
||||
@@ -363,20 +421,25 @@
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "value"
|
||||
},
|
||||
"service": {
|
||||
"const": "number.set_value"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "value"
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"service": {
|
||||
"const": "number.set_value"
|
||||
},
|
||||
"picker": {
|
||||
"properties": {
|
||||
"data_attribute": {
|
||||
"const": "value"
|
||||
}
|
||||
},
|
||||
"not": {
|
||||
"required": [
|
||||
"attribute"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"not": {
|
||||
"required": [
|
||||
"attribute"
|
||||
]
|
||||
}
|
||||
},
|
||||
"else": {
|
||||
@@ -389,20 +452,28 @@
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "percentage"
|
||||
},
|
||||
"service": {
|
||||
"const": "fan.set_percentage"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "percentage"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 100
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"service": {
|
||||
"const": "fan.set_percentage"
|
||||
},
|
||||
"picker": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "percentage"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "percentage"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -416,20 +487,28 @@
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "position"
|
||||
},
|
||||
"service": {
|
||||
"const": "valve.set_valve_position"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "position"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 100
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"service": {
|
||||
"const": "valve.set_valve_position"
|
||||
},
|
||||
"picker": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "position"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "position"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -442,48 +521,122 @@
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "position"
|
||||
"allOf": [
|
||||
{
|
||||
"properties": {
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"service": {
|
||||
"enum": [
|
||||
"cover.set_position",
|
||||
"cover.set_tilt_position"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"service": {
|
||||
"const": "cover.set_position"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "position"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 100
|
||||
{
|
||||
"if": {
|
||||
"properties": {
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"service": {
|
||||
"const": "cover.set_tilt_position"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"service": {
|
||||
"const": "cover.set_tilt_position"
|
||||
},
|
||||
"picker": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "tilt_position"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "tilt_position"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": {
|
||||
"properties": {
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"service": {
|
||||
"const": "cover.set_position"
|
||||
},
|
||||
"picker": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "position"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "position"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 100
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"else": {
|
||||
"if": {
|
||||
"properties": {
|
||||
"entity": {
|
||||
"pattern": "^cover\\.[^.]+$"
|
||||
"pattern": "^media_player\\.[^.]+$"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "tilt_position"
|
||||
},
|
||||
"service": {
|
||||
"const": "cover.set_tilt_position"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "tilt_position"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 100
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"service": {
|
||||
"const": "media_player.volume_set"
|
||||
},
|
||||
"picker": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "volume_level"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "volume_level"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -491,47 +644,32 @@
|
||||
"if": {
|
||||
"properties": {
|
||||
"entity": {
|
||||
"pattern": "^media_player\\.[^.]+$"
|
||||
"pattern": "^climate\\.[^.]+$"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "volume_level"
|
||||
},
|
||||
"service": {
|
||||
"const": "media_player.volume_set"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "volume_level"
|
||||
},
|
||||
"min": {
|
||||
"const": 0
|
||||
},
|
||||
"max": {
|
||||
"const": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"else": {
|
||||
"if": {
|
||||
"tap_action": {
|
||||
"properties": {
|
||||
"entity": {
|
||||
"pattern": "^climate\\.[^.]+$"
|
||||
}
|
||||
}
|
||||
},
|
||||
"then": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "temperature"
|
||||
},
|
||||
"service": {
|
||||
"const": "climate.set_temperature"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "temperature"
|
||||
"properties": {
|
||||
"service": {
|
||||
"const": "climate.set_temperature"
|
||||
},
|
||||
"picker": {
|
||||
"properties": {
|
||||
"attribute": {
|
||||
"const": "temperature"
|
||||
},
|
||||
"data_attribute": {
|
||||
"const": "temperature"
|
||||
}
|
||||
},
|
||||
"not": {
|
||||
"required": [
|
||||
"attribute"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -579,96 +717,132 @@
|
||||
"type": "numeric",
|
||||
"name": "Example",
|
||||
"entity": "light.example",
|
||||
"attribute": "brightness",
|
||||
"service": "light.turn_on",
|
||||
"data_attribute": "brightness",
|
||||
"min": 0,
|
||||
"max": 255,
|
||||
"step": 1
|
||||
"tap_action": {
|
||||
"service": "light.turn_on",
|
||||
"picker": {
|
||||
"attribute": "brightness",
|
||||
"data_attribute": "brightness",
|
||||
"min": 0,
|
||||
"max": 255,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "numeric",
|
||||
"name": "Example",
|
||||
"entity": "input_number.example",
|
||||
"service": "input_number.set_value",
|
||||
"data_attribute": "value",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
"tap_action": {
|
||||
"service": "input_number.set_value",
|
||||
"picker": {
|
||||
"data_attribute": "value",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "numeric",
|
||||
"name": "Example",
|
||||
"entity": "number.example",
|
||||
"service": "number.set_value",
|
||||
"data_attribute": "value",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
"tap_action": {
|
||||
"service": "number.set_value",
|
||||
"picker": {
|
||||
"data_attribute": "value",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "numeric",
|
||||
"name": "Example",
|
||||
"entity": "fan.example",
|
||||
"attribute": "percentage",
|
||||
"service": "fan.set_percentage",
|
||||
"data_attribute": "percentage",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1,
|
||||
"display_format": "%.0f%%"
|
||||
"tap_action": {
|
||||
"service": "fan.set_percentage",
|
||||
"picker": {
|
||||
"attribute": "percentage",
|
||||
"data_attribute": "percentage",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1,
|
||||
"display_format": "%.0f%%"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "numeric",
|
||||
"name": "Example",
|
||||
"entity": "valve.example",
|
||||
"attribute": "position",
|
||||
"service": "valve.set_valve_position",
|
||||
"data_attribute": "position",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
"tap_action": {
|
||||
"service": "valve.set_valve_position",
|
||||
"picker": {
|
||||
"attribute": "position",
|
||||
"data_attribute": "position",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "numeric",
|
||||
"name": "Example",
|
||||
"entity": "cover.example",
|
||||
"attribute": "position",
|
||||
"service": "cover.set_position",
|
||||
"data_attribute": "position",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
"tap_action": {
|
||||
"service": "cover.set_position",
|
||||
"picker": {
|
||||
"attribute": "position",
|
||||
"data_attribute": "position",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "numeric",
|
||||
"name": "Example",
|
||||
"entity": "cover.example",
|
||||
"attribute": "tilt_position",
|
||||
"service": "cover.set_tilt_position",
|
||||
"data_attribute": "tilt_position",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
"tap_action": {
|
||||
"service": "cover.set_tilt_position",
|
||||
"picker": {
|
||||
"attribute": "tilt_position",
|
||||
"data_attribute": "tilt_position",
|
||||
"min": 0,
|
||||
"max": 100,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "numeric",
|
||||
"name": "Example",
|
||||
"entity": "media_player.example",
|
||||
"attribute": "volume_level",
|
||||
"service": "media_player.volume_set",
|
||||
"data_attribute": "volume_level",
|
||||
"min": 0,
|
||||
"max": 1,
|
||||
"step": 0.01
|
||||
"tap_action": {
|
||||
"service": "media_player.volume_set",
|
||||
"picker": {
|
||||
"attribute": "volume_level",
|
||||
"data_attribute": "volume_level",
|
||||
"min": 0,
|
||||
"max": 1,
|
||||
"step": 0.01
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "numeric",
|
||||
"name": "Example",
|
||||
"entity": "climate.example",
|
||||
"attribute": "temperature",
|
||||
"service": "climate.set_temperature",
|
||||
"data_attribute": "temperature"
|
||||
"tap_action": {
|
||||
"service": "climate.set_temperature",
|
||||
"picker": {
|
||||
"attribute": "temperature",
|
||||
"data_attribute": "temperature"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"allOf": [
|
||||
@@ -778,11 +952,8 @@
|
||||
"tap_action": {
|
||||
"type": "object",
|
||||
"title": "Action",
|
||||
"description": "'confirm' field is optional.",
|
||||
"description": "'confirm' and 'pin' fields are optional.",
|
||||
"properties": {
|
||||
"picker": {
|
||||
"$ref": "#/$defs/picker"
|
||||
},
|
||||
"confirm": {
|
||||
"$ref": "#/$defs/confirm"
|
||||
},
|
||||
@@ -791,51 +962,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"picker": {
|
||||
"type": "object",
|
||||
"title": "Number picker configuration",
|
||||
"description": "'attribute' field is optional.",
|
||||
"properties": {
|
||||
"min": {
|
||||
"type": "number",
|
||||
"title": "Minimum Value"
|
||||
},
|
||||
"max": {
|
||||
"type": "number",
|
||||
"title": "Maximum Value"
|
||||
},
|
||||
"step": {
|
||||
"type": "number",
|
||||
"title": "Step Size"
|
||||
},
|
||||
"attribute": {
|
||||
"type": "string",
|
||||
"title": "Attribute on the entity",
|
||||
"description": "Attribute on the entity with the current numeric value. To use the state of the entity, do not specify."
|
||||
},
|
||||
"data_attribute": {
|
||||
"type": "string",
|
||||
"title": "Attribute on the service data",
|
||||
"description": "Attribute on the service data for the value to set."
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"min",
|
||||
"max",
|
||||
"step",
|
||||
"data_attribute"
|
||||
]
|
||||
},
|
||||
"content": {
|
||||
"title": "Home Assistant Template",
|
||||
"description": "Jinja2 template defining the text to display. Must be included in an 'info'. Optional in a 'toggle', 'tap' and 'group'. Special characters may not render in the glance context.",
|
||||
"type": "string"
|
||||
},
|
||||
"confirm": {
|
||||
"type": "boolean",
|
||||
"type": ["boolean", "string"],
|
||||
"default": false,
|
||||
"title": "Confirmation",
|
||||
"description": "Optional confirmation of the action before execution as a precaution."
|
||||
"description": "Optional confirmation of the action before execution as a precaution. Use a Boolean for the default message. Specify a string to display a specific confirmation message."
|
||||
},
|
||||
"pin": {
|
||||
"type": "boolean",
|
||||
|
||||
@@ -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
|
||||
@@ -37,6 +37,14 @@ For example:
|
||||
"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
|
||||
"tap_action": {
|
||||
"confirm": "Toggle the cover?"
|
||||
}
|
||||
```
|
||||
|
||||
**The authors do not advise the use of this application for security sensitive devices. But we suspect users are taking that risk anyway, hence a PIN confirmation is provided that can be used for additional menu item security.**
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
163
examples/Numeric.md
Normal file
163
examples/Numeric.md
Normal file
@@ -0,0 +1,163 @@
|
||||
[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:
|
||||
|
||||
<img src="../images/my_float.png" width="400" title="Home Assistant 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.
|
||||
|
||||
```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.
|
||||
|
||||
<img src="../images/template_number.png" width="500" title="Home Assistant Helper definition for an 'input_number'." style="margin:5px"/>
|
||||
|
||||
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') }}
|
||||
```
|
||||
|
||||
As an alternative to using the GUI, the following can be pasted into Home Assistant's `configuration.yaml`:
|
||||
|
||||
```yaml
|
||||
template:
|
||||
- number:
|
||||
- name: "Amplifier dB"
|
||||
unique_id: "<Generate Unique ID>"
|
||||
unit_of_measurement: "dB"
|
||||
state: "{{ state_attr('media_player.amplifier','volume_level') * 100 -80 }}"
|
||||
availability: "{{ not is_state('media_player.amplifier','unavailable') }}"
|
||||
set_value:
|
||||
- action: media_player.volume_set
|
||||
target:
|
||||
entity_id: media_player.amplifier
|
||||
data:
|
||||
volume_level: "{{ (value+80)/100 }}"
|
||||
step: 0.5
|
||||
min: -60
|
||||
max: -15
|
||||
icon: mdi:audio-video
|
||||
```
|
||||
|
||||
We noticed some schema checking errors when we tried this, but the YAML above is consistent with the HA [Template](https://www.home-assistant.io/integrations/template/#number) support pages, and this code does correctly create the number template as required.
|
||||
|
||||
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 value as the `content` template is rendered on the Home Assistant server.
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
BIN
images/my_float.png
Normal file
BIN
images/my_float.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 64 KiB |
BIN
images/template_number.png
Normal file
BIN
images/template_number.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 159 KiB |
@@ -24,7 +24,7 @@
|
||||
Use "Monkey C: Edit Application" from the Visual Studio Code command palette
|
||||
to update the application attributes.
|
||||
-->
|
||||
<iq:application id="971834c4-e4fc-4825-801f-7ac9db0e3044" type="watch-app" name="@Strings.AppName" entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.1.0">
|
||||
<iq:application id="98c36259-498a-4458-9cef-74a273ad2bc3" type="watch-app" name="@Strings.AppName" entry="HomeAssistantApp" launcherIcon="@Drawables.LauncherIcon" minApiLevel="3.1.0">
|
||||
<!--
|
||||
Use the following from the Visual Studio Code command palette to edit
|
||||
the build targets:
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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() };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,10 +24,13 @@ class HomeAssistantConfirmation extends WatchUi.Confirmation {
|
||||
|
||||
//! Class Constructor
|
||||
//
|
||||
function initialize() {
|
||||
WatchUi.Confirmation.initialize(WatchUi.loadResource($.Rez.Strings.Confirm) as Lang.String);
|
||||
function initialize(message as Lang.String?) {
|
||||
if (message == null) {
|
||||
WatchUi.Confirmation.initialize(WatchUi.loadResource($.Rez.Strings.Confirm) as Lang.String);
|
||||
} else {
|
||||
WatchUi.Confirmation.initialize(message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//! Delegate to respond to the confirmation request.
|
||||
|
||||
@@ -33,7 +33,7 @@ class HomeAssistantGroupMenuItem extends HomeAssistantMenuItem {
|
||||
}?
|
||||
) {
|
||||
if (options != null) {
|
||||
options.put(:icon, icon);
|
||||
options[:icon] = icon;
|
||||
} else {
|
||||
options = { :icon => icon };
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -23,7 +23,7 @@ using Toybox.Graphics;
|
||||
class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
|
||||
private var mHomeAssistantService as HomeAssistantService?;
|
||||
private var mService as Lang.String?;
|
||||
private var mConfirm as Lang.Boolean;
|
||||
private var mConfirm as Lang.Boolean or Lang.String or Null;
|
||||
private var mExit as Lang.Boolean;
|
||||
private var mPin as Lang.Boolean;
|
||||
private var mData as Lang.Dictionary?;
|
||||
@@ -127,7 +127,12 @@ class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
|
||||
WatchUi.SLIDE_LEFT
|
||||
);
|
||||
} else {
|
||||
var view = new HomeAssistantConfirmation();
|
||||
var view;
|
||||
if (mConfirm instanceof Lang.String) {
|
||||
view = new HomeAssistantConfirmation(mConfirm as Lang.String?);
|
||||
} else {
|
||||
view = new HomeAssistantConfirmation(null);
|
||||
}
|
||||
WatchUi.pushView(
|
||||
view,
|
||||
new HomeAssistantConfirmationDelegate({
|
||||
|
||||
@@ -22,7 +22,7 @@ using Toybox.Graphics;
|
||||
class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
|
||||
private var mHomeAssistantService as HomeAssistantService;
|
||||
private var mService as Lang.String?;
|
||||
private var mConfirm as Lang.Boolean;
|
||||
private var mConfirm as Lang.Boolean or Lang.String or Null;
|
||||
private var mExit as Lang.Boolean;
|
||||
private var mPin as Lang.Boolean;
|
||||
private var mData as Lang.Dictionary?;
|
||||
@@ -95,8 +95,7 @@ class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
|
||||
if ((! System.getDeviceSettings().phoneConnected ||
|
||||
! System.getDeviceSettings().connectionAvailable) &&
|
||||
Settings.getWifiLteExecutionEnabled()) {
|
||||
var dialogMsg = WatchUi.loadResource($.Rez.Strings.WifiLtePrompt) as Lang.String;
|
||||
var dialog = new WatchUi.Confirmation(dialogMsg);
|
||||
var dialog = new WatchUi.Confirmation(WatchUi.loadResource($.Rez.Strings.WifiLtePrompt) as Lang.String);
|
||||
WatchUi.pushView(
|
||||
dialog,
|
||||
new WifiLteExecutionConfirmDelegate({
|
||||
@@ -108,7 +107,12 @@ class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
|
||||
WatchUi.SLIDE_LEFT
|
||||
);
|
||||
} else {
|
||||
var view = new HomeAssistantConfirmation();
|
||||
var view;
|
||||
if (mConfirm instanceof Lang.String) {
|
||||
view = new HomeAssistantConfirmation(mConfirm as Lang.String?);
|
||||
} else {
|
||||
view = new HomeAssistantConfirmation(null);
|
||||
}
|
||||
WatchUi.pushView(
|
||||
view,
|
||||
new HomeAssistantConfirmationDelegate({
|
||||
|
||||
@@ -25,7 +25,7 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
||||
private var mData as Lang.Dictionary;
|
||||
private var mTemplate as Lang.String?;
|
||||
private var mExit as Lang.Boolean;
|
||||
private var mConfirm as Lang.Boolean;
|
||||
private var mConfirm as Lang.Boolean or Lang.String or Null;
|
||||
private var mPin as Lang.Boolean;
|
||||
private var mHasVibrate as Lang.Boolean = false;
|
||||
|
||||
@@ -324,7 +324,12 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
||||
Settings.getWifiLteExecutionEnabled()) {
|
||||
wifiPrompt(b);
|
||||
} else {
|
||||
var confirmationView = new HomeAssistantConfirmation();
|
||||
var confirmationView;
|
||||
if (mConfirm instanceof Lang.String) {
|
||||
confirmationView = new HomeAssistantConfirmation(mConfirm as Lang.String?);
|
||||
} else {
|
||||
confirmationView = new HomeAssistantConfirmation(null);
|
||||
}
|
||||
WatchUi.pushView(
|
||||
confirmationView,
|
||||
new HomeAssistantConfirmationDelegate({
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -48,7 +48,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
||||
var entity = items[i].get("entity") as Lang.String?;
|
||||
var tap_action = items[i].get("tap_action") as Lang.Dictionary?;
|
||||
var service = items[i].get("service") as Lang.String?; // Deprecated schema
|
||||
var confirm = false as Lang.Boolean?;
|
||||
var confirm = false as Lang.Boolean or Lang.String or Null;
|
||||
var pin = false as Lang.Boolean?;
|
||||
var data = null as Lang.Dictionary?;
|
||||
var enabled = true as Lang.Boolean?;
|
||||
|
||||
Reference in New Issue
Block a user