Initial working version
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-18/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="18" viewBox="0 -960 960 960" width="18" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-21/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="21" viewBox="0 -960 960 960" width="21" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-24/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="24" viewBox="0 -960 960 960" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-26/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="26" viewBox="0 -960 960 960" width="26" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-28/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="28" viewBox="0 -960 960 960" width="28" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-30/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="30" viewBox="0 -960 960 960" width="30" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-32/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="32" viewBox="0 -960 960 960" width="32" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-38/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="38" viewBox="0 -960 960 960" width="38" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-42/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="42" viewBox="0 -960 960 960" width="42" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-46/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="46" viewBox="0 -960 960 960" width="46" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-48/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="http://www.w3.org/2000/svg" height="48" viewBox="0 -960 960 960" width="48"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -19,4 +19,5 @@
|
|||||||
<bitmap id="ErrorIcon" filename="error.svg"/>
|
<bitmap id="ErrorIcon" filename="error.svg"/>
|
||||||
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
<bitmap id="GroupTypeIcon" filename="group_type.svg"/>
|
||||||
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
<bitmap id="TapTypeIcon" filename="tap_type.svg"/>
|
||||||
|
<bitmap id="InfoTypeIcon" filename="info_type.svg"/>
|
||||||
</drawables>
|
</drawables>
|
||||||
|
1
resources-icons-53/info_type.svg
Normal file
@ -0,0 +1 @@
|
|||||||
|
<svg height="53" viewBox="0 -960 960 960" width="53" xmlns="http://www.w3.org/2000/svg"><path d="M440-280h80v-240h-80v240Zm40-320q17 0 28.5-11.5T520-640q0-17-11.5-28.5T480-680q-17 0-28.5 11.5T440-640q0 17 11.5 28.5T480-600Zm0 520q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z" fill="blue" stroke="blue"/></svg>
|
After Width: | Height: | Size: 542 B |
@ -26,6 +26,7 @@ class HomeAssistantMenuItem extends WatchUi.IconMenuItem {
|
|||||||
private var mHomeAssistantService as HomeAssistantService;
|
private var mHomeAssistantService as HomeAssistantService;
|
||||||
private var mService as Lang.String;
|
private var mService as Lang.String;
|
||||||
private var mConfirm as Lang.Boolean;
|
private var mConfirm as Lang.Boolean;
|
||||||
|
private var mData as Lang.Dictionary or Null;
|
||||||
|
|
||||||
function initialize(
|
function initialize(
|
||||||
label as Lang.String or Lang.Symbol,
|
label as Lang.String or Lang.Symbol,
|
||||||
@ -33,6 +34,7 @@ class HomeAssistantMenuItem extends WatchUi.IconMenuItem {
|
|||||||
identifier as Lang.Object or Null,
|
identifier as Lang.Object or Null,
|
||||||
service as Lang.String or Null,
|
service as Lang.String or Null,
|
||||||
confirm as Lang.Boolean,
|
confirm as Lang.Boolean,
|
||||||
|
data as Lang.Dictionary or Null,
|
||||||
icon as Graphics.BitmapType or WatchUi.Drawable,
|
icon as Graphics.BitmapType or WatchUi.Drawable,
|
||||||
options as {
|
options as {
|
||||||
:alignment as WatchUi.MenuItem.Alignment
|
:alignment as WatchUi.MenuItem.Alignment
|
||||||
@ -48,9 +50,14 @@ class HomeAssistantMenuItem extends WatchUi.IconMenuItem {
|
|||||||
);
|
);
|
||||||
|
|
||||||
mHomeAssistantService = haService;
|
mHomeAssistantService = haService;
|
||||||
mIdentifier = identifier;
|
|
||||||
mService = service;
|
mService = service;
|
||||||
mConfirm = confirm;
|
mConfirm = confirm;
|
||||||
|
mData = data;
|
||||||
|
if (mData == null) {
|
||||||
|
mData = {"entity_id" => identifier};
|
||||||
|
} else {
|
||||||
|
mData.put("entity_id", identifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function callService() as Void {
|
function callService() as Void {
|
||||||
@ -66,7 +73,7 @@ class HomeAssistantMenuItem extends WatchUi.IconMenuItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onConfirm() as Void {
|
function onConfirm() as Void {
|
||||||
mHomeAssistantService.call(mIdentifier as Lang.String, mService);
|
mHomeAssistantService.call(mIdentifier as Lang.String, mService, mData);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,7 @@ class HomeAssistantMenuItemFactory {
|
|||||||
private var mMenuItemOptions as Lang.Dictionary;
|
private var mMenuItemOptions as Lang.Dictionary;
|
||||||
private var mTapTypeIcon as WatchUi.Bitmap;
|
private var mTapTypeIcon as WatchUi.Bitmap;
|
||||||
private var mGroupTypeIcon as WatchUi.Bitmap;
|
private var mGroupTypeIcon as WatchUi.Bitmap;
|
||||||
|
private var mInfoTypeIcon as WatchUi.Bitmap;
|
||||||
private var mHomeAssistantService as HomeAssistantService;
|
private var mHomeAssistantService as HomeAssistantService;
|
||||||
|
|
||||||
private static var instance;
|
private static var instance;
|
||||||
@ -47,6 +48,12 @@ class HomeAssistantMenuItemFactory {
|
|||||||
:locY => WatchUi.LAYOUT_VALIGN_CENTER
|
:locY => WatchUi.LAYOUT_VALIGN_CENTER
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mInfoTypeIcon = new WatchUi.Bitmap({
|
||||||
|
:rezId => $.Rez.Drawables.InfoTypeIcon,
|
||||||
|
:locX => WatchUi.LAYOUT_HALIGN_CENTER,
|
||||||
|
:locY => WatchUi.LAYOUT_VALIGN_CENTER
|
||||||
|
});
|
||||||
|
|
||||||
mHomeAssistantService = new HomeAssistantService();
|
mHomeAssistantService = new HomeAssistantService();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,12 +74,13 @@ class HomeAssistantMenuItemFactory {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function template(
|
function template_tap(
|
||||||
label as Lang.String or Lang.Symbol,
|
label as Lang.String or Lang.Symbol,
|
||||||
identifier as Lang.Object or Null,
|
identifier as Lang.Object or Null,
|
||||||
template as Lang.String or Null,
|
template as Lang.String or Null,
|
||||||
service as Lang.String or Null,
|
service as Lang.String or Null,
|
||||||
confirm as Lang.Boolean
|
confirm as Lang.Boolean,
|
||||||
|
data as Lang.Dictionary or Null
|
||||||
) as WatchUi.MenuItem {
|
) as WatchUi.MenuItem {
|
||||||
return new HomeAssistantTemplateMenuItem(
|
return new HomeAssistantTemplateMenuItem(
|
||||||
label,
|
label,
|
||||||
@ -80,6 +88,29 @@ class HomeAssistantMenuItemFactory {
|
|||||||
template,
|
template,
|
||||||
service,
|
service,
|
||||||
confirm,
|
confirm,
|
||||||
|
data,
|
||||||
|
mTapTypeIcon,
|
||||||
|
mMenuItemOptions,
|
||||||
|
mHomeAssistantService
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function template_notap(
|
||||||
|
label as Lang.String or Lang.Symbol,
|
||||||
|
identifier as Lang.Object or Null,
|
||||||
|
template as Lang.String or Null,
|
||||||
|
service as Lang.String or Null,
|
||||||
|
confirm as Lang.Boolean,
|
||||||
|
data as Lang.Dictionary or Null
|
||||||
|
) as WatchUi.MenuItem {
|
||||||
|
return new HomeAssistantTemplateMenuItem(
|
||||||
|
label,
|
||||||
|
identifier,
|
||||||
|
template,
|
||||||
|
service,
|
||||||
|
confirm,
|
||||||
|
data,
|
||||||
|
mInfoTypeIcon,
|
||||||
mMenuItemOptions,
|
mMenuItemOptions,
|
||||||
mHomeAssistantService
|
mHomeAssistantService
|
||||||
);
|
);
|
||||||
@ -89,7 +120,8 @@ class HomeAssistantMenuItemFactory {
|
|||||||
label as Lang.String or Lang.Symbol,
|
label as Lang.String or Lang.Symbol,
|
||||||
identifier as Lang.Object or Null,
|
identifier as Lang.Object or Null,
|
||||||
service as Lang.String or Null,
|
service as Lang.String or Null,
|
||||||
confirm as Lang.Boolean
|
confirm as Lang.Boolean,
|
||||||
|
data as Lang.Dictionary or Null
|
||||||
) as WatchUi.MenuItem {
|
) as WatchUi.MenuItem {
|
||||||
return new HomeAssistantMenuItem(
|
return new HomeAssistantMenuItem(
|
||||||
label,
|
label,
|
||||||
@ -97,6 +129,7 @@ class HomeAssistantMenuItemFactory {
|
|||||||
identifier,
|
identifier,
|
||||||
service,
|
service,
|
||||||
confirm,
|
confirm,
|
||||||
|
data,
|
||||||
mTapTypeIcon,
|
mTapTypeIcon,
|
||||||
mMenuItemOptions,
|
mMenuItemOptions,
|
||||||
mHomeAssistantService
|
mHomeAssistantService
|
||||||
|
@ -27,7 +27,7 @@ class HomeAssistantService {
|
|||||||
private var mHasToast as Lang.Boolean = false;
|
private var mHasToast as Lang.Boolean = false;
|
||||||
private var mHasVibrate as Lang.Boolean = false;
|
private var mHasVibrate as Lang.Boolean = false;
|
||||||
|
|
||||||
function initialise() {
|
function initialize() {
|
||||||
if (WatchUi has :showToast) {
|
if (WatchUi has :showToast) {
|
||||||
mHasToast = true;
|
mHasToast = true;
|
||||||
}
|
}
|
||||||
@ -38,7 +38,11 @@ class HomeAssistantService {
|
|||||||
|
|
||||||
// Callback function after completing the POST request to call a service.
|
// Callback function after completing the POST request to call a service.
|
||||||
//
|
//
|
||||||
function onReturnCall(responseCode as Lang.Number, data as Null or Lang.Dictionary or Lang.String, context as Lang.Object) as Void {
|
function onReturnCall(
|
||||||
|
responseCode as Lang.Number,
|
||||||
|
data as Null or Lang.Dictionary or Lang.String,
|
||||||
|
context as Lang.Object
|
||||||
|
) as Void {
|
||||||
var identifier = context as Lang.String;
|
var identifier = context as Lang.String;
|
||||||
if (Globals.scDebug) {
|
if (Globals.scDebug) {
|
||||||
System.println("HomeAssistantService onReturnCall() Response Code: " + responseCode);
|
System.println("HomeAssistantService onReturnCall() Response Code: " + responseCode);
|
||||||
@ -120,7 +124,11 @@ class HomeAssistantService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function call(identifier as Lang.String, service as Lang.String) as Void {
|
function call(
|
||||||
|
identifier as Lang.String,
|
||||||
|
service as Lang.String,
|
||||||
|
data as Lang.Dictionary or Null
|
||||||
|
) as Void {
|
||||||
if (! System.getDeviceSettings().phoneConnected) {
|
if (! System.getDeviceSettings().phoneConnected) {
|
||||||
if (Globals.scDebug) {
|
if (Globals.scDebug) {
|
||||||
System.println("HomeAssistantService call(): No Phone connection, skipping API call.");
|
System.println("HomeAssistantService call(): No Phone connection, skipping API call.");
|
||||||
@ -140,9 +148,7 @@ class HomeAssistantService {
|
|||||||
}
|
}
|
||||||
Communications.makeWebRequest(
|
Communications.makeWebRequest(
|
||||||
url,
|
url,
|
||||||
{
|
data, // Includes {"entity_id": identifier}
|
||||||
"entity_id" => identifier
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
:method => Communications.HTTP_REQUEST_METHOD_POST,
|
:method => Communications.HTTP_REQUEST_METHOD_POST,
|
||||||
:headers => {
|
:headers => {
|
||||||
|
@ -26,11 +26,12 @@ using Toybox.Lang;
|
|||||||
using Toybox.WatchUi;
|
using Toybox.WatchUi;
|
||||||
using Toybox.Graphics;
|
using Toybox.Graphics;
|
||||||
|
|
||||||
class HomeAssistantTemplateMenuItem extends WatchUi.MenuItem {
|
class HomeAssistantTemplateMenuItem extends WatchUi.IconMenuItem {
|
||||||
private var mHomeAssistantService as HomeAssistantService;
|
private var mHomeAssistantService as HomeAssistantService;
|
||||||
private var mTemplate as Lang.String;
|
private var mTemplate as Lang.String;
|
||||||
private var mService as Lang.String or Null;
|
private var mService as Lang.String or Null;
|
||||||
private var mConfirm as Lang.Boolean;
|
private var mConfirm as Lang.Boolean;
|
||||||
|
private var mData as Lang.Dictionary or Null;
|
||||||
|
|
||||||
function initialize(
|
function initialize(
|
||||||
label as Lang.String or Lang.Symbol,
|
label as Lang.String or Lang.Symbol,
|
||||||
@ -38,16 +39,18 @@ class HomeAssistantTemplateMenuItem extends WatchUi.MenuItem {
|
|||||||
template as Lang.String,
|
template as Lang.String,
|
||||||
service as Lang.String or Null,
|
service as Lang.String or Null,
|
||||||
confirm as Lang.Boolean,
|
confirm as Lang.Boolean,
|
||||||
|
data as Lang.Dictionary or Null,
|
||||||
|
icon as Graphics.BitmapType or WatchUi.Drawable,
|
||||||
options as {
|
options as {
|
||||||
:alignment as WatchUi.MenuItem.Alignment,
|
:alignment as WatchUi.MenuItem.Alignment,
|
||||||
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol
|
|
||||||
} or Null,
|
} or Null,
|
||||||
haService as HomeAssistantService
|
haService as HomeAssistantService
|
||||||
) {
|
) {
|
||||||
WatchUi.MenuItem.initialize(
|
WatchUi.IconMenuItem.initialize(
|
||||||
label,
|
label,
|
||||||
null,
|
null,
|
||||||
identifier,
|
identifier,
|
||||||
|
icon,
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -55,6 +58,12 @@ class HomeAssistantTemplateMenuItem extends WatchUi.MenuItem {
|
|||||||
mTemplate = template;
|
mTemplate = template;
|
||||||
mService = service;
|
mService = service;
|
||||||
mConfirm = confirm;
|
mConfirm = confirm;
|
||||||
|
mData = data;
|
||||||
|
if (mData == null) {
|
||||||
|
mData = {"entity_id" => identifier};
|
||||||
|
} else {
|
||||||
|
mData.put("entity_id", identifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function callService() as Void {
|
function callService() as Void {
|
||||||
@ -71,7 +80,7 @@ class HomeAssistantTemplateMenuItem extends WatchUi.MenuItem {
|
|||||||
|
|
||||||
function onConfirm() as Void {
|
function onConfirm() as Void {
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
mHomeAssistantService.call(mIdentifier as Lang.String, mService);
|
mHomeAssistantService.call(mIdentifier as Lang.String, mService, mData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,11 +51,13 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
var content = items[i].get("content") as Lang.String or Null;
|
var content = items[i].get("content") as Lang.String or Null;
|
||||||
var entity = items[i].get("entity") as Lang.String or Null;
|
var entity = items[i].get("entity") as Lang.String or Null;
|
||||||
var tap_action = items[i].get("tap_action") as Lang.Dictionary or Null;
|
var tap_action = items[i].get("tap_action") as Lang.Dictionary or Null;
|
||||||
var service = items[i].get("service") as Lang.String or Null;
|
var service = items[i].get("service") as Lang.String or Null; // Deprecated schema
|
||||||
var confirm = false as Lang.Boolean;
|
var confirm = false as Lang.Boolean or Null;
|
||||||
|
var data = null as Lang.Dictionary or Null;
|
||||||
if (tap_action != null) {
|
if (tap_action != null) {
|
||||||
service = tap_action.get("service");
|
service = tap_action.get("service");
|
||||||
confirm = tap_action.get("confirm");
|
confirm = tap_action.get("confirm"); // Optional
|
||||||
|
data = tap_action.get("data"); // Optional
|
||||||
if (confirm == null) {
|
if (confirm == null) {
|
||||||
confirm = false;
|
confirm = false;
|
||||||
}
|
}
|
||||||
@ -64,9 +66,14 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
if (type.equals("toggle") && entity != null) {
|
if (type.equals("toggle") && entity != null) {
|
||||||
addItem(HomeAssistantMenuItemFactory.create().toggle(name, entity));
|
addItem(HomeAssistantMenuItemFactory.create().toggle(name, entity));
|
||||||
} else if (type.equals("template") && content != null) {
|
} else if (type.equals("template") && content != null) {
|
||||||
addItem(HomeAssistantMenuItemFactory.create().template(name, entity, content, service, confirm));
|
if (tap_action == null) {
|
||||||
|
addItem(HomeAssistantMenuItemFactory.create().template_notap(name, entity, content, service, confirm, data));
|
||||||
|
} else {
|
||||||
|
addItem(HomeAssistantMenuItemFactory.create().template_tap(name, entity, content, service, confirm, data));
|
||||||
|
}
|
||||||
|
|
||||||
} else if (type.equals("tap") && entity != null && service != null) {
|
} else if (type.equals("tap") && entity != null && service != null) {
|
||||||
addItem(HomeAssistantMenuItemFactory.create().tap(name, entity, service, confirm));
|
addItem(HomeAssistantMenuItemFactory.create().tap(name, entity, service, confirm, data));
|
||||||
} else if (type.equals("group")) {
|
} else if (type.equals("group")) {
|
||||||
addItem(HomeAssistantMenuItemFactory.create().group(items[i]));
|
addItem(HomeAssistantMenuItemFactory.create().group(items[i]));
|
||||||
}
|
}
|
||||||
|