From bc5a7d04e468fd3ddc9af25b5f71aa70df2a9590 Mon Sep 17 00:00:00 2001 From: Joseph Abbey Date: Sun, 2 Nov 2025 13:14:48 +0000 Subject: [PATCH] Schema fixes and move "exit" into "tap_action" --- config.schema.json | 91 +++++++++++++++++++++++-------------- source/HomeAssistantView.mc | 5 +- 2 files changed, 61 insertions(+), 35 deletions(-) diff --git a/config.schema.json b/config.schema.json index 1677862..5bf4c70 100644 --- a/config.schema.json +++ b/config.schema.json @@ -47,7 +47,8 @@ "$ref": "#/$defs/enabled" }, "exit": { - "$ref": "#/$defs/exit" + "$ref": "#/$defs/exit", + "deprecated": true } }, "required": [ @@ -58,6 +59,7 @@ "additionalProperties": false }, "template": { + "deprecated": true, "oneOf": [ { "type": "object", @@ -118,7 +120,8 @@ "$ref": "#/$defs/enabled" }, "exit": { - "$ref": "#/$defs/exit" + "$ref": "#/$defs/exit", + "deprecated": true } }, "required": [ @@ -184,7 +187,8 @@ "$ref": "#/$defs/enabled" }, "exit": { - "$ref": "#/$defs/exit" + "$ref": "#/$defs/exit", + "deprecated": true } }, "required": [ @@ -922,9 +926,51 @@ "title": "Home Assistant action name", "pattern": "^[^.]+\\.[^.]+$" }, + "tap_action_tap": { + "allOf": [ + { + "title": "Tap Action", + "description": "'confirm' and 'pin' fields are optional. 'action' is required.", + "properties": { + "service": { + "$ref": "#/$defs/action", + "deprecated": true + }, + "action": { + "$ref": "#/$defs/action" + }, + "data": { + "type": "object", + "title": "Your actions's parameters", + "description": "The object containing the parameters and their values to be passed to the entity. No schema checking can be done here, you are on your own! On application crash, remove the parameters." + } + }, + "oneOf": [ + { + "required": [ + "action" + ], + "not": { + "required": [ + "service" + ] + } + }, + { + "required": [ + "service" + ] + } + ] + }, + { + "$ref": "#/$defs/tap_action" + } + ] + }, "tap_action": { "type": "object", - "title": "Action", + "title": "Tap Action", "description": "'confirm' and 'pin' fields are optional.", "properties": { "confirm": { @@ -932,45 +978,22 @@ }, "pin": { "$ref": "#/$defs/pin" + }, + "exit": { + "$ref": "#/$defs/exit" } } }, - "tap_action_tap": { - "$ref": "#/$defs/tap_action", - "properties": { - "service": { - "$ref": "#/$defs/action", - "deprecated": true - }, - "action": { - "$ref": "#/$defs/action" - }, - "data": { - "type": "object", - "title": "Your actions's parameters", - "description": "The object containing the parameters and their values to be passed to the entity. No schema checking can be done here, you are on your own! On application crash, remove the parameters." - }, - "anyOf": [ - { - "required": [ - "service" - ] - }, - { - "required": [ - "action" - ] - } - ] - } - }, "content": { "title": "Home Assistant Template", "description": "Jinja2 template defining the text to display. Must be included in an 'info'. Optional in a 'toggle', 'tap' and 'group'. Special characters may not render in the glance context.", "type": "string" }, "confirm": { - "type": ["boolean", "string"], + "type": [ + "boolean", + "string" + ], "default": false, "title": "Confirmation", "description": "Optional confirmation of the action before execution as a precaution. Use a Boolean for the default message. Specify a string to display a specific confirmation message." diff --git a/source/HomeAssistantView.mc b/source/HomeAssistantView.mc index ced9146..03544d7 100644 --- a/source/HomeAssistantView.mc +++ b/source/HomeAssistantView.mc @@ -57,7 +57,7 @@ class HomeAssistantView extends WatchUi.Menu2 { enabled = items[i].get("enabled"); // Optional } if (items[i].get("exit") != null) { - exit = items[i].get("exit"); // Optional + exit = items[i].get("exit"); // Deprecated } if (tap_action != null) { action = tap_action.get("service"); // Deprecated @@ -71,6 +71,9 @@ class HomeAssistantView extends WatchUi.Menu2 { if (tap_action.get("pin") != null) { pin = tap_action.get("pin"); // Optional } + if (tap_action.get("exit") != null) { + exit = tap_action.get("exit"); // Optional + } } if (type != null && name != null && enabled) { if (type.equals("toggle") && entity != null) {