Info only menu item

This commit is contained in:
Philip Abbey
2025-01-19 13:44:53 +00:00
parent 816f2e6399
commit fd58625640
2 changed files with 26 additions and 5 deletions

View File

@ -70,7 +70,7 @@
"const": "template",
"deprecated": true,
"title": "Schema change:",
"description": "Use 'tap' instead."
"description": "Use 'info' or 'tap' instead."
}
},
"required": ["name", "content", "type"],
@ -93,7 +93,7 @@
"const": "template",
"deprecated": true,
"title": "Schema change:",
"description": "Use 'tap' instead."
"description": "Use 'info' or 'tap' instead."
},
"tap_action": {
"$ref": "#/$defs/tap_action"
@ -104,6 +104,23 @@
}
]
},
"info": {
"type": "object",
"properties": {
"name": {
"$ref": "#/$defs/name"
},
"content": {
"$ref": "#/$defs/content"
},
"type": {
"$ref": "#/$defs/type",
"const": "info"
}
},
"required": ["name", "content", "type"],
"additionalProperties": false
},
"tap": {
"type": "object",
"properties": {
@ -169,7 +186,7 @@
},
"type": {
"title": "Menu item type",
"description": "One of 'tap', 'toggle' or 'group'."
"description": "One of 'info', 'tap', 'toggle' or 'group'."
},
"items": {
"type": "array",
@ -185,6 +202,9 @@
{
"$ref": "#/$defs/tap"
},
{
"$ref": "#/$defs/info"
},
{
"$ref": "#/$defs/group"
}
@ -192,7 +212,7 @@
}
},
"name": {
"title": "Your familiar name",
"title": "Your familiar name to display in the menu item",
"type": "string"
},
"entity": {

View File

@ -64,7 +64,8 @@ class HomeAssistantView extends WatchUi.Menu2 {
if (type != null && name != null) {
if (type.equals("toggle") && entity != null) {
addItem(HomeAssistantMenuItemFactory.create().toggle(name, entity, content, confirm, pin));
} else if ((type.equals("tap") && service != null) || (type.equals("template") && content != null)) {
} else if ((type.equals("tap") && service != null) || (type.equals("info") && content != null) || (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".
addItem(HomeAssistantMenuItemFactory.create().tap(name, entity, content, service, confirm, pin, data));
} else if (type.equals("group")) {
addItem(HomeAssistantMenuItemFactory.create().group(items[i], content));