mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2026-06-26 14:03:28 +00:00
Preserve tap action data for numeric picker actions
Pass tap_action.data into numeric menu items and merge it with the selected picker value before calling the Home Assistant service.
This commit is contained in:
@@ -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) {
|
||||||
|
if (data == null) {
|
||||||
data = { "entity_id" => entity_id };
|
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