mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-09-16 21:51:33 +00:00
Compare commits
8 Commits
5639ff5c42
...
v2.31
Author | SHA1 | Date | |
---|---|---|---|
|
6db7b67536 | ||
|
e5df010af8 | ||
|
ee964ce882 | ||
|
ee9da24592 | ||
|
906cdf7371 | ||
|
7dd85937fa | ||
|
d141c03104 | ||
|
842a31a1cc |
@@ -43,3 +43,4 @@
|
|||||||
| 2.28 | Added support for Vivoactive 6 device which also required an SDK update to 8.1.0. |
|
| 2.28 | Added support for Vivoactive 6 device which also required an SDK update to 8.1.0. |
|
||||||
| 2.29 | Added support for three new devices, Forerunners 570 42mm & 47mm and 970. |
|
| 2.29 | Added support for three new devices, Forerunners 570 42mm & 47mm and 970. |
|
||||||
| 2.30 | <img src="images/Venu2_glance_default.png" width="200" title="Default Glance"/><br/>Extensive re-work of the [Glance](examples/Glance.md) view, including the ability to customise it with a user supplied template. |
|
| 2.30 | <img src="images/Venu2_glance_default.png" width="200" title="Default Glance"/><br/>Extensive re-work of the [Glance](examples/Glance.md) view, including the ability to customise it with a user supplied template. |
|
||||||
|
| 2.31 | Adding [two new options](./examples/Actions.md#exit-on-tap) to the menu items: 1) The ability to disable a menu item, e.g. temporarily for seasonal changes, 2) The option to exit after a menu item has been select. |
|
||||||
|
@@ -48,8 +48,8 @@
|
|||||||
},
|
},
|
||||||
"additionalProperties": false
|
"additionalProperties": false
|
||||||
},
|
},
|
||||||
"enable": {
|
"enabled": {
|
||||||
"$ref": "#/$defs/enable"
|
"$ref": "#/$defs/enabled"
|
||||||
},
|
},
|
||||||
"exit": {
|
"exit": {
|
||||||
"$ref": "#/$defs/exit"
|
"$ref": "#/$defs/exit"
|
||||||
@@ -82,8 +82,8 @@
|
|||||||
"title": "Schema change:",
|
"title": "Schema change:",
|
||||||
"description": "Use 'info' or 'tap' instead."
|
"description": "Use 'info' or 'tap' instead."
|
||||||
},
|
},
|
||||||
"enable": {
|
"enabled": {
|
||||||
"$ref": "#/$defs/enable"
|
"$ref": "#/$defs/enabled"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name", "content", "type"],
|
"required": ["name", "content", "type"],
|
||||||
@@ -111,8 +111,8 @@
|
|||||||
"tap_action": {
|
"tap_action": {
|
||||||
"$ref": "#/$defs/tap_action"
|
"$ref": "#/$defs/tap_action"
|
||||||
},
|
},
|
||||||
"enable": {
|
"enabled": {
|
||||||
"$ref": "#/$defs/enable"
|
"$ref": "#/$defs/enabled"
|
||||||
},
|
},
|
||||||
"exit": {
|
"exit": {
|
||||||
"$ref": "#/$defs/exit"
|
"$ref": "#/$defs/exit"
|
||||||
@@ -136,8 +136,8 @@
|
|||||||
"$ref": "#/$defs/type",
|
"$ref": "#/$defs/type",
|
||||||
"const": "info"
|
"const": "info"
|
||||||
},
|
},
|
||||||
"enable": {
|
"enabled": {
|
||||||
"$ref": "#/$defs/enable"
|
"$ref": "#/$defs/enabled"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name", "content", "type"],
|
"required": ["name", "content", "type"],
|
||||||
@@ -168,8 +168,8 @@
|
|||||||
"tap_action": {
|
"tap_action": {
|
||||||
"$ref": "#/$defs/tap_action"
|
"$ref": "#/$defs/tap_action"
|
||||||
},
|
},
|
||||||
"enable": {
|
"enabled": {
|
||||||
"$ref": "#/$defs/enable"
|
"$ref": "#/$defs/enabled"
|
||||||
},
|
},
|
||||||
"exit": {
|
"exit": {
|
||||||
"$ref": "#/$defs/exit"
|
"$ref": "#/$defs/exit"
|
||||||
@@ -206,8 +206,8 @@
|
|||||||
"items": {
|
"items": {
|
||||||
"$ref": "#/$defs/items"
|
"$ref": "#/$defs/items"
|
||||||
},
|
},
|
||||||
"enable": {
|
"enabled": {
|
||||||
"$ref": "#/$defs/enable"
|
"$ref": "#/$defs/enabled"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["name", "title", "type", "items"],
|
"required": ["name", "title", "type", "items"],
|
||||||
@@ -321,7 +321,7 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"enable": {
|
"enabled": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
"title": "Enable the menu item",
|
"title": "Enable the menu item",
|
||||||
|
@@ -70,25 +70,27 @@ class HomeAssistantMenuItemFactory {
|
|||||||
//! @param label Menu item label.
|
//! @param label Menu item label.
|
||||||
//! @param entity_id Home Assistant Entity ID (optional)
|
//! @param entity_id Home Assistant Entity ID (optional)
|
||||||
//! @param template Template for Home Assistant to render (optional)
|
//! @param template Template for Home Assistant to render (optional)
|
||||||
//! @param confirm Should this menu item selection be confirmed?
|
//! @param options Menu item options to be passed on, including both SDK and menu options, e.g. exit, confirm & pin.
|
||||||
//! @param pin Should this menu item selection request the security PIN?
|
|
||||||
//
|
//
|
||||||
function toggle(
|
function toggle(
|
||||||
label as Lang.String or Lang.Symbol,
|
label as Lang.String or Lang.Symbol,
|
||||||
entity_id as Lang.String or Null,
|
entity_id as Lang.String or Null,
|
||||||
template as Lang.String or Null,
|
template as Lang.String or Null,
|
||||||
exit as Lang.Boolean,
|
options as {
|
||||||
confirm as Lang.Boolean,
|
:exit as Lang.Boolean,
|
||||||
pin as Lang.Boolean
|
:confirm as Lang.Boolean,
|
||||||
|
:pin as Lang.Boolean
|
||||||
|
}
|
||||||
) as WatchUi.MenuItem {
|
) as WatchUi.MenuItem {
|
||||||
|
var keys = mMenuItemOptions.keys();
|
||||||
|
for (var i = 0; i < keys.size(); i++) {
|
||||||
|
options.put(keys[i], mMenuItemOptions.get(keys[i]));
|
||||||
|
}
|
||||||
return new HomeAssistantToggleMenuItem(
|
return new HomeAssistantToggleMenuItem(
|
||||||
label,
|
label,
|
||||||
template,
|
template,
|
||||||
{ "entity_id" => entity_id },
|
{ "entity_id" => entity_id },
|
||||||
exit,
|
options
|
||||||
confirm,
|
|
||||||
pin,
|
|
||||||
mMenuItemOptions
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,9 +100,8 @@ class HomeAssistantMenuItemFactory {
|
|||||||
//! @param entity_id Home Assistant Entity ID (optional)
|
//! @param entity_id Home Assistant Entity ID (optional)
|
||||||
//! @param template Template for Home Assistant to render (optional)
|
//! @param template Template for Home Assistant to render (optional)
|
||||||
//! @param service Template for Home Assistant to render (optional)
|
//! @param service Template for Home Assistant to render (optional)
|
||||||
//! @param confirm Should this menu item selection be confirmed?
|
|
||||||
//! @param pin Should this menu item selection request the security PIN?
|
|
||||||
//! @param data Sourced from the menu JSON, this is the `data` field from the `tap_action` field.
|
//! @param data Sourced from the menu JSON, this is the `data` field from the `tap_action` field.
|
||||||
|
//! @param options Menu item options to be passed on, including both SDK and menu options, e.g. exit, confirm & pin.
|
||||||
//
|
//
|
||||||
function tap(
|
function tap(
|
||||||
label as Lang.String or Lang.Symbol,
|
label as Lang.String or Lang.Symbol,
|
||||||
@@ -108,9 +109,11 @@ class HomeAssistantMenuItemFactory {
|
|||||||
template as Lang.String or Null,
|
template as Lang.String or Null,
|
||||||
service as Lang.String or Null,
|
service as Lang.String or Null,
|
||||||
data as Lang.Dictionary or Null,
|
data as Lang.Dictionary or Null,
|
||||||
exit as Lang.Boolean,
|
options as {
|
||||||
confirm as Lang.Boolean,
|
:exit as Lang.Boolean,
|
||||||
pin as Lang.Boolean
|
:confirm as Lang.Boolean,
|
||||||
|
:pin as Lang.Boolean
|
||||||
|
}
|
||||||
) as WatchUi.MenuItem {
|
) as WatchUi.MenuItem {
|
||||||
if (entity_id != null) {
|
if (entity_id != null) {
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
@@ -119,30 +122,28 @@ class HomeAssistantMenuItemFactory {
|
|||||||
data.put("entity_id", entity_id);
|
data.put("entity_id", entity_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var keys = mMenuItemOptions.keys();
|
||||||
|
for (var i = 0; i < keys.size(); i++) {
|
||||||
|
options.put(keys[i], mMenuItemOptions.get(keys[i]));
|
||||||
|
}
|
||||||
if (service != null) {
|
if (service != null) {
|
||||||
|
options.put(:icon, mTapTypeIcon);
|
||||||
return new HomeAssistantTapMenuItem(
|
return new HomeAssistantTapMenuItem(
|
||||||
label,
|
label,
|
||||||
template,
|
template,
|
||||||
service,
|
service,
|
||||||
data,
|
data,
|
||||||
exit,
|
options,
|
||||||
confirm,
|
|
||||||
pin,
|
|
||||||
mTapTypeIcon,
|
|
||||||
mMenuItemOptions,
|
|
||||||
mHomeAssistantService
|
mHomeAssistantService
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
options.put(:icon, mInfoTypeIcon);
|
||||||
return new HomeAssistantTapMenuItem(
|
return new HomeAssistantTapMenuItem(
|
||||||
label,
|
label,
|
||||||
template,
|
template,
|
||||||
service,
|
null,
|
||||||
data,
|
data,
|
||||||
exit,
|
options,
|
||||||
confirm,
|
|
||||||
pin,
|
|
||||||
mInfoTypeIcon,
|
|
||||||
mMenuItemOptions,
|
|
||||||
mHomeAssistantService
|
mHomeAssistantService
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -46,7 +46,13 @@ class HomeAssistantService {
|
|||||||
data as Null or Lang.Dictionary or Lang.String,
|
data as Null or Lang.Dictionary or Lang.String,
|
||||||
context as Lang.Object
|
context as Lang.Object
|
||||||
) as Void {
|
) as Void {
|
||||||
var entity_id = context as Lang.String or Null;
|
var c = context as Lang.Dictionary;
|
||||||
|
var entity_id;
|
||||||
|
var exit = false;
|
||||||
|
if (c != null) {
|
||||||
|
entity_id = c.get(:entity_id) as Lang.String;
|
||||||
|
exit = c.get(:exit) as Lang.Boolean;
|
||||||
|
}
|
||||||
// System.println("HomeAssistantService onReturnCall() Response Code: " + responseCode);
|
// System.println("HomeAssistantService onReturnCall() Response Code: " + responseCode);
|
||||||
// System.println("HomeAssistantService onReturnCall() Response Data: " + data);
|
// System.println("HomeAssistantService onReturnCall() Response Data: " + data);
|
||||||
|
|
||||||
@@ -102,6 +108,9 @@ class HomeAssistantService {
|
|||||||
:bgcolor => Graphics.COLOR_BLACK
|
:bgcolor => Graphics.COLOR_BLACK
|
||||||
}).pushView(WatchUi.SLIDE_IMMEDIATE);
|
}).pushView(WatchUi.SLIDE_IMMEDIATE);
|
||||||
}
|
}
|
||||||
|
if (exit) {
|
||||||
|
System.exit();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -117,7 +126,8 @@ class HomeAssistantService {
|
|||||||
//
|
//
|
||||||
function call(
|
function call(
|
||||||
service as Lang.String,
|
service as Lang.String,
|
||||||
data as Lang.Dictionary or Null
|
data as Lang.Dictionary or Null,
|
||||||
|
exit as Lang.Boolean
|
||||||
) as Void {
|
) as Void {
|
||||||
if (! System.getDeviceSettings().phoneConnected) {
|
if (! System.getDeviceSettings().phoneConnected) {
|
||||||
// System.println("HomeAssistantService call(): No Phone connection, skipping API call.");
|
// System.println("HomeAssistantService call(): No Phone connection, skipping API call.");
|
||||||
@@ -149,7 +159,10 @@ class HomeAssistantService {
|
|||||||
"Authorization" => "Bearer " + Settings.getApiKey()
|
"Authorization" => "Bearer " + Settings.getApiKey()
|
||||||
},
|
},
|
||||||
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON,
|
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON,
|
||||||
:context => entity_id
|
:context => {
|
||||||
|
:entity_id => entity_id,
|
||||||
|
:exit => exit
|
||||||
|
}
|
||||||
},
|
},
|
||||||
method(:onReturnCall)
|
method(:onReturnCall)
|
||||||
);
|
);
|
||||||
|
@@ -32,11 +32,12 @@ class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
|
|||||||
//! @param label Menu item label.
|
//! @param label Menu item label.
|
||||||
//! @param template Menu item template.
|
//! @param template Menu item template.
|
||||||
//! @param service Menu item service.
|
//! @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 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 pin Should the service call be protected with a PIN for some low level of security?
|
||||||
//! @param data Data to supply to the service call.
|
|
||||||
//! @param icon Icon to use for the menu item.
|
//! @param icon Icon to use for the menu item.
|
||||||
//! @param options Menu item options to be passed on.
|
//! @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
|
//! @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.
|
//! one of these objects is created for all menu items to re-use.
|
||||||
//
|
//
|
||||||
@@ -45,34 +46,30 @@ class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
|
|||||||
template as Lang.String,
|
template as Lang.String,
|
||||||
service as Lang.String or Null,
|
service as Lang.String or Null,
|
||||||
data as Lang.Dictionary or Null,
|
data as Lang.Dictionary or Null,
|
||||||
exit as Lang.Boolean,
|
|
||||||
confirm as Lang.Boolean,
|
|
||||||
pin as Lang.Boolean,
|
|
||||||
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
|
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol,
|
||||||
|
:exit as Lang.Boolean,
|
||||||
|
:confirm as Lang.Boolean,
|
||||||
|
:pin as Lang.Boolean
|
||||||
} or Null,
|
} or Null,
|
||||||
haService as HomeAssistantService
|
haService as HomeAssistantService
|
||||||
) {
|
) {
|
||||||
if (options != null) {
|
|
||||||
options.put(:icon, icon);
|
|
||||||
} else {
|
|
||||||
options = { :icon => icon };
|
|
||||||
}
|
|
||||||
|
|
||||||
HomeAssistantMenuItem.initialize(
|
HomeAssistantMenuItem.initialize(
|
||||||
label,
|
label,
|
||||||
template,
|
template,
|
||||||
options
|
{
|
||||||
|
:alignment => options.get(:alignment),
|
||||||
|
:icon => options.get(:icon)
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
mHomeAssistantService = haService;
|
mHomeAssistantService = haService;
|
||||||
mService = service;
|
mService = service;
|
||||||
mData = data;
|
mData = data;
|
||||||
mExit = exit;
|
mExit = options.get(:exit);
|
||||||
mConfirm = confirm;
|
mConfirm = options.get(:confirm);
|
||||||
mPin = pin;
|
mPin = options.get(:acospin);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Call a Home Assistant service only after checks have been done for confirmation or PIN entry.
|
//! Call a Home Assistant service only after checks have been done for confirmation or PIN entry.
|
||||||
@@ -106,10 +103,7 @@ class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
|
|||||||
//
|
//
|
||||||
function onConfirm(b as Lang.Boolean) as Void {
|
function onConfirm(b as Lang.Boolean) as Void {
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
mHomeAssistantService.call(mService, mData);
|
mHomeAssistantService.call(mService, mData, mExit);
|
||||||
}
|
|
||||||
if (mExit) {
|
|
||||||
System.exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -33,21 +33,19 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
|||||||
//!
|
//!
|
||||||
//! @param label Menu item label.
|
//! @param label Menu item label.
|
||||||
//! @param template Menu item template.
|
//! @param template Menu item template.
|
||||||
//! @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 data Data to supply to the service call.
|
//! @param data Data to supply to the service call.
|
||||||
//! @param options Menu item options to be passed on.
|
//! @param options Menu item options to be passed on, including both SDK and menu options, e.g. exit, confirm & pin.
|
||||||
//
|
//
|
||||||
function initialize(
|
function initialize(
|
||||||
label as Lang.String or Lang.Symbol,
|
label as Lang.String or Lang.Symbol,
|
||||||
template as Lang.String,
|
template as Lang.String,
|
||||||
data as Lang.Dictionary or Null,
|
data as Lang.Dictionary or Null,
|
||||||
exit as Lang.Boolean,
|
|
||||||
confirm as Lang.Boolean,
|
|
||||||
pin as Lang.Boolean,
|
|
||||||
options as {
|
options as {
|
||||||
:alignment as WatchUi.MenuItem.Alignment,
|
:alignment as WatchUi.MenuItem.Alignment,
|
||||||
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol
|
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol,
|
||||||
|
:exit as Lang.Boolean,
|
||||||
|
:confirm as Lang.Boolean,
|
||||||
|
:pin as Lang.Boolean
|
||||||
} or Null
|
} or Null
|
||||||
) {
|
) {
|
||||||
WatchUi.ToggleMenuItem.initialize(
|
WatchUi.ToggleMenuItem.initialize(
|
||||||
@@ -55,16 +53,19 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
|||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
false,
|
false,
|
||||||
options
|
{
|
||||||
|
:alignment => options.get(:alignment),
|
||||||
|
:icon => options.get(:icon)
|
||||||
|
}
|
||||||
);
|
);
|
||||||
if (Attention has :vibrate) {
|
if (Attention has :vibrate) {
|
||||||
mHasVibrate = true;
|
mHasVibrate = true;
|
||||||
}
|
}
|
||||||
mData = data;
|
mData = data;
|
||||||
mTemplate = template;
|
mTemplate = template;
|
||||||
mExit = exit;
|
mExit = options.get(:exit);
|
||||||
mConfirm = confirm;
|
mConfirm = options.get(:confirm);
|
||||||
mPin = pin;
|
mPin = options.get(:pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Set the state of a toggle menu item.
|
//! Set the state of a toggle menu item.
|
||||||
@@ -215,6 +216,9 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
|||||||
ErrorView.show(WatchUi.loadResource($.Rez.Strings.UnhandledHttpErr) as Lang.String + responseCode);
|
ErrorView.show(WatchUi.loadResource($.Rez.Strings.UnhandledHttpErr) as Lang.String + responseCode);
|
||||||
}
|
}
|
||||||
getApp().setApiStatus(status);
|
getApp().setApiStatus(status);
|
||||||
|
if (mExit) {
|
||||||
|
System.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Set the state of the toggle menu item.
|
//! Set the state of the toggle menu item.
|
||||||
@@ -297,9 +301,6 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
|||||||
//
|
//
|
||||||
function onConfirm(b as Lang.Boolean) as Void {
|
function onConfirm(b as Lang.Boolean) as Void {
|
||||||
setState(b);
|
setState(b);
|
||||||
if (mExit) {
|
|
||||||
System.exit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -51,10 +51,10 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
var confirm = false as Lang.Boolean or Null;
|
var confirm = false as Lang.Boolean or Null;
|
||||||
var pin = false as Lang.Boolean or Null;
|
var pin = false as Lang.Boolean or Null;
|
||||||
var data = null as Lang.Dictionary or Null;
|
var data = null as Lang.Dictionary or Null;
|
||||||
var enable = true as Lang.Boolean or Null;
|
var enabled = true as Lang.Boolean or Null;
|
||||||
var exit = false as Lang.Boolean or Null;
|
var exit = false as Lang.Boolean or Null;
|
||||||
if (items[i].get("enable") != null) {
|
if (items[i].get("enabled") != null) {
|
||||||
enable = items[i].get("enable"); // Optional
|
enabled = items[i].get("enabled"); // Optional
|
||||||
}
|
}
|
||||||
if (items[i].get("exit") != null) {
|
if (items[i].get("exit") != null) {
|
||||||
exit = items[i].get("exit"); // Optional
|
exit = items[i].get("exit"); // Optional
|
||||||
@@ -69,24 +69,77 @@ class HomeAssistantView extends WatchUi.Menu2 {
|
|||||||
pin = tap_action.get("pin"); // Optional
|
pin = tap_action.get("pin"); // Optional
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type != null && name != null && enable) {
|
if (type != null && name != null && enabled) {
|
||||||
if (type.equals("toggle") && entity != null) {
|
if (type.equals("toggle") && entity != null) {
|
||||||
addItem(HomeAssistantMenuItemFactory.create().toggle(name, entity, content, exit, confirm, pin));
|
addItem(HomeAssistantMenuItemFactory.create().toggle(
|
||||||
|
name,
|
||||||
|
entity,
|
||||||
|
content,
|
||||||
|
{
|
||||||
|
:exit => exit,
|
||||||
|
:confirm => confirm,
|
||||||
|
:pin => pin
|
||||||
|
}
|
||||||
|
));
|
||||||
} else if (type.equals("tap") && service != null) {
|
} else if (type.equals("tap") && service != null) {
|
||||||
addItem(HomeAssistantMenuItemFactory.create().tap(name, entity, content, service, data, exit, confirm, pin));
|
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||||
|
name,
|
||||||
|
entity,
|
||||||
|
content,
|
||||||
|
service,
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
:exit => exit,
|
||||||
|
:confirm => confirm,
|
||||||
|
:pin => pin
|
||||||
|
}
|
||||||
|
));
|
||||||
} else if (type.equals("template") && content != null) {
|
} else if (type.equals("template") && content != null) {
|
||||||
// NB. "template" is deprecated in the schema and remains only for backward compatibility. All menu items can now use templates, so the replacement is "info".
|
// NB. "template" is deprecated in the schema and remains only for backward compatibility. All menu items can now use templates, so the replacement is "info".
|
||||||
// The exit option is dependent on the type of template.
|
// The exit option is dependent on the type of template.
|
||||||
if (tap_action == null) {
|
if (tap_action == null) {
|
||||||
// No exit from an information only item
|
// No exit from an information only item
|
||||||
addItem(HomeAssistantMenuItemFactory.create().tap(name, entity, content, service, data, false, confirm, pin));
|
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||||
|
name,
|
||||||
|
entity,
|
||||||
|
content,
|
||||||
|
service,
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
:exit => false,
|
||||||
|
:confirm => confirm,
|
||||||
|
:pin => pin
|
||||||
|
}
|
||||||
|
));
|
||||||
} else {
|
} else {
|
||||||
// You may exit from template item with a 'tap_action'.
|
// You may exit from template item with a 'tap_action'.
|
||||||
addItem(HomeAssistantMenuItemFactory.create().tap(name, entity, content, service, data, exit, confirm, pin));
|
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||||
|
name,
|
||||||
|
entity,
|
||||||
|
content,
|
||||||
|
service,
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
: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(name, entity, content, service, data, false, confirm, pin));
|
addItem(HomeAssistantMenuItemFactory.create().tap(
|
||||||
|
name,
|
||||||
|
entity,
|
||||||
|
content,
|
||||||
|
service,
|
||||||
|
data,
|
||||||
|
{
|
||||||
|
:exit => false,
|
||||||
|
:confirm => confirm,
|
||||||
|
:pin => pin
|
||||||
|
}
|
||||||
|
));
|
||||||
} else if (type.equals("group")) {
|
} else if (type.equals("group")) {
|
||||||
addItem(HomeAssistantMenuItemFactory.create().group(items[i], content));
|
addItem(HomeAssistantMenuItemFactory.create().group(items[i], content));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user