mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-11-22 08:38:15 +00:00
Compare commits
40 Commits
v3.5
...
0d3c76ef2e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0d3c76ef2e | ||
|
|
4c946d584a | ||
|
|
6e3cf73ab3 | ||
|
|
14186b7992 | ||
|
|
f64bed5058 | ||
|
|
619671de5d | ||
|
|
6d18406880 | ||
|
|
3a7676f4bf | ||
|
|
f19eb7c276 | ||
|
|
c617d2cad6 | ||
|
|
d1f6f6d9d2 | ||
|
|
35333f4d75 | ||
|
|
a5ddb65512 | ||
|
|
b0fa10b2c1 | ||
|
|
6a0ec34cdb | ||
|
|
2cd171637c | ||
|
|
264b160fdf | ||
|
|
81fa876449 | ||
|
|
b563ab7923 | ||
|
|
2ebf36a445 | ||
|
|
5bdab41d8b | ||
|
|
85080f5d46 | ||
|
|
35e0fe26d0 | ||
|
|
427c1834a8 | ||
|
|
4fbe4135b1 | ||
|
|
edef4ef464 | ||
|
|
92e4278332 | ||
|
|
4348c899ae | ||
|
|
b34291e41f | ||
|
|
7453b40cb1 | ||
|
|
483603a44d | ||
|
|
bc3271ba63 | ||
|
|
5ccd1be4e7 | ||
|
|
7871334b4a | ||
|
|
2f3ee236e8 | ||
|
|
6609fed35d | ||
|
|
d68aecd19c | ||
|
|
9a61c9ce77 | ||
|
|
2981893af7 | ||
|
|
52e2efddd8 |
8
.vscode/launch.json
vendored
8
.vscode/launch.json
vendored
@@ -4,14 +4,6 @@
|
|||||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
"version": "0.2.0",
|
"version": "0.2.0",
|
||||||
"configurations": [
|
"configurations": [
|
||||||
{
|
|
||||||
"name": "Python: Current File",
|
|
||||||
"type": "python",
|
|
||||||
"request": "launch",
|
|
||||||
"program": "${file}",
|
|
||||||
"console": "integratedTerminal",
|
|
||||||
"justMyCode": true
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"type": "monkeyc",
|
"type": "monkeyc",
|
||||||
"request": "launch",
|
"request": "launch",
|
||||||
|
|||||||
@@ -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
|
# 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
|
# 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.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.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.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.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. |
|
||||||
|
|||||||
@@ -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
|
# User Specified Custom HTTP Headers
|
||||||
|
|
||||||
|
|||||||
46
README.md
46
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
|
# GarminHomeAssistant
|
||||||
|
|
||||||
@@ -143,6 +143,22 @@ Example schema:
|
|||||||
"service": "scene.turn_on",
|
"service": "scene.turn_on",
|
||||||
"pin": true
|
"pin": true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -157,24 +173,28 @@ The example above illustrates how to configure:
|
|||||||
* Script invocation (`tap`)
|
* Script invocation (`tap`)
|
||||||
* Service invocation, e.g. Scene setting, (`tap`)
|
* Service invocation, e.g. Scene setting, (`tap`)
|
||||||
* A sub-menu to open (`group`)
|
* 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. 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
|
* 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).
|
* 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`.
|
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)|
|
| HA Entity Type | Tap | Toggle | Info (status)| Numeric |
|
||||||
|------------------|:---:|:------:|:------------:|
|
|------------------|:---:|:------:|:------------:|:-------:|
|
||||||
| Switch | ❌ | ✅ | ✅ |
|
| Switch | ❌ | ✅ | ✅ | ❌ |
|
||||||
| Light | ❌ | ✅ | ✅ |
|
| Switched Light | ❌ | ✅ | ✅ | ❌ |
|
||||||
| Automation | ✅ | ✅ | ❌ |
|
| Dimmer Light | ❌ | ❌ | ✅ | ✅ |
|
||||||
| Script | ✅ | ❌ | ❌ |
|
| Automation | ✅ | ✅ | ❌ | ❌ |
|
||||||
| Scene | ✅ | ❌ | ❌ |
|
| Script | ✅ | ❌ | ❌ | ❌ |
|
||||||
| Sensor | ❌ | ❌ | ✅ |
|
| Scene | ✅ | ❌ | ❌ | ❌ |
|
||||||
| Binary Sensor | ❌ | ❌ | ✅ |
|
| Sensor | ❌ | ❌ | ✅ | ❌ |
|
||||||
| Any other entity | ❌ | ❌ | ✅ |
|
| Binary Sensor | ❌ | ❌ | ✅ | ❌ |
|
||||||
| Any service | ✅ | ❌ | ❌ |
|
| 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 ;-) ?
|
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 ;-) ?
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
# 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
|
# Wi-Fi & LTE
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,10 @@
|
|||||||
"$ref": "#/$defs/items"
|
"$ref": "#/$defs/items"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["title", "items"],
|
"required": [
|
||||||
|
"title",
|
||||||
|
"items"
|
||||||
|
],
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"$defs": {
|
"$defs": {
|
||||||
"toggle": {
|
"toggle": {
|
||||||
@@ -37,15 +40,7 @@
|
|||||||
"$ref": "#/$defs/content"
|
"$ref": "#/$defs/content"
|
||||||
},
|
},
|
||||||
"tap_action": {
|
"tap_action": {
|
||||||
"type": "object",
|
"$ref": "#/$defs/tap_action",
|
||||||
"properties": {
|
|
||||||
"confirm": {
|
|
||||||
"$ref": "#/$defs/confirm"
|
|
||||||
},
|
|
||||||
"pin": {
|
|
||||||
"$ref": "#/$defs/pin"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"enabled": {
|
"enabled": {
|
||||||
@@ -55,7 +50,11 @@
|
|||||||
"$ref": "#/$defs/exit"
|
"$ref": "#/$defs/exit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["entity", "name", "type"],
|
"required": [
|
||||||
|
"entity",
|
||||||
|
"name",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"template": {
|
"template": {
|
||||||
@@ -86,7 +85,11 @@
|
|||||||
"$ref": "#/$defs/enabled"
|
"$ref": "#/$defs/enabled"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name", "content", "type"],
|
"required": [
|
||||||
|
"name",
|
||||||
|
"content",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -109,7 +112,20 @@
|
|||||||
"description": "Use 'info' or 'tap' instead."
|
"description": "Use 'info' or 'tap' instead."
|
||||||
},
|
},
|
||||||
"tap_action": {
|
"tap_action": {
|
||||||
"$ref": "#/$defs/tap_action"
|
"$ref": "#/$defs/tap_action",
|
||||||
|
"properties": {
|
||||||
|
"service": {
|
||||||
|
"$ref": "#/$defs/service"
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"type": "object",
|
||||||
|
"title": "Your services's parameters",
|
||||||
|
"description": "The object containing the parameters and their values to be passed to the entity. No schema checking can be done here, you are on your own! On application crash, remove the parameters."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"service"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"$ref": "#/$defs/enabled"
|
"$ref": "#/$defs/enabled"
|
||||||
@@ -118,7 +134,12 @@
|
|||||||
"$ref": "#/$defs/exit"
|
"$ref": "#/$defs/exit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name", "content", "type", "tap_action"],
|
"required": [
|
||||||
|
"name",
|
||||||
|
"content",
|
||||||
|
"type",
|
||||||
|
"tap_action"
|
||||||
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -140,7 +161,11 @@
|
|||||||
"$ref": "#/$defs/enabled"
|
"$ref": "#/$defs/enabled"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name", "content", "type"],
|
"required": [
|
||||||
|
"name",
|
||||||
|
"content",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"tap": {
|
"tap": {
|
||||||
@@ -160,13 +185,26 @@
|
|||||||
"$ref": "#/$defs/content"
|
"$ref": "#/$defs/content"
|
||||||
},
|
},
|
||||||
"service": {
|
"service": {
|
||||||
"$ref": "#/$defs/entity",
|
"$ref": "#/$defs/service",
|
||||||
"deprecated": true,
|
"deprecated": true,
|
||||||
"title": "Schema change:",
|
"title": "Schema change:",
|
||||||
"description": "Use 'tap_action' instead to mirror Home Assistant."
|
"description": "Use 'tap_action' instead to mirror Home Assistant."
|
||||||
},
|
},
|
||||||
"tap_action": {
|
"tap_action": {
|
||||||
"$ref": "#/$defs/tap_action"
|
"$ref": "#/$defs/tap_action",
|
||||||
|
"properties": {
|
||||||
|
"service": {
|
||||||
|
"$ref": "#/$defs/service"
|
||||||
|
},
|
||||||
|
"data": {
|
||||||
|
"type": "object",
|
||||||
|
"title": "Your services's parameters",
|
||||||
|
"description": "The object containing the parameters and their values to be passed to the entity. No schema checking can be done here, you are on your own! On application crash, remove the parameters."
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"service"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"enabled": {
|
"enabled": {
|
||||||
"$ref": "#/$defs/enabled"
|
"$ref": "#/$defs/enabled"
|
||||||
@@ -175,7 +213,10 @@
|
|||||||
"$ref": "#/$defs/exit"
|
"$ref": "#/$defs/exit"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name", "type"],
|
"required": [
|
||||||
|
"name",
|
||||||
|
"type"
|
||||||
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"group": {
|
"group": {
|
||||||
@@ -210,9 +251,302 @@
|
|||||||
"$ref": "#/$defs/enabled"
|
"$ref": "#/$defs/enabled"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name", "title", "type", "items"],
|
"required": [
|
||||||
|
"name",
|
||||||
|
"title",
|
||||||
|
"type",
|
||||||
|
"items"
|
||||||
|
],
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
|
"numeric": {
|
||||||
|
"type": "object",
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"properties": {
|
||||||
|
"name": {
|
||||||
|
"$ref": "#/$defs/name"
|
||||||
|
},
|
||||||
|
"type": {
|
||||||
|
"$ref": "#/$defs/type",
|
||||||
|
"const": "numeric"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"$ref": "#/$defs/content"
|
||||||
|
},
|
||||||
|
"tap_action": {
|
||||||
|
"$ref": "#/$defs/tap_action"
|
||||||
|
},
|
||||||
|
"enabled": {
|
||||||
|
"$ref": "#/$defs/enabled"
|
||||||
|
},
|
||||||
|
"exit": {
|
||||||
|
"$ref": "#/$defs/exit"
|
||||||
|
},
|
||||||
|
"entity": {
|
||||||
|
"$ref": "#/$defs/entity"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"required": [
|
||||||
|
"name",
|
||||||
|
"type",
|
||||||
|
"entity",
|
||||||
|
"tap_action"
|
||||||
|
],
|
||||||
|
"additionalProperties": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"properties": {
|
||||||
|
"entity": {
|
||||||
|
"pattern": "^(light|input_number|number|fan|valve|cover|media_player|climate)\\.[^.]+$"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"entity": {
|
||||||
|
"pattern": "^light\\.[^.]+$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"entity": {
|
||||||
|
"pattern": "^input_number\\.[^.]+$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"properties": {
|
||||||
|
"attribute": {
|
||||||
|
"const": "value"
|
||||||
|
},
|
||||||
|
"service": {
|
||||||
|
"const": "input_number.set_value"
|
||||||
|
},
|
||||||
|
"data_attribute": {
|
||||||
|
"const": "value"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"not": {
|
||||||
|
"required": [
|
||||||
|
"attribute"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"entity": {
|
||||||
|
"pattern": "^number\\.[^.]+$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"properties": {
|
||||||
|
"attribute": {
|
||||||
|
"const": "value"
|
||||||
|
},
|
||||||
|
"service": {
|
||||||
|
"const": "number.set_value"
|
||||||
|
},
|
||||||
|
"data_attribute": {
|
||||||
|
"const": "value"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"not": {
|
||||||
|
"required": [
|
||||||
|
"attribute"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"entity": {
|
||||||
|
"pattern": "^fan\\.[^.]+$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"properties": {
|
||||||
|
"attribute": {
|
||||||
|
"const": "percentage"
|
||||||
|
},
|
||||||
|
"service": {
|
||||||
|
"const": "fan.set_percentage"
|
||||||
|
},
|
||||||
|
"data_attribute": {
|
||||||
|
"const": "percentage"
|
||||||
|
},
|
||||||
|
"min": {
|
||||||
|
"const": 0
|
||||||
|
},
|
||||||
|
"max": {
|
||||||
|
"const": 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"entity": {
|
||||||
|
"pattern": "^valve\\.[^.]+$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"properties": {
|
||||||
|
"attribute": {
|
||||||
|
"const": "position"
|
||||||
|
},
|
||||||
|
"service": {
|
||||||
|
"const": "valve.set_valve_position"
|
||||||
|
},
|
||||||
|
"data_attribute": {
|
||||||
|
"const": "position"
|
||||||
|
},
|
||||||
|
"min": {
|
||||||
|
"const": 0
|
||||||
|
},
|
||||||
|
"max": {
|
||||||
|
"const": 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"entity": {
|
||||||
|
"pattern": "^cover\\.[^.]+$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"properties": {
|
||||||
|
"attribute": {
|
||||||
|
"const": "position"
|
||||||
|
},
|
||||||
|
"service": {
|
||||||
|
"const": "cover.set_position"
|
||||||
|
},
|
||||||
|
"data_attribute": {
|
||||||
|
"const": "position"
|
||||||
|
},
|
||||||
|
"min": {
|
||||||
|
"const": 0
|
||||||
|
},
|
||||||
|
"max": {
|
||||||
|
"const": 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"entity": {
|
||||||
|
"pattern": "^cover\\.[^.]+$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"properties": {
|
||||||
|
"attribute": {
|
||||||
|
"const": "tilt_position"
|
||||||
|
},
|
||||||
|
"service": {
|
||||||
|
"const": "cover.set_tilt_position"
|
||||||
|
},
|
||||||
|
"data_attribute": {
|
||||||
|
"const": "tilt_position"
|
||||||
|
},
|
||||||
|
"min": {
|
||||||
|
"const": 0
|
||||||
|
},
|
||||||
|
"max": {
|
||||||
|
"const": 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"entity": {
|
||||||
|
"pattern": "^media_player\\.[^.]+$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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": {
|
||||||
|
"properties": {
|
||||||
|
"entity": {
|
||||||
|
"pattern": "^climate\\.[^.]+$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"properties": {
|
||||||
|
"attribute": {
|
||||||
|
"const": "temperature"
|
||||||
|
},
|
||||||
|
"service": {
|
||||||
|
"const": "climate.set_temperature"
|
||||||
|
},
|
||||||
|
"data_attribute": {
|
||||||
|
"const": "temperature"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
"type": {
|
"type": {
|
||||||
"title": "Menu item type",
|
"title": "Menu item type",
|
||||||
"description": "One of 'info', 'tap', 'toggle' or 'group'."
|
"description": "One of 'info', 'tap', 'toggle' or 'group'."
|
||||||
@@ -220,21 +554,210 @@
|
|||||||
"items": {
|
"items": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"items": {
|
"items": {
|
||||||
"oneOf": [
|
"examples": [
|
||||||
{
|
{
|
||||||
"$ref": "#/$defs/toggle"
|
"type": "tap",
|
||||||
|
"name": "Example",
|
||||||
|
"tap_action": {
|
||||||
|
"service": "notify.notify",
|
||||||
|
"data": {
|
||||||
|
"message": "Example"
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/$defs/template"
|
"type": "toggle",
|
||||||
|
"name": "Example",
|
||||||
|
"entity": "switch.example"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/$defs/tap"
|
"type": "group",
|
||||||
|
"name": "Example",
|
||||||
|
"title": "Example",
|
||||||
|
"items": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/$defs/info"
|
"type": "numeric",
|
||||||
|
"name": "Example",
|
||||||
|
"entity": "light.example",
|
||||||
|
"attribute": "brightness",
|
||||||
|
"service": "light.turn_on",
|
||||||
|
"data_attribute": "brightness",
|
||||||
|
"min": 0,
|
||||||
|
"max": 255,
|
||||||
|
"step": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"$ref": "#/$defs/group"
|
"type": "numeric",
|
||||||
|
"name": "Example",
|
||||||
|
"entity": "input_number.example",
|
||||||
|
"service": "input_number.set_value",
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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%%"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "numeric",
|
||||||
|
"name": "Example",
|
||||||
|
"entity": "valve.example",
|
||||||
|
"attribute": "position",
|
||||||
|
"service": "valve.set_valve_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
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "numeric",
|
||||||
|
"name": "Example",
|
||||||
|
"entity": "climate.example",
|
||||||
|
"attribute": "temperature",
|
||||||
|
"service": "climate.set_temperature",
|
||||||
|
"data_attribute": "temperature"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"allOf": [
|
||||||
|
{
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"enum": [
|
||||||
|
"toggle",
|
||||||
|
"template",
|
||||||
|
"tap",
|
||||||
|
"info",
|
||||||
|
"group",
|
||||||
|
"numeric"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"const": "toggle"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"$ref": "#/$defs/toggle"
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"const": "template"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"$ref": "#/$defs/template"
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"const": "tap"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"$ref": "#/$defs/tap"
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"const": "info"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"$ref": "#/$defs/info"
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"const": "group"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"$ref": "#/$defs/group"
|
||||||
|
},
|
||||||
|
"else": {
|
||||||
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"const": "numeric"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"$ref": "#/$defs/numeric"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -256,24 +779,65 @@
|
|||||||
"tap_action": {
|
"tap_action": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "Action",
|
"title": "Action",
|
||||||
"description": "'confirm' field is optional.",
|
"description": "'picker' field is required for 'numeric' menu type. 'confirm' and 'pin' fields are optional.",
|
||||||
"properties": {
|
"properties": {
|
||||||
"service": {
|
"picker": {
|
||||||
"$ref": "#/$defs/service"
|
"$ref": "#/$defs/picker"
|
||||||
},
|
},
|
||||||
"confirm": {
|
"confirm": {
|
||||||
"$ref": "#/$defs/confirm"
|
"$ref": "#/$defs/confirm"
|
||||||
},
|
},
|
||||||
"pin": {
|
"pin": {
|
||||||
"$ref": "#/$defs/pin"
|
"$ref": "#/$defs/pin"
|
||||||
},
|
|
||||||
"data": {
|
|
||||||
"type": "object",
|
|
||||||
"title": "Your services's parameters",
|
|
||||||
"description": "The object containing the parameters and their values to be passed to the entity. No schema checking can be done here, you are on your own! On application crash, remove the parameters."
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["service"]
|
"if": {
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"const": "numeric"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"then": {
|
||||||
|
"required": [
|
||||||
|
"picker"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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": {
|
"content": {
|
||||||
"title": "Home Assistant Template",
|
"title": "Home Assistant Template",
|
||||||
@@ -307,7 +871,10 @@
|
|||||||
"$ref": "#/$defs/content"
|
"$ref": "#/$defs/content"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["type", "content"]
|
"required": [
|
||||||
|
"type",
|
||||||
|
"content"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"properties": {
|
"properties": {
|
||||||
@@ -317,7 +884,9 @@
|
|||||||
"const": "status"
|
"const": "status"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["type"]
|
"required": [
|
||||||
|
"type"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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
|
# Actions
|
||||||
@@ -108,3 +108,64 @@ If you would like to temporarily disable an item in your menu, e.g. for seasonal
|
|||||||
"enabled": false
|
"enabled": false
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Selects
|
||||||
|
|
||||||
|
Here is an example of how to make a light effect selector:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"type": "group",
|
||||||
|
"name": "Example",
|
||||||
|
"title": "Light Effect",
|
||||||
|
"content": "{{ state_attr('light.moon', 'effect') }}",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"type": "tap",
|
||||||
|
"name": "None",
|
||||||
|
"entity": "light.example",
|
||||||
|
"tap_action": {
|
||||||
|
"service": "light.turn_on",
|
||||||
|
"data": {
|
||||||
|
"effect": "None"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "tap",
|
||||||
|
"name": "Rainbow",
|
||||||
|
"entity": "light.example",
|
||||||
|
"tap_action": {
|
||||||
|
"service": "light.turn_on",
|
||||||
|
"data": {
|
||||||
|
"effect": "Rainbow"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "tap",
|
||||||
|
"name": "Glimmer",
|
||||||
|
"entity": "light.example",
|
||||||
|
"tap_action": {
|
||||||
|
"service": "light.turn_on",
|
||||||
|
"data": {
|
||||||
|
"effect": "Glimmer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "tap",
|
||||||
|
"name": "Twinkle",
|
||||||
|
"entity": "light.example",
|
||||||
|
"tap_action": {
|
||||||
|
"service": "light.turn_on",
|
||||||
|
"data": {
|
||||||
|
"effect": "Twinkle"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The same pattern works for any selector (`input_select.*`, `select.*`, `climate.*` mode).
|
||||||
|
|||||||
@@ -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
|
# Glance
|
||||||
|
|
||||||
|
|||||||
139
examples/Numeric.md
Normal file
139
examples/Numeric.md
Normal file
@@ -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:
|
||||||
|
|
||||||
|
<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') }}
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
@@ -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
|
# 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
|
# 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 |
378
manifest.xml
378
manifest.xml
@@ -13,218 +13,218 @@
|
|||||||
|
|
||||||
Device Information & References:
|
Device Information & References:
|
||||||
* https://developer.garmin.com/connect-iq/compatible-devices/
|
* https://developer.garmin.com/connect-iq/compatible-devices/
|
||||||
* https://developer.garmin.com/connect-iq/reference-guides/devices-reference/
|
* https://developer.garmin.com/connect-iq/device-reference/
|
||||||
|
|
||||||
philipabbey's Test App id="98c36259-498a-4458-9cef-74a273ad2bc3" type="watch-app"
|
philipabbey's Test App id="98c36259-498a-4458-9cef-74a273ad2bc3" type="watch-app"
|
||||||
Live Application id="40131e87-31ff-454b-a8e2-92276ee399d6" type="watch-app"
|
Live Application id="40131e87-31ff-454b-a8e2-92276ee399d6" type="watch-app"
|
||||||
|
|
||||||
-->
|
-->
|
||||||
<iq:manifest version="3" xmlns:iq="http://www.garmin.com/xml/connectiq">
|
<iq:manifest version="3" xmlns:iq="http://www.garmin.com/xml/connectiq">
|
||||||
<!--
|
<!--
|
||||||
Use "Monkey C: Edit Application" from the Visual Studio Code command palette
|
Use "Monkey C: Edit Application" from the Visual Studio Code command palette
|
||||||
to update the application attributes.
|
to update the application attributes.
|
||||||
-->
|
-->
|
||||||
<iq:application id="98c36259-498a-4458-9cef-74a273ad2bc3" 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
|
Use the following from the Visual Studio Code command palette to edit
|
||||||
the build targets:
|
the build targets:
|
||||||
"Monkey C: Set Products by Product Category" - Lets you add all products
|
"Monkey C: Set Products by Product Category" - Lets you add all products
|
||||||
that belong to the same product category
|
that belong to the same product category
|
||||||
"Monkey C: Edit Products" - Lets you add or remove any product
|
"Monkey C: Edit Products" - Lets you add or remove any product
|
||||||
-->
|
-->
|
||||||
<iq:products>
|
<iq:products>
|
||||||
<iq:product id="approachs50"/>
|
<iq:product id="approachs50"/>
|
||||||
<iq:product id="approachs7042mm"/>
|
<iq:product id="approachs7042mm"/>
|
||||||
<iq:product id="approachs7047mm"/>
|
<iq:product id="approachs7047mm"/>
|
||||||
<iq:product id="d2air"/>
|
<iq:product id="d2air"/>
|
||||||
<iq:product id="d2airx10"/>
|
<iq:product id="d2airx10"/>
|
||||||
<iq:product id="d2delta"/>
|
<iq:product id="d2delta"/>
|
||||||
<iq:product id="d2deltapx"/>
|
<iq:product id="d2deltapx"/>
|
||||||
<iq:product id="d2deltas"/>
|
<iq:product id="d2deltas"/>
|
||||||
<iq:product id="d2mach1"/>
|
<iq:product id="d2mach1"/>
|
||||||
<iq:product id="descentg1"/>
|
<iq:product id="descentg1"/>
|
||||||
<iq:product id="descentg2"/>
|
<iq:product id="descentg2"/>
|
||||||
<iq:product id="descentmk1"/>
|
<iq:product id="descentmk2"/>
|
||||||
<iq:product id="descentmk2"/>
|
<iq:product id="descentmk2s"/>
|
||||||
<iq:product id="descentmk2s"/>
|
<iq:product id="descentmk343mm"/>
|
||||||
<iq:product id="descentmk343mm"/>
|
<iq:product id="descentmk351mm"/>
|
||||||
<iq:product id="descentmk351mm"/>
|
<iq:product id="edge1030"/>
|
||||||
<iq:product id="edge1030"/>
|
<iq:product id="edge1030bontrager"/>
|
||||||
<iq:product id="edge1030bontrager"/>
|
<iq:product id="edge1030plus"/>
|
||||||
<iq:product id="edge1030plus"/>
|
<iq:product id="edge1040"/>
|
||||||
<iq:product id="edge1040"/>
|
<iq:product id="edge1050"/>
|
||||||
<iq:product id="edge1050"/>
|
<iq:product id="edge520plus"/>
|
||||||
<iq:product id="edge520plus"/>
|
<iq:product id="edge530"/>
|
||||||
<iq:product id="edge530"/>
|
<iq:product id="edge540"/>
|
||||||
<iq:product id="edge540"/>
|
<iq:product id="edge550"/>
|
||||||
<iq:product id="edge550"/>
|
<iq:product id="edge820"/>
|
||||||
<iq:product id="edge820"/>
|
<iq:product id="edge830"/>
|
||||||
<iq:product id="edge830"/>
|
<iq:product id="edge840"/>
|
||||||
<iq:product id="edge840"/>
|
<iq:product id="edge850"/>
|
||||||
<iq:product id="edge850"/>
|
<iq:product id="edgeexplore"/>
|
||||||
<iq:product id="edgeexplore"/>
|
<iq:product id="edgeexplore2"/>
|
||||||
<iq:product id="edgeexplore2"/>
|
<iq:product id="edgemtb"/>
|
||||||
<iq:product id="edgemtb"/>
|
<iq:product id="enduro"/>
|
||||||
<iq:product id="enduro"/>
|
<iq:product id="enduro3"/>
|
||||||
<iq:product id="enduro3"/>
|
<iq:product id="epix2"/>
|
||||||
<iq:product id="epix2"/>
|
<iq:product id="epix2pro42mm"/>
|
||||||
<iq:product id="epix2pro42mm"/>
|
<iq:product id="epix2pro47mm"/>
|
||||||
<iq:product id="epix2pro47mm"/>
|
<iq:product id="epix2pro47mmsystem7preview"/>
|
||||||
<iq:product id="epix2pro51mm"/>
|
<iq:product id="epix2pro51mm"/>
|
||||||
<iq:product id="fenix5"/>
|
<iq:product id="fenix5"/>
|
||||||
<iq:product id="fenix5plus"/>
|
<iq:product id="fenix5plus"/>
|
||||||
<iq:product id="fenix5s"/>
|
<iq:product id="fenix5s"/>
|
||||||
<iq:product id="fenix5splus"/>
|
<iq:product id="fenix5splus"/>
|
||||||
<iq:product id="fenix5x"/>
|
<iq:product id="fenix5x"/>
|
||||||
<iq:product id="fenix5xplus"/>
|
<iq:product id="fenix5xplus"/>
|
||||||
<iq:product id="fenix6"/>
|
<iq:product id="fenix6"/>
|
||||||
<iq:product id="fenix6pro"/>
|
<iq:product id="fenix6pro"/>
|
||||||
<iq:product id="fenix6s"/>
|
<iq:product id="fenix6s"/>
|
||||||
<iq:product id="fenix6spro"/>
|
<iq:product id="fenix6spro"/>
|
||||||
<iq:product id="fenix6xpro"/>
|
<iq:product id="fenix6xpro"/>
|
||||||
<iq:product id="fenix7"/>
|
<iq:product id="fenix7"/>
|
||||||
<iq:product id="fenix7pro"/>
|
<iq:product id="fenix7pro"/>
|
||||||
<iq:product id="fenix7pronowifi"/>
|
<iq:product id="fenix7pronowifi"/>
|
||||||
<iq:product id="fenix7s"/>
|
<iq:product id="fenix7s"/>
|
||||||
<iq:product id="fenix7spro"/>
|
<iq:product id="fenix7spro"/>
|
||||||
<iq:product id="fenix7x"/>
|
<iq:product id="fenix7x"/>
|
||||||
<iq:product id="fenix7xpro"/>
|
<iq:product id="fenix7xpro"/>
|
||||||
<iq:product id="fenix7xpronowifi"/>
|
<iq:product id="fenix7xpronowifi"/>
|
||||||
<iq:product id="fenix843mm"/>
|
<iq:product id="fenix843mm"/>
|
||||||
<iq:product id="fenix847mm"/>
|
<iq:product id="fenix847mm"/>
|
||||||
<iq:product id="fenix8pro47mm"/>
|
<iq:product id="fenix8pro47mm"/>
|
||||||
<iq:product id="fenix8solar47mm"/>
|
<iq:product id="fenix8solar47mm"/>
|
||||||
<iq:product id="fenix8solar51mm"/>
|
<iq:product id="fenix8solar51mm"/>
|
||||||
<iq:product id="fenixchronos"/>
|
<iq:product id="fenixchronos"/>
|
||||||
<iq:product id="fenixe"/>
|
<iq:product id="fenixe"/>
|
||||||
<iq:product id="fr165"/>
|
<iq:product id="fr165"/>
|
||||||
<iq:product id="fr165m"/>
|
<iq:product id="fr165m"/>
|
||||||
<iq:product id="fr245"/>
|
<iq:product id="fr245"/>
|
||||||
<iq:product id="fr245m"/>
|
<iq:product id="fr245m"/>
|
||||||
<iq:product id="fr255"/>
|
<iq:product id="fr255"/>
|
||||||
<iq:product id="fr255m"/>
|
<iq:product id="fr255m"/>
|
||||||
<iq:product id="fr255s"/>
|
<iq:product id="fr255s"/>
|
||||||
<iq:product id="fr255sm"/>
|
<iq:product id="fr255sm"/>
|
||||||
<iq:product id="fr265"/>
|
<iq:product id="fr265"/>
|
||||||
<iq:product id="fr265s"/>
|
<iq:product id="fr265s"/>
|
||||||
<iq:product id="fr55"/>
|
<iq:product id="fr55"/>
|
||||||
<iq:product id="fr57042mm"/>
|
<iq:product id="fr57042mm"/>
|
||||||
<iq:product id="fr57047mm"/>
|
<iq:product id="fr57047mm"/>
|
||||||
<iq:product id="fr645"/>
|
<iq:product id="fr645"/>
|
||||||
<iq:product id="fr645m"/>
|
<iq:product id="fr645m"/>
|
||||||
<iq:product id="fr745"/>
|
<iq:product id="fr745"/>
|
||||||
<iq:product id="fr935"/>
|
<iq:product id="fr935"/>
|
||||||
<iq:product id="fr945"/>
|
<iq:product id="fr945"/>
|
||||||
<iq:product id="fr945lte"/>
|
<iq:product id="fr945lte"/>
|
||||||
<iq:product id="fr955"/>
|
<iq:product id="fr955"/>
|
||||||
<iq:product id="fr965"/>
|
<iq:product id="fr965"/>
|
||||||
<iq:product id="fr970"/>
|
<iq:product id="fr970"/>
|
||||||
<iq:product id="gpsmap66"/>
|
<iq:product id="gpsmap66"/>
|
||||||
<iq:product id="gpsmap67"/>
|
<iq:product id="gpsmap67"/>
|
||||||
<iq:product id="gpsmaph1"/>
|
<iq:product id="gpsmaph1"/>
|
||||||
<iq:product id="instinct2"/>
|
<iq:product id="instinct2"/>
|
||||||
<iq:product id="instinct2s"/>
|
<iq:product id="instinct2s"/>
|
||||||
<iq:product id="instinct2x"/>
|
<iq:product id="instinct2x"/>
|
||||||
<iq:product id="instinct3amoled45mm"/>
|
<iq:product id="instinct3amoled45mm"/>
|
||||||
<iq:product id="instinct3amoled50mm"/>
|
<iq:product id="instinct3amoled50mm"/>
|
||||||
<iq:product id="instinct3solar45mm"/>
|
<iq:product id="instinct3solar45mm"/>
|
||||||
<iq:product id="instinctcrossover"/>
|
<iq:product id="instinctcrossover"/>
|
||||||
<iq:product id="instinctcrossoveramoled"/>
|
<iq:product id="instinctcrossoveramoled"/>
|
||||||
<iq:product id="instincte40mm"/>
|
<iq:product id="instincte40mm"/>
|
||||||
<iq:product id="instincte45mm"/>
|
<iq:product id="instincte45mm"/>
|
||||||
<iq:product id="legacyherocaptainmarvel"/>
|
<iq:product id="legacyherocaptainmarvel"/>
|
||||||
<iq:product id="legacyherofirstavenger"/>
|
<iq:product id="legacyherofirstavenger"/>
|
||||||
<iq:product id="legacysagadarthvader"/>
|
<iq:product id="legacysagadarthvader"/>
|
||||||
<iq:product id="legacysagarey"/>
|
<iq:product id="legacysagarey"/>
|
||||||
<iq:product id="marq2"/>
|
<iq:product id="marq2"/>
|
||||||
<iq:product id="marq2aviator"/>
|
<iq:product id="marq2aviator"/>
|
||||||
<iq:product id="marqadventurer"/>
|
<iq:product id="marqadventurer"/>
|
||||||
<iq:product id="marqathlete"/>
|
<iq:product id="marqathlete"/>
|
||||||
<iq:product id="marqaviator"/>
|
<iq:product id="marqaviator"/>
|
||||||
<iq:product id="marqcaptain"/>
|
<iq:product id="marqcaptain"/>
|
||||||
<iq:product id="marqcommander"/>
|
<iq:product id="marqcommander"/>
|
||||||
<iq:product id="marqdriver"/>
|
<iq:product id="marqdriver"/>
|
||||||
<iq:product id="marqexpedition"/>
|
<iq:product id="marqexpedition"/>
|
||||||
<iq:product id="marqgolfer"/>
|
<iq:product id="marqgolfer"/>
|
||||||
<iq:product id="montana7xx"/>
|
<iq:product id="montana7xx"/>
|
||||||
<iq:product id="venu"/>
|
<iq:product id="venu"/>
|
||||||
<iq:product id="venu2"/>
|
<iq:product id="venu2"/>
|
||||||
<iq:product id="venu2plus"/>
|
<iq:product id="venu2plus"/>
|
||||||
<iq:product id="venu2s"/>
|
<iq:product id="venu2s"/>
|
||||||
<iq:product id="venu3"/>
|
<iq:product id="venu3"/>
|
||||||
<iq:product id="venu3s"/>
|
<iq:product id="venu3s"/>
|
||||||
<iq:product id="venu441mm"/>
|
<iq:product id="venu441mm"/>
|
||||||
<iq:product id="venu445mm"/>
|
<iq:product id="venu445mm"/>
|
||||||
<iq:product id="venud"/>
|
<iq:product id="venud"/>
|
||||||
<iq:product id="venusq"/>
|
<iq:product id="venusq"/>
|
||||||
<iq:product id="venusq2"/>
|
<iq:product id="venusq2"/>
|
||||||
<iq:product id="venusq2m"/>
|
<iq:product id="venusq2m"/>
|
||||||
<iq:product id="venusqm"/>
|
<iq:product id="venusqm"/>
|
||||||
<iq:product id="venux1"/>
|
<iq:product id="venux1"/>
|
||||||
<iq:product id="vivoactive3"/>
|
<iq:product id="vivoactive3"/>
|
||||||
<iq:product id="vivoactive3m"/>
|
<iq:product id="vivoactive3m"/>
|
||||||
<iq:product id="vivoactive3mlte"/>
|
<iq:product id="vivoactive3mlte"/>
|
||||||
<iq:product id="vivoactive4"/>
|
<iq:product id="vivoactive4"/>
|
||||||
<iq:product id="vivoactive4s"/>
|
<iq:product id="vivoactive4s"/>
|
||||||
<iq:product id="vivoactive5"/>
|
<iq:product id="vivoactive5"/>
|
||||||
<iq:product id="vivoactive6"/>
|
<iq:product id="vivoactive6"/>
|
||||||
</iq:products>
|
</iq:products>
|
||||||
<!--
|
<!--
|
||||||
Use "Monkey C: Edit Permissions" from the Visual Studio Code command
|
Use "Monkey C: Edit Permissions" from the Visual Studio Code command
|
||||||
palette to update permissions.
|
palette to update permissions.
|
||||||
-->
|
-->
|
||||||
<iq:permissions>
|
<iq:permissions>
|
||||||
<iq:uses-permission id="Background"/>
|
<iq:uses-permission id="Background"/>
|
||||||
<iq:uses-permission id="BluetoothLowEnergy"/>
|
<iq:uses-permission id="BluetoothLowEnergy"/>
|
||||||
<iq:uses-permission id="Communications"/>
|
<iq:uses-permission id="Communications"/>
|
||||||
<iq:uses-permission id="Positioning"/>
|
<iq:uses-permission id="Positioning"/>
|
||||||
</iq:permissions>
|
</iq:permissions>
|
||||||
<!--
|
<!--
|
||||||
Use "Monkey C: Edit Languages" from the Visual Studio Code command
|
Use "Monkey C: Edit Languages" from the Visual Studio Code command
|
||||||
palette to edit your compatible language list.
|
palette to edit your compatible language list.
|
||||||
-->
|
-->
|
||||||
<iq:languages>
|
<iq:languages>
|
||||||
<iq:language>ara</iq:language>
|
<iq:language>ara</iq:language>
|
||||||
<iq:language>bul</iq:language>
|
<iq:language>bul</iq:language>
|
||||||
<iq:language>ces</iq:language>
|
<iq:language>ces</iq:language>
|
||||||
<iq:language>dan</iq:language>
|
<iq:language>dan</iq:language>
|
||||||
<iq:language>deu</iq:language>
|
<iq:language>deu</iq:language>
|
||||||
<iq:language>dut</iq:language>
|
<iq:language>dut</iq:language>
|
||||||
<iq:language>eng</iq:language>
|
<iq:language>eng</iq:language>
|
||||||
<iq:language>est</iq:language>
|
<iq:language>est</iq:language>
|
||||||
<iq:language>fin</iq:language>
|
<iq:language>fin</iq:language>
|
||||||
<iq:language>fre</iq:language>
|
<iq:language>fre</iq:language>
|
||||||
<iq:language>gre</iq:language>
|
<iq:language>gre</iq:language>
|
||||||
<iq:language>heb</iq:language>
|
<iq:language>heb</iq:language>
|
||||||
<iq:language>hrv</iq:language>
|
<iq:language>hrv</iq:language>
|
||||||
<iq:language>hun</iq:language>
|
<iq:language>hun</iq:language>
|
||||||
<iq:language>ind</iq:language>
|
<iq:language>ind</iq:language>
|
||||||
<iq:language>ita</iq:language>
|
<iq:language>ita</iq:language>
|
||||||
<iq:language>jpn</iq:language>
|
<iq:language>jpn</iq:language>
|
||||||
<iq:language>kor</iq:language>
|
<iq:language>kor</iq:language>
|
||||||
<iq:language>lav</iq:language>
|
<iq:language>lav</iq:language>
|
||||||
<iq:language>lit</iq:language>
|
<iq:language>lit</iq:language>
|
||||||
<iq:language>nob</iq:language>
|
<iq:language>nob</iq:language>
|
||||||
<iq:language>pol</iq:language>
|
<iq:language>pol</iq:language>
|
||||||
<iq:language>por</iq:language>
|
<iq:language>por</iq:language>
|
||||||
<iq:language>ron</iq:language>
|
<iq:language>ron</iq:language>
|
||||||
<!-- <iq:language>rus</iq:language> -->
|
<!-- <iq:language>rus</iq:language> -->
|
||||||
<iq:language>slo</iq:language>
|
<iq:language>slo</iq:language>
|
||||||
<iq:language>slv</iq:language>
|
<iq:language>slv</iq:language>
|
||||||
<iq:language>spa</iq:language>
|
<iq:language>spa</iq:language>
|
||||||
<iq:language>swe</iq:language>
|
<iq:language>swe</iq:language>
|
||||||
<iq:language>tha</iq:language>
|
<iq:language>tha</iq:language>
|
||||||
<iq:language>tur</iq:language>
|
<iq:language>tur</iq:language>
|
||||||
<iq:language>ukr</iq:language>
|
<iq:language>ukr</iq:language>
|
||||||
<iq:language>vie</iq:language>
|
<iq:language>vie</iq:language>
|
||||||
<iq:language>zhs</iq:language>
|
<iq:language>zhs</iq:language>
|
||||||
<iq:language>zht</iq:language>
|
<iq:language>zht</iq:language>
|
||||||
<iq:language>zsm</iq:language>
|
<iq:language>zsm</iq:language>
|
||||||
</iq:languages>
|
</iq:languages>
|
||||||
<!--
|
<!--
|
||||||
Use "Monkey C: Configure Monkey Barrel" from the Visual Studio Code
|
Use "Monkey C: Configure Monkey Barrel" from the Visual Studio Code
|
||||||
command palette to edit the included barrels.
|
command palette to edit the included barrels.
|
||||||
-->
|
-->
|
||||||
<iq:barrels/>
|
<iq:barrels/>
|
||||||
</iq:application>
|
</iq:application>
|
||||||
</iq:manifest>
|
</iq:manifest>
|
||||||
|
|||||||
@@ -133,20 +133,20 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
|
|||||||
var data = { "gps_accuracy" => accuracy };
|
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.
|
// 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) {
|
if (position.position != null) {
|
||||||
data.put("gps", position.position.toDegrees());
|
data["gps"] = position.position.toDegrees();
|
||||||
}
|
}
|
||||||
if (position.speed != null) {
|
if (position.speed != null) {
|
||||||
data.put("speed", Math.round(position.speed));
|
data["speed"] = Math.round(position.speed);
|
||||||
}
|
}
|
||||||
if (position.heading != null) {
|
if (position.heading != null) {
|
||||||
var heading = Math.round(position.heading * 180 / Math.PI);
|
var heading = Math.round(position.heading * 180 / Math.PI);
|
||||||
while (heading < 0) {
|
while (heading < 0) {
|
||||||
heading += 360;
|
heading += 360;
|
||||||
}
|
}
|
||||||
data.put("course", heading);
|
data["course"] = heading;
|
||||||
}
|
}
|
||||||
if (position.altitude != null) {
|
if (position.altitude != null) {
|
||||||
data.put("altitude", Math.round(position.altitude));
|
data["altitude"] = Math.round(position.altitude);
|
||||||
}
|
}
|
||||||
// System.println("BackgroundServiceDelegate onTemporalEvent(): data = " + data.toString());
|
// System.println("BackgroundServiceDelegate onTemporalEvent(): data = " + data.toString());
|
||||||
|
|
||||||
|
|||||||
@@ -30,14 +30,14 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
private var mHasToast as Lang.Boolean = false;
|
private var mHasToast as Lang.Boolean = false;
|
||||||
private var mApiStatus as Lang.String?;
|
private var mApiStatus as Lang.String?;
|
||||||
private var mMenuStatus as Lang.String?;
|
private var mMenuStatus as Lang.String?;
|
||||||
private var mHaMenu as HomeAssistantView?;
|
private var mHaMenu as HomeAssistantView?;
|
||||||
private var mGlanceTemplate as Lang.String? = null;
|
private var mGlanceTemplate as Lang.String? = null;
|
||||||
private var mGlanceText as Lang.String? = null;
|
private var mGlanceText as Lang.String? = null;
|
||||||
private var mQuitTimer as QuitTimer?;
|
private var mQuitTimer as QuitTimer?;
|
||||||
private var mGlanceTimer as Timer.Timer?;
|
private var mGlanceTimer as Timer.Timer?;
|
||||||
private var mUpdateTimer as Timer.Timer?;
|
private var mUpdateTimer as Timer.Timer?;
|
||||||
// Array initialised by onReturnFetchMenuConfig()
|
// Array initialised by onReturnFetchMenuConfig()
|
||||||
private var mItemsToUpdate as Lang.Array<HomeAssistantToggleMenuItem or HomeAssistantTapMenuItem or HomeAssistantGroupMenuItem>?;
|
private var mItemsToUpdate as Lang.Array<HomeAssistantToggleMenuItem or HomeAssistantTapMenuItem or HomeAssistantGroupMenuItem or HomeAssistantNumericMenuItem>?;
|
||||||
private var mIsApp as Lang.Boolean = false; // Or Widget
|
private var mIsApp as Lang.Boolean = false; // Or Widget
|
||||||
private var mUpdating as Lang.Boolean = false; // Don't start a second chain of updates
|
private var mUpdating as Lang.Boolean = false; // Don't start a second chain of updates
|
||||||
private var mTemplates as Lang.Dictionary? = null; // Cache of compiled templates
|
private var mTemplates as Lang.Dictionary? = null; // Cache of compiled templates
|
||||||
@@ -629,6 +629,12 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
if (item instanceof HomeAssistantToggleMenuItem) {
|
if (item instanceof HomeAssistantToggleMenuItem) {
|
||||||
(item as HomeAssistantToggleMenuItem).updateToggleState(data[i.toString() + "t"]);
|
(item as HomeAssistantToggleMenuItem).updateToggleState(data[i.toString() + "t"]);
|
||||||
}
|
}
|
||||||
|
if (item instanceof HomeAssistantNumericMenuItem) {
|
||||||
|
var s = data[i.toString() + "n"];
|
||||||
|
if ((s instanceof Lang.Number) or (s instanceof Lang.Float)) {
|
||||||
|
(item as HomeAssistantNumericMenuItem).setValue(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (Settings.getMenuCheck() && Settings.getCacheConfig() && !mIsCacheChecked) {
|
if (Settings.getMenuCheck() && Settings.getCacheConfig() && !mIsCacheChecked) {
|
||||||
// We are caching the menu configuration, so let's fetch it and check if its been updated.
|
// We are caching the menu configuration, so let's fetch it and check if its been updated.
|
||||||
@@ -714,14 +720,13 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
var item = mItemsToUpdate[i];
|
var item = mItemsToUpdate[i];
|
||||||
var template = item.getTemplate();
|
var template = item.getTemplate();
|
||||||
if (template != null) {
|
if (template != null) {
|
||||||
mTemplates.put(i.toString(), {
|
mTemplates[i.toString()] = { "template" => template };
|
||||||
"template" => template
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (item instanceof HomeAssistantToggleMenuItem) {
|
if (item instanceof HomeAssistantToggleMenuItem) {
|
||||||
mTemplates.put(i.toString() + "t", {
|
mTemplates[i.toString() + "t"] = { "template" => (item as HomeAssistantToggleMenuItem).getToggleTemplate() };
|
||||||
"template" => (item as HomeAssistantToggleMenuItem).getToggleTemplate()
|
}
|
||||||
});
|
if (item instanceof HomeAssistantNumericMenuItem) {
|
||||||
|
mTemplates[i.toString() + "n"] = { "template" => (item as HomeAssistantNumericMenuItem).getNumericTemplate() };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -822,7 +827,7 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
var phoneConnected = System.getDeviceSettings().phoneConnected;
|
var phoneConnected = System.getDeviceSettings().phoneConnected;
|
||||||
var connectionAvailable = System.getDeviceSettings().connectionAvailable;
|
var connectionAvailable = System.getDeviceSettings().connectionAvailable;
|
||||||
|
|
||||||
// System.println("API URL = " + Settings.getApiUrl());
|
// System.println("HomeAssistantApp fetchApiStatus(): API URL = " + Settings.getApiUrl());
|
||||||
if (Settings.getApiUrl().equals("")) {
|
if (Settings.getApiUrl().equals("")) {
|
||||||
mApiStatus = WatchUi.loadResource($.Rez.Strings.Unconfigured) as Lang.String;
|
mApiStatus = WatchUi.loadResource($.Rez.Strings.Unconfigured) as Lang.String;
|
||||||
WatchUi.requestUpdate();
|
WatchUi.requestUpdate();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class HomeAssistantGroupMenuItem extends HomeAssistantMenuItem {
|
|||||||
}?
|
}?
|
||||||
) {
|
) {
|
||||||
if (options != null) {
|
if (options != null) {
|
||||||
options.put(:icon, icon);
|
options[:icon] = icon;
|
||||||
} else {
|
} else {
|
||||||
options = { :icon => icon };
|
options = { :icon => icon };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,7 @@ class HomeAssistantMenuItemFactory {
|
|||||||
//! Class Constructor
|
//! Class Constructor
|
||||||
//
|
//
|
||||||
private function initialize() {
|
private function initialize() {
|
||||||
mMenuItemOptions = {
|
mMenuItemOptions = { :alignment => Settings.getMenuAlignment() };
|
||||||
:alignment => Settings.getMenuAlignment()
|
|
||||||
};
|
|
||||||
|
|
||||||
mTapTypeIcon = new WatchUi.Bitmap({
|
mTapTypeIcon = new WatchUi.Bitmap({
|
||||||
:rezId => $.Rez.Drawables.TapTypeIcon,
|
:rezId => $.Rez.Drawables.TapTypeIcon,
|
||||||
@@ -84,7 +82,7 @@ class HomeAssistantMenuItemFactory {
|
|||||||
) as WatchUi.MenuItem {
|
) as WatchUi.MenuItem {
|
||||||
var keys = mMenuItemOptions.keys();
|
var keys = mMenuItemOptions.keys();
|
||||||
for (var i = 0; i < keys.size(); i++) {
|
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(
|
return new HomeAssistantToggleMenuItem(
|
||||||
label,
|
label,
|
||||||
@@ -119,15 +117,15 @@ class HomeAssistantMenuItemFactory {
|
|||||||
if (data == null) {
|
if (data == null) {
|
||||||
data = { "entity_id" => entity_id };
|
data = { "entity_id" => entity_id };
|
||||||
} else {
|
} else {
|
||||||
data.put("entity_id", entity_id);
|
data["entity_id"] = entity_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var keys = mMenuItemOptions.keys();
|
var keys = mMenuItemOptions.keys();
|
||||||
for (var i = 0; i < keys.size(); i++) {
|
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) {
|
if (service != null) {
|
||||||
options.put(:icon, mTapTypeIcon);
|
options[:icon] = mTapTypeIcon;
|
||||||
return new HomeAssistantTapMenuItem(
|
return new HomeAssistantTapMenuItem(
|
||||||
label,
|
label,
|
||||||
template,
|
template,
|
||||||
@@ -137,7 +135,7 @@ class HomeAssistantMenuItemFactory {
|
|||||||
mHomeAssistantService
|
mHomeAssistantService
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
options.put(:icon, mInfoTypeIcon);
|
options[:icon] = mInfoTypeIcon;
|
||||||
return new HomeAssistantTapMenuItem(
|
return new HomeAssistantTapMenuItem(
|
||||||
label,
|
label,
|
||||||
template,
|
template,
|
||||||
@@ -148,7 +146,43 @@ class HomeAssistantMenuItemFactory {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//! Numeric menu item.
|
||||||
|
//!
|
||||||
|
//! @param definition Items array from the JSON that defines this sub menu.
|
||||||
|
//! @param template Template for Home Assistant to render (optional)
|
||||||
|
//
|
||||||
|
function numeric(
|
||||||
|
label as Lang.String or Lang.Symbol,
|
||||||
|
entity_id as Lang.String?,
|
||||||
|
template as Lang.String?,
|
||||||
|
service as Lang.String?,
|
||||||
|
picker as Lang.Dictionary,
|
||||||
|
options as {
|
||||||
|
:exit as Lang.Boolean,
|
||||||
|
:confirm as Lang.Boolean,
|
||||||
|
:pin as Lang.Boolean,
|
||||||
|
:icon as WatchUi.Bitmap
|
||||||
|
}
|
||||||
|
) as WatchUi.MenuItem {
|
||||||
|
var data = null;
|
||||||
|
if (entity_id != null) {
|
||||||
|
data = { "entity_id" => entity_id };
|
||||||
|
}
|
||||||
|
var keys = mMenuItemOptions.keys();
|
||||||
|
for (var i = 0; i < keys.size(); i++) {
|
||||||
|
options[keys[i]] = mMenuItemOptions.get(keys[i]);
|
||||||
|
}
|
||||||
|
options[:icon] = mTapTypeIcon;
|
||||||
|
return new HomeAssistantNumericMenuItem(
|
||||||
|
label,
|
||||||
|
template,
|
||||||
|
service,
|
||||||
|
data,
|
||||||
|
picker,
|
||||||
|
options,
|
||||||
|
mHomeAssistantService
|
||||||
|
);
|
||||||
|
}
|
||||||
//! Group menu item.
|
//! Group menu item.
|
||||||
//!
|
//!
|
||||||
//! @param definition Items array from the JSON that defines this sub menu.
|
//! @param definition Items array from the JSON that defines this sub menu.
|
||||||
|
|||||||
100
source/HomeAssistantNumericFactory.mc
Normal file
100
source/HomeAssistantNumericFactory.mc
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Distributed under MIT Licence
|
||||||
|
// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
|
||||||
|
// tested on a Venu 2 device. The source code is provided at:
|
||||||
|
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||||
|
//
|
||||||
|
// P A Abbey & J D Abbey & @thmichel, 13 October 2025
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------
|
||||||
|
|
||||||
|
using Toybox.Graphics;
|
||||||
|
using Toybox.Lang;
|
||||||
|
using Toybox.WatchUi;
|
||||||
|
|
||||||
|
//! Factory that controls which numbers can be picked
|
||||||
|
class HomeAssistantNumericFactory extends WatchUi.PickerFactory {
|
||||||
|
// define default values in case not contained in data
|
||||||
|
private var mStart as Lang.Float = 0.0;
|
||||||
|
private var mStop as Lang.Float = 100.0;
|
||||||
|
private var mStep as Lang.Float = 1.0;
|
||||||
|
private var mFormatString as Lang.String = "%d";
|
||||||
|
|
||||||
|
//! Class Constructor
|
||||||
|
//
|
||||||
|
public function initialize(picker as Lang.Dictionary) {
|
||||||
|
PickerFactory.initialize();
|
||||||
|
|
||||||
|
// Get values from data
|
||||||
|
var val = picker["min"];
|
||||||
|
if (val != null) {
|
||||||
|
mStart = val.toString().toFloat();
|
||||||
|
}
|
||||||
|
val = picker["max"];
|
||||||
|
if (val != null) {
|
||||||
|
mStop = val.toString().toFloat();
|
||||||
|
}
|
||||||
|
val = picker["step"];
|
||||||
|
if (val != null) {
|
||||||
|
mStep = val.toString().toFloat();
|
||||||
|
}
|
||||||
|
if (mStep > 0.0) {
|
||||||
|
var s = mStep;
|
||||||
|
var dp = 0;
|
||||||
|
while (s < 1.0) {
|
||||||
|
s *= 10;
|
||||||
|
dp++;
|
||||||
|
// Assigned inside the loop and in each iteration to avoid clobbering the default '%d'.
|
||||||
|
mFormatString = "%." + dp.toString() + "f";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// The JSON menu definition defined a step size of 0, revert to the default.
|
||||||
|
mStep = 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Generate a Drawable instance for an item
|
||||||
|
//!
|
||||||
|
//! @param index The item index
|
||||||
|
//! @param selected true if the current item is selected, false otherwise
|
||||||
|
//! @return Drawable for the item
|
||||||
|
//
|
||||||
|
public function getDrawable(
|
||||||
|
index as Lang.Number,
|
||||||
|
selected as Lang.Boolean
|
||||||
|
) as WatchUi.Drawable? {
|
||||||
|
var value = getValue(index);
|
||||||
|
var text = "No item";
|
||||||
|
if (value instanceof Lang.Float) {
|
||||||
|
text = value.format(mFormatString);
|
||||||
|
}
|
||||||
|
return new WatchUi.Text({
|
||||||
|
:text => text,
|
||||||
|
:color => Graphics.COLOR_WHITE,
|
||||||
|
:locX => WatchUi.LAYOUT_HALIGN_CENTER,
|
||||||
|
:locY => WatchUi.LAYOUT_VALIGN_CENTER
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Get the value of the item at the given index
|
||||||
|
//!
|
||||||
|
//! @param index Index of the item to get the value of
|
||||||
|
//! @return Value of the item
|
||||||
|
//
|
||||||
|
public function getValue(index as Lang.Number) as Lang.Object? {
|
||||||
|
return mStart + (index * mStep);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Get the number of picker items
|
||||||
|
//!
|
||||||
|
//! @return Number of items
|
||||||
|
//
|
||||||
|
public function getSize() as Lang.Number {
|
||||||
|
return ((mStop - mStart) / mStep).toNumber() + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
247
source/HomeAssistantNumericMenuItem.mc
Normal file
247
source/HomeAssistantNumericMenuItem.mc
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Distributed under MIT Licence
|
||||||
|
// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
|
||||||
|
// tested on a Venu 2 device. The source code is provided at:
|
||||||
|
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||||
|
//
|
||||||
|
// P A Abbey & J D Abbey & @thmichel, 13 October 2025
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using Toybox.Lang;
|
||||||
|
using Toybox.WatchUi;
|
||||||
|
using Toybox.Graphics;
|
||||||
|
|
||||||
|
//! Menu button with an icon that opens a sub-menu, i.e. group, and optionally renders
|
||||||
|
//! a Home Assistant Template.
|
||||||
|
//
|
||||||
|
class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
|
||||||
|
private var mHomeAssistantService as HomeAssistantService?;
|
||||||
|
private var mService as Lang.String?;
|
||||||
|
private var mConfirm as Lang.Boolean;
|
||||||
|
private var mExit as Lang.Boolean;
|
||||||
|
private var mPin as Lang.Boolean;
|
||||||
|
private var mData as Lang.Dictionary?;
|
||||||
|
private var mPicker as Lang.Dictionary?;
|
||||||
|
private var mValue as Lang.Number or Lang.Float = 0;
|
||||||
|
private var mFormatString as Lang.String = "%d";
|
||||||
|
|
||||||
|
//! Class Constructor
|
||||||
|
//!
|
||||||
|
//! @param label Menu item label.
|
||||||
|
//! @param template Menu item template.
|
||||||
|
//! @param service Menu item service.
|
||||||
|
//! @param data Data to supply to the service call.
|
||||||
|
//! @param exit Should the service call complete and then exit?
|
||||||
|
//! @param confirm Should the service call be confirmed to avoid accidental invocation?
|
||||||
|
//! @param pin Should the service call be protected with a PIN for some low level of security?
|
||||||
|
//! @param icon Icon to use for the menu item.
|
||||||
|
//! @param options Menu item options to be passed on, including both SDK and menu options, e.g. exit, confirm & pin.
|
||||||
|
//! @param haService Shared Home Assistant service object that will perform the required call. Only
|
||||||
|
//! one of these objects is created for all menu items to re-use.
|
||||||
|
//
|
||||||
|
function initialize(
|
||||||
|
label as Lang.String or Lang.Symbol,
|
||||||
|
template as Lang.String,
|
||||||
|
service as Lang.String?,
|
||||||
|
data as Lang.Dictionary?,
|
||||||
|
picker as Lang.Dictionary,
|
||||||
|
options as {
|
||||||
|
:alignment as WatchUi.MenuItem.Alignment,
|
||||||
|
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol,
|
||||||
|
:exit as Lang.Boolean,
|
||||||
|
:confirm as Lang.Boolean,
|
||||||
|
:pin as Lang.Boolean
|
||||||
|
}?,
|
||||||
|
haService as HomeAssistantService
|
||||||
|
) {
|
||||||
|
mService = service;
|
||||||
|
mData = data;
|
||||||
|
mPicker = picker;
|
||||||
|
mExit = options[:exit];
|
||||||
|
mConfirm = options[:confirm];
|
||||||
|
mPin = options[:pin];
|
||||||
|
mLabel = label;
|
||||||
|
mHomeAssistantService = haService;
|
||||||
|
|
||||||
|
HomeAssistantMenuItem.initialize(
|
||||||
|
label,
|
||||||
|
template,
|
||||||
|
{
|
||||||
|
:alignment => options[:alignment],
|
||||||
|
:icon => options[:icon]
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (picker != null) {
|
||||||
|
var s = picker["step"];
|
||||||
|
if (s != null) {
|
||||||
|
var step = s.toFloat() as Lang.Float;
|
||||||
|
var dp = 0;
|
||||||
|
while (step < 1.0) {
|
||||||
|
step *= 10;
|
||||||
|
dp++;
|
||||||
|
// Assigned inside the loop and in each iteration to avoid clobbering the default '%d'.
|
||||||
|
mFormatString = "%." + dp.toString() + "f";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function callService() as Void {
|
||||||
|
var hasTouchScreen = System.getDeviceSettings().isTouchScreen;
|
||||||
|
if (mPin && hasTouchScreen) {
|
||||||
|
var pin = Settings.getPin();
|
||||||
|
if (pin != null) {
|
||||||
|
var pinConfirmationView = new HomeAssistantPinConfirmationView();
|
||||||
|
WatchUi.pushView(
|
||||||
|
pinConfirmationView,
|
||||||
|
new HomeAssistantPinConfirmationDelegate({
|
||||||
|
:callback => method(:onConfirm),
|
||||||
|
:pin => pin,
|
||||||
|
:state => false,
|
||||||
|
:view => pinConfirmationView,
|
||||||
|
}),
|
||||||
|
WatchUi.SLIDE_IMMEDIATE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if (mConfirm) {
|
||||||
|
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);
|
||||||
|
WatchUi.pushView(
|
||||||
|
dialog,
|
||||||
|
new WifiLteExecutionConfirmDelegate({
|
||||||
|
:type => "service",
|
||||||
|
:service => mService,
|
||||||
|
:data => mData,
|
||||||
|
:exit => mExit,
|
||||||
|
}, dialog),
|
||||||
|
WatchUi.SLIDE_LEFT
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
var view = new HomeAssistantConfirmation();
|
||||||
|
WatchUi.pushView(
|
||||||
|
view,
|
||||||
|
new HomeAssistantConfirmationDelegate({
|
||||||
|
:callback => method(:onConfirm),
|
||||||
|
:confirmationView => view,
|
||||||
|
:state => false,
|
||||||
|
}),
|
||||||
|
WatchUi.SLIDE_IMMEDIATE
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
onConfirm(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Callback function after the menu items selection has been (optionally) confirmed.
|
||||||
|
//!
|
||||||
|
//! @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 {
|
||||||
|
var dataAttribute = mPicker["data_attribute"];
|
||||||
|
if (dataAttribute == null) {
|
||||||
|
//return without call service 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 service if no entity_id is set to avoid crash
|
||||||
|
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mHomeAssistantService.call(
|
||||||
|
mService,
|
||||||
|
{
|
||||||
|
"entity_id" => entity_id.toString(),
|
||||||
|
dataAttribute.toString() => mValue
|
||||||
|
},
|
||||||
|
mExit
|
||||||
|
);
|
||||||
|
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Return a numeric menu item's fetch state template.
|
||||||
|
//!
|
||||||
|
//! @return A string with the menu item's template definition (or null).
|
||||||
|
//
|
||||||
|
function getNumericTemplate() as Lang.String? {
|
||||||
|
var entity_id = mData["entity_id"];
|
||||||
|
var attribute = mPicker["attribute"] as Lang.String?;
|
||||||
|
if (entity_id == null) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
if (attribute == null) {
|
||||||
|
return "{{states('" + entity_id.toString() + "')}}";
|
||||||
|
} else {
|
||||||
|
return "{{state_attr('" + entity_id.toString() + "','" + attribute + "')}}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Update the menu item's sub label to display the template rendered by Home Assistant.
|
||||||
|
//!
|
||||||
|
//! @param data The rendered template (typically a string) to be placed in the sub label. This may
|
||||||
|
//! unusually be a number if the SDK interprets the JSON returned by Home Assistant as such.
|
||||||
|
//
|
||||||
|
public function updateState(data as Lang.String or Lang.Dictionary or Lang.Number or Lang.Float or Null) as Void {
|
||||||
|
if (data == null) {
|
||||||
|
setSubLabel($.Rez.Strings.Empty);
|
||||||
|
} else if(data instanceof Lang.Float) {
|
||||||
|
var f = data as Lang.Float;
|
||||||
|
setSubLabel(f.format(mFormatString));
|
||||||
|
} else if(data instanceof Lang.Number) {
|
||||||
|
var f = data.toFloat() as Lang.Float;
|
||||||
|
setSubLabel(f.format(mFormatString));
|
||||||
|
} else if (data instanceof Lang.String) {
|
||||||
|
// This should not happen
|
||||||
|
setSubLabel(data);
|
||||||
|
} else {
|
||||||
|
// The template must return a Float on Numeric value, or the item cannot be formatted locally without error.
|
||||||
|
setSubLabel(WatchUi.loadResource($.Rez.Strings.TemplateError) as Lang.String);
|
||||||
|
}
|
||||||
|
WatchUi.requestUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Set the Picker's value. Needed to set new value via the Service call
|
||||||
|
//!
|
||||||
|
//! @param value New value to set.
|
||||||
|
//
|
||||||
|
public function setValue(value as Lang.Number or Lang.Float) as Void {
|
||||||
|
mValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Get the Picker's value.
|
||||||
|
//!
|
||||||
|
//! Needed to set new value via the Service call
|
||||||
|
//
|
||||||
|
public function getValue() as Lang.Number or Lang.Float {
|
||||||
|
return mValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Get the original 'data' field supplied by the JSON menu.
|
||||||
|
//!
|
||||||
|
//! @return Dictionary containing the 'data' field.
|
||||||
|
//
|
||||||
|
public function getData() as Lang.Dictionary {
|
||||||
|
return mData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the original 'picker' field supplied by the JSON menu.
|
||||||
|
//!
|
||||||
|
//! @return Dictionary containing the 'picker' field.
|
||||||
|
//
|
||||||
|
public function getPicker() as Lang.Dictionary {
|
||||||
|
return mPicker;
|
||||||
|
}
|
||||||
|
}
|
||||||
98
source/HomeAssistantNumericPicker.mc
Normal file
98
source/HomeAssistantNumericPicker.mc
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Distributed under MIT Licence
|
||||||
|
// See https://github.com/house-of-abbey/GarminHomeAssistant/blob/main/LICENSE.
|
||||||
|
//
|
||||||
|
//-----------------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// GarminHomeAssistant is a Garmin IQ application written in Monkey C and routinely
|
||||||
|
// tested on a Venu 2 device. The source code is provided at:
|
||||||
|
// https://github.com/house-of-abbey/GarminHomeAssistant.
|
||||||
|
//
|
||||||
|
// P A Abbey & J D Abbey & @thmichel, 13 October 2025
|
||||||
|
//
|
||||||
|
//------------------------------------------------------------
|
||||||
|
|
||||||
|
using Toybox.Application;
|
||||||
|
using Toybox.Lang;
|
||||||
|
using Toybox.Graphics;
|
||||||
|
using Toybox.System;
|
||||||
|
using Toybox.WatchUi;
|
||||||
|
|
||||||
|
//! Picker that allows the user to choose a float value
|
||||||
|
//
|
||||||
|
class HomeAssistantNumericPicker extends WatchUi.Picker {
|
||||||
|
private var mItem as HomeAssistantNumericMenuItem;
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
//
|
||||||
|
public function initialize(
|
||||||
|
factory as HomeAssistantNumericFactory,
|
||||||
|
haItem as HomeAssistantNumericMenuItem
|
||||||
|
) {
|
||||||
|
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 val = haItem.getValue();
|
||||||
|
|
||||||
|
if (min == null) {
|
||||||
|
min = 0.0;
|
||||||
|
}
|
||||||
|
if (step == null) {
|
||||||
|
step = 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
WatchUi.Picker.initialize({
|
||||||
|
:title => new WatchUi.Text({
|
||||||
|
:text => haItem.getLabel(),
|
||||||
|
:locX => WatchUi.LAYOUT_HALIGN_CENTER,
|
||||||
|
:locY => WatchUi.LAYOUT_VALIGN_BOTTOM
|
||||||
|
}),
|
||||||
|
:pattern => [factory],
|
||||||
|
:defaults => [((val - min) / step).toNumber()]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Called when the user has completed picking.
|
||||||
|
//!
|
||||||
|
//! @param value Value user selected
|
||||||
|
//! @return true if user is done, false otherwise
|
||||||
|
//
|
||||||
|
public function onConfirm(value as Lang.Number or Lang.Float) as Void {
|
||||||
|
mItem.setValue(value);
|
||||||
|
mItem.callService();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Responds to a numeric picker selection or cancellation.
|
||||||
|
//
|
||||||
|
class HomeAssistantNumericPickerDelegate extends WatchUi.PickerDelegate {
|
||||||
|
private var mPicker as HomeAssistantNumericPicker;
|
||||||
|
|
||||||
|
//! Constructor
|
||||||
|
//
|
||||||
|
public function initialize(picker as HomeAssistantNumericPicker) {
|
||||||
|
PickerDelegate.initialize();
|
||||||
|
mPicker = picker;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Handle a cancel event from the picker
|
||||||
|
//!
|
||||||
|
//! @return true if handled, false otherwise
|
||||||
|
//
|
||||||
|
public function onCancel() as Lang.Boolean {
|
||||||
|
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//! Handle a confirm event from the picker
|
||||||
|
//!
|
||||||
|
//! @param values The values chosen in the picker
|
||||||
|
//! @return true if handled, false otherwise
|
||||||
|
//
|
||||||
|
public function onAccept(values as Lang.Array) as Lang.Boolean {
|
||||||
|
mPicker.onConfirm(values[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -128,7 +128,7 @@ class HomeAssistantTapMenuItem 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 {
|
public function onConfirm(b as Lang.Boolean) as Void {
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
mHomeAssistantService.call(mService, mData, mExit);
|
mHomeAssistantService.call(mService, mData, mExit);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
if (options == null) {
|
if (options == null) {
|
||||||
options = { :title => definition.get("title") as Lang.String };
|
options = { :title => definition.get("title") as Lang.String };
|
||||||
} else {
|
} else {
|
||||||
options.put(:title, definition.get("title") as Lang.String);
|
options[:title] = definition.get("title") as Lang.String;
|
||||||
}
|
}
|
||||||
WatchUi.Menu2.initialize(options);
|
WatchUi.Menu2.initialize(options);
|
||||||
|
|
||||||
@@ -126,6 +126,24 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
}
|
}
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
} else if (type.equals("numeric") && service != null) {
|
||||||
|
if (tap_action != null) {
|
||||||
|
var picker = tap_action.get("picker") as Lang.Dictionary?;
|
||||||
|
if (picker != null) {
|
||||||
|
addItem(HomeAssistantMenuItemFactory.create().numeric(
|
||||||
|
name,
|
||||||
|
entity,
|
||||||
|
content,
|
||||||
|
service,
|
||||||
|
picker,
|
||||||
|
{
|
||||||
|
:exit => exit,
|
||||||
|
:confirm => confirm,
|
||||||
|
:pin => pin
|
||||||
|
}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (type.equals("info") && content != null) {
|
} else if (type.equals("info") && content != null) {
|
||||||
// Cannot exit from a non-actionable information only menu item.
|
// Cannot exit from a non-actionable information only menu item.
|
||||||
addItem(HomeAssistantMenuItemFactory.create().tap(
|
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||||
@@ -154,7 +172,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
//!
|
//!
|
||||||
//! @return An array of menu items that need to be updated periodically to reflect the latest Home Assistant state.
|
//! @return An array of menu items that need to be updated periodically to reflect the latest Home Assistant state.
|
||||||
//
|
//
|
||||||
function getItemsToUpdate() as Lang.Array<HomeAssistantToggleMenuItem or HomeAssistantTapMenuItem or HomeAssistantGroupMenuItem or Null> {
|
function getItemsToUpdate() as Lang.Array<HomeAssistantToggleMenuItem or HomeAssistantTapMenuItem or HomeAssistantGroupMenuItem or HomeAssistantNumericMenuItem or Null> {
|
||||||
var fullList = [];
|
var fullList = [];
|
||||||
var lmi = mItems as Lang.Array<WatchUi.MenuItem>;
|
var lmi = mItems as Lang.Array<WatchUi.MenuItem>;
|
||||||
|
|
||||||
@@ -167,6 +185,12 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
fullList.add(item);
|
fullList.add(item);
|
||||||
}
|
}
|
||||||
fullList.addAll(item.getMenuView().getItemsToUpdate());
|
fullList.addAll(item.getMenuView().getItemsToUpdate());
|
||||||
|
} else if (item instanceof HomeAssistantNumericMenuItem) {
|
||||||
|
// Numeric items can have an optional template to evaluate
|
||||||
|
var nmi = item as HomeAssistantNumericMenuItem;
|
||||||
|
if (nmi.hasTemplate()) {
|
||||||
|
fullList.add(item);
|
||||||
|
}
|
||||||
} else if (item instanceof HomeAssistantToggleMenuItem) {
|
} else if (item instanceof HomeAssistantToggleMenuItem) {
|
||||||
fullList.add(item);
|
fullList.add(item);
|
||||||
} else if (item instanceof HomeAssistantTapMenuItem) {
|
} else if (item instanceof HomeAssistantTapMenuItem) {
|
||||||
@@ -183,8 +207,8 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
//! Called when this View is brought to the foreground. Restore
|
//! Called when this View is brought to the foreground. Restore
|
||||||
//! the state of this View and prepare it to be shown. This includes
|
//! the state of this View and prepare it to be shown. This includes
|
||||||
//! loading resources into memory.
|
//! loading resources into memory.
|
||||||
|
//
|
||||||
function onShow() as Void {}
|
function onShow() as Void {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Delegate for the HomeAssistantView.
|
//! Delegate for the HomeAssistantView.
|
||||||
@@ -216,7 +240,7 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
|||||||
// If its started from glance or as an activity, directly exit the widget/app
|
// If its started from glance or as an activity, directly exit the widget/app
|
||||||
// (on widgets without glance, this exit() won't do anything,
|
// (on widgets without glance, this exit() won't do anything,
|
||||||
// so the base view will be shown instead, through the popView below this "if body")
|
// so the base view will be shown instead, through the popView below this "if body")
|
||||||
System.exit();
|
System.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||||
@@ -248,12 +272,17 @@ class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
|
|||||||
var haItem = item as HomeAssistantTapMenuItem;
|
var haItem = item as HomeAssistantTapMenuItem;
|
||||||
// System.println(haItem.getLabel() + " " + haItem.getId());
|
// System.println(haItem.getLabel() + " " + haItem.getId());
|
||||||
haItem.callService();
|
haItem.callService();
|
||||||
|
} else if (item instanceof HomeAssistantNumericMenuItem) {
|
||||||
|
var haItem = item as HomeAssistantNumericMenuItem;
|
||||||
|
// System.println(haItem.getLabel() + " " + haItem.getId());
|
||||||
|
// create new view to select new value
|
||||||
|
var mPickerFactory = new HomeAssistantNumericFactory((haItem as HomeAssistantNumericMenuItem).getPicker());
|
||||||
|
var mPicker = new HomeAssistantNumericPicker(mPickerFactory,haItem);
|
||||||
|
var mPickerDelegate = new HomeAssistantNumericPickerDelegate(mPicker);
|
||||||
|
WatchUi.pushView(mPicker,mPickerDelegate,WatchUi.SLIDE_LEFT);
|
||||||
} else if (item instanceof HomeAssistantGroupMenuItem) {
|
} else if (item instanceof HomeAssistantGroupMenuItem) {
|
||||||
var haMenuItem = item as HomeAssistantGroupMenuItem;
|
var haMenuItem = item as HomeAssistantGroupMenuItem;
|
||||||
// System.println("IconMenu: " + haMenuItem.getLabel() + " " + haMenuItem.getId());
|
|
||||||
WatchUi.pushView(haMenuItem.getMenuView(), new HomeAssistantViewDelegate(false), WatchUi.SLIDE_LEFT);
|
WatchUi.pushView(haMenuItem.getMenuView(), new HomeAssistantViewDelegate(false), WatchUi.SLIDE_LEFT);
|
||||||
// } else {
|
|
||||||
// System.println(item.getLabel() + " " + item.getId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
data-name="vs/editor/editor.main"
|
data-name="vs/editor/editor.main"
|
||||||
href="https://www.unpkg.com/monaco-editor@0.45.0/min/vs/editor/editor.main.css" />
|
href="https://www.unpkg.com/monaco-editor@0.52.2/min/vs/editor/editor.main.css" />
|
||||||
<link
|
<link
|
||||||
rel="stylesheet"
|
rel="stylesheet"
|
||||||
type="text/css"
|
type="text/css"
|
||||||
|
|||||||
30
web/main.js
30
web/main.js
@@ -141,10 +141,32 @@ async function get_services() {
|
|||||||
* @returns {Promise<{}>}
|
* @returns {Promise<{}>}
|
||||||
*/
|
*/
|
||||||
async function get_schema() {
|
async function get_schema() {
|
||||||
const res = await fetch(
|
const searchParams = new URL(window.location).searchParams;
|
||||||
'https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json'
|
|
||||||
);
|
const url = searchParams.get('schema');
|
||||||
return res.json();
|
if (url) return (await fetch(url)).json();
|
||||||
|
|
||||||
|
const branch = searchParams.get('branch');
|
||||||
|
if (branch)
|
||||||
|
return (
|
||||||
|
await fetch(
|
||||||
|
`https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/refs/heads/${branch}/config.schema.json`
|
||||||
|
)
|
||||||
|
).json();
|
||||||
|
|
||||||
|
const version = searchParams.get('version');
|
||||||
|
if (version)
|
||||||
|
return (
|
||||||
|
await fetch(
|
||||||
|
`https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/refs/tags/${version}/config.schema.json`
|
||||||
|
)
|
||||||
|
).json();
|
||||||
|
|
||||||
|
return (
|
||||||
|
await fetch(
|
||||||
|
`https://raw.githubusercontent.com/house-of-abbey/GarminHomeAssistant/main/config.schema.json`
|
||||||
|
)
|
||||||
|
).json();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/toastify-js": "^1.12.4",
|
"@types/toastify-js": "1.12.0",
|
||||||
"@vscode/webview-ui-toolkit": "1.4.0",
|
"@vscode/webview-ui-toolkit": "1.4.0",
|
||||||
"json-ast-comments": "1.1.1",
|
"json-ast-comments": "1.1.1",
|
||||||
"monaco-editor": "0.52.2",
|
"monaco-editor": "0.52.2",
|
||||||
|
|||||||
8
web/pnpm-lock.yaml
generated
8
web/pnpm-lock.yaml
generated
@@ -6,8 +6,8 @@ settings:
|
|||||||
|
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@types/toastify-js':
|
'@types/toastify-js':
|
||||||
specifier: ^1.12.4
|
specifier: 1.12.0
|
||||||
version: 1.12.4
|
version: 1.12.0
|
||||||
'@vscode/webview-ui-toolkit':
|
'@vscode/webview-ui-toolkit':
|
||||||
specifier: 1.4.0
|
specifier: 1.4.0
|
||||||
version: 1.4.0(react@18.2.0)
|
version: 1.4.0(react@18.2.0)
|
||||||
@@ -55,8 +55,8 @@ packages:
|
|||||||
exenv-es6: 1.1.1
|
exenv-es6: 1.1.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/toastify-js@1.12.4:
|
/@types/toastify-js@1.12.0:
|
||||||
resolution: {integrity: sha512-zfZHU4tKffPCnZRe7pjv/eFKzTVHozKewFCKaCjZ4gFinKgJRz/t0bkZiMCXJxPhv/ZoeDGNOeRD09R0kQZ/nw==}
|
resolution: {integrity: sha512-fqpDHaKhFukN9KRm24bbH0wozvHmSwjvkaLjBUrWcSfSS4zysIwTYqNLG3XbSNhRlsTNRNLGS23tp/VhPwsfHQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@vscode/webview-ui-toolkit@1.4.0(react@18.2.0):
|
/@vscode/webview-ui-toolkit@1.4.0(react@18.2.0):
|
||||||
|
|||||||
Reference in New Issue
Block a user