mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2026-07-08 11:53:32 +00:00
Compare commits
4 Commits
v3.13
...
a97440b997
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a97440b997 | ||
|
|
17690d4349 | ||
|
|
b1fb5d9417 | ||
|
|
2fb59d2a56 |
@@ -256,6 +256,11 @@
|
|||||||
"action": {
|
"action": {
|
||||||
"$ref": "#/$defs/action"
|
"$ref": "#/$defs/action"
|
||||||
},
|
},
|
||||||
|
"data": {
|
||||||
|
"type": "object",
|
||||||
|
"title": "Additional action data",
|
||||||
|
"description": "Fixed Home Assistant service data. The selected picker value is merged into this object using the picker's data_attribute. Service-specific fields cannot be schema checked here."
|
||||||
|
},
|
||||||
"picker": {
|
"picker": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"title": "Number picker configuration",
|
"title": "Number picker configuration",
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ Two simple examples using a scene and a cover as `tap` menu items.
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Confirmation
|
||||||
|
|
||||||
Any menu item with an action (`tap`, `template`, or `toggle`), may have a confirmation view added. For consistency this is always done via the `tap_action` JSON object, even though for a `toggle` menu item there will only ever be a single field inside. For the `toggle` menu item, the confirmation is presented on both `on` and `off` directions. There is no option for asymmetry, i.e. only in one direction.
|
Any menu item with an action (`tap`, `template`, or `toggle`), may have a confirmation view added. For consistency this is always done via the `tap_action` JSON object, even though for a `toggle` menu item there will only ever be a single field inside. For the `toggle` menu item, the confirmation is presented on both `on` and `off` directions. There is no option for asymmetry, i.e. only in one direction.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
@@ -56,6 +58,8 @@ The `confirm` field may contain a string instead of a Boolean in order to provid
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Personal Identification Number (PIN)
|
||||||
|
|
||||||
**The authors do not advise the use of this application for security sensitive devices. But we suspect users are taking that risk anyway, hence a PIN confirmation is provided that can be used for additional menu item security.**
|
**The authors do not advise the use of this application for security sensitive devices. But we suspect users are taking that risk anyway, hence a PIN confirmation is provided that can be used for additional menu item security.**
|
||||||
|
|
||||||
This can be enabled by setting the `pin` field in the `tap_action`. The `pin` field overrides `confirm`. Explicitly setting `confirm` is not necessary.
|
This can be enabled by setting the `pin` field in the `tap_action`. The `pin` field overrides `confirm`. Explicitly setting `confirm` is not necessary.
|
||||||
@@ -70,9 +74,14 @@ The 4-digit PIN is set globally for all actions in the app settings in Connect I
|
|||||||
|
|
||||||
When entering an invalid PIN for the fifth time within 2 minutes, the PIN dialog will be locked for all actions for the next 10 minutes. Entering a valid PIN will always reset the failure counter.
|
When entering an invalid PIN for the fifth time within 2 minutes, the PIN dialog will be locked for all actions for the next 10 minutes. Entering a valid PIN will always reset the failure counter.
|
||||||
|
|
||||||
<img src="../images/pin_view.png" width="200" title="Confirmation View"/>
|
<img src="../images/pin_view.png" width="200" title="PIN View"/>
|
||||||
|
|
||||||
Note that for notify events, you _must_ not supply an `entity_id` or the API call will fail. There are other examples too.
|
> [!IMPORTANT]
|
||||||
|
> The PIN entry requires a touch screen enabled device.
|
||||||
|
|
||||||
|
## Additional Data
|
||||||
|
|
||||||
|
Some `action`s require additional `data` to be supplied. The following example shows how we handle this scenario. Note that for notify events, you _must not_ supply an `entity_id` or the API call will fail. There are other examples too.
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,6 +39,36 @@ Field | Purpose
|
|||||||
|
|
||||||
It may well be the case that often `attribute` and `data_attribute` are the same attribute, as with this example.
|
It may well be the case that often `attribute` and `data_attribute` are the same attribute, as with this example.
|
||||||
|
|
||||||
|
## Additional Action Data
|
||||||
|
|
||||||
|
The `tap_action` object may also include a `data` object for fixed service call parameters. When the picker value is selected, the application merges the picker value into this `data` object using `data_attribute`.
|
||||||
|
|
||||||
|
For example, a light brightness picker can request a HomeAssistant transition while still using the picker value for `brightness`.
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"name": "Lounge Brightness",
|
||||||
|
"content": "{{ ((state_attr('light.lounge','brightness') | int(0) / 255) * 100) | round(0) }}%",
|
||||||
|
"type": "numeric",
|
||||||
|
"entity": "light.lounge",
|
||||||
|
"tap_action": {
|
||||||
|
"action": "light.turn_on",
|
||||||
|
"data": {
|
||||||
|
"transition": 2
|
||||||
|
},
|
||||||
|
"picker": {
|
||||||
|
"step": 5,
|
||||||
|
"min": 0,
|
||||||
|
"max": 255,
|
||||||
|
"attribute": "brightness",
|
||||||
|
"data_attribute": "brightness"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The resulting action data sent to HomeAssistant contains both the fixed `transition` value and the selected `brightness` value.
|
||||||
|
|
||||||
## Helper
|
## Helper
|
||||||
|
|
||||||
You might define a "helper" entity as follows in HomeAssistant:
|
You might define a "helper" entity as follows in HomeAssistant:
|
||||||
|
|||||||
@@ -163,6 +163,7 @@ class HomeAssistantMenuItemFactory {
|
|||||||
entity_id as Lang.String?,
|
entity_id as Lang.String?,
|
||||||
template as Lang.String?,
|
template as Lang.String?,
|
||||||
action as Lang.String?,
|
action as Lang.String?,
|
||||||
|
data as Lang.Dictionary?,
|
||||||
picker as Lang.Dictionary,
|
picker as Lang.Dictionary,
|
||||||
options as {
|
options as {
|
||||||
:exit as Lang.Boolean,
|
:exit as Lang.Boolean,
|
||||||
@@ -171,9 +172,12 @@ class HomeAssistantMenuItemFactory {
|
|||||||
:icon as WatchUi.Bitmap
|
:icon as WatchUi.Bitmap
|
||||||
}
|
}
|
||||||
) as WatchUi.MenuItem {
|
) as WatchUi.MenuItem {
|
||||||
var data = null;
|
|
||||||
if (entity_id != null) {
|
if (entity_id != null) {
|
||||||
data = { "entity_id" => entity_id };
|
if (data == null) {
|
||||||
|
data = { "entity_id" => entity_id };
|
||||||
|
} else {
|
||||||
|
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++) {
|
||||||
|
|||||||
@@ -155,7 +155,10 @@ class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
|
|||||||
//
|
//
|
||||||
function onConfirm(b as Lang.Boolean) as Void {
|
function onConfirm(b as Lang.Boolean) as Void {
|
||||||
var dataAttribute = mPicker["data_attribute"] as Lang.String?;
|
var dataAttribute = mPicker["data_attribute"] as Lang.String?;
|
||||||
var entity_id = mData["entity_id"] as Lang.String?;
|
var entity_id = null as Lang.String?;
|
||||||
|
if (mData != null) {
|
||||||
|
entity_id = mData["entity_id"] as Lang.String?;
|
||||||
|
}
|
||||||
|
|
||||||
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
WatchUi.popView(WatchUi.SLIDE_RIGHT);
|
||||||
WatchUi.requestUpdate();
|
WatchUi.requestUpdate();
|
||||||
@@ -164,12 +167,18 @@ class HomeAssistantNumericMenuItem extends HomeAssistantMenuItem {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (mAction != null) {
|
if (mAction != null) {
|
||||||
|
var data = {} as Lang.Dictionary;
|
||||||
|
if (mData != null) {
|
||||||
|
var keys = mData.keys();
|
||||||
|
for (var i = 0; i < keys.size(); i++) {
|
||||||
|
data[keys[i]] = mData[keys[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data["entity_id"] = entity_id.toString();
|
||||||
|
data[dataAttribute.toString()] = mValue;
|
||||||
mHomeAssistantService.call(
|
mHomeAssistantService.call(
|
||||||
mAction,
|
mAction,
|
||||||
{
|
data,
|
||||||
"entity_id" => entity_id.toString(),
|
|
||||||
dataAttribute.toString() => mValue
|
|
||||||
},
|
|
||||||
mExit
|
mExit
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
entity,
|
entity,
|
||||||
content,
|
content,
|
||||||
action,
|
action,
|
||||||
|
data,
|
||||||
picker,
|
picker,
|
||||||
{
|
{
|
||||||
:exit => exit,
|
:exit => exit,
|
||||||
|
|||||||
Reference in New Issue
Block a user