diff --git a/config.schema.json b/config.schema.json index a696066..3357f69 100644 --- a/config.schema.json +++ b/config.schema.json @@ -275,7 +275,51 @@ "$ref": "#/$defs/content" }, "tap_action": { - "$ref": "#/$defs/tap_action" + "$ref": "#/$defs/tap_action", + "properties": { + "service": { + "$ref": "#/$defs/service" + }, + "picker": { + "type": "object", + "title": "Number picker configuration", + "description": "'attribute' field is optional.", + "properties": { + "min": { + "type": "number", + "title": "Minimum Value" + }, + "max": { + "type": "number", + "title": "Maximum Value" + }, + "step": { + "type": "number", + "title": "Step Size" + }, + "attribute": { + "type": "string", + "title": "Attribute on the entity", + "description": "Attribute on the entity with the current numeric value. To use the state of the entity, do not specify." + }, + "data_attribute": { + "type": "string", + "title": "Attribute on the service data", + "description": "Attribute on the service data for the value to set." + } + }, + "required": [ + "min", + "max", + "step", + "data_attribute" + ] + } + }, + "required": [ + "service", + "picker" + ] }, "enabled": { "$ref": "#/$defs/enabled" @@ -310,21 +354,29 @@ }, "then": { "properties": { - "attribute": { - "const": "brightness" - }, - "service": { - "const": "light.turn_on" - }, - "data_attribute": { - "const": "brightness" - }, - "min": { - "const": 0 - }, - "max": { - "const": 255, - "description": "Lights are not a percentage." + "tap_action": { + "properties": { + "service": { + "const": "light.turn_on" + }, + "picker": { + "properties": { + "attribute": { + "const": "brightness" + }, + "data_attribute": { + "const": "brightness" + }, + "min": { + "const": 0 + }, + "max": { + "const": 255, + "description": "Lights are not a percentage." + } + } + } + } } } }, @@ -338,20 +390,25 @@ }, "then": { "properties": { - "attribute": { - "const": "value" - }, - "service": { - "const": "input_number.set_value" - }, - "data_attribute": { - "const": "value" + "tap_action": { + "properties": { + "service": { + "const": "input_number.set_value" + }, + "picker": { + "properties": { + "data_attribute": { + "const": "value" + } + }, + "not": { + "required": [ + "attribute" + ] + } + } + } } - }, - "not": { - "required": [ - "attribute" - ] } }, "else": { @@ -364,20 +421,25 @@ }, "then": { "properties": { - "attribute": { - "const": "value" - }, - "service": { - "const": "number.set_value" - }, - "data_attribute": { - "const": "value" + "tap_action": { + "properties": { + "service": { + "const": "number.set_value" + }, + "picker": { + "properties": { + "data_attribute": { + "const": "value" + } + }, + "not": { + "required": [ + "attribute" + ] + } + } + } } - }, - "not": { - "required": [ - "attribute" - ] } }, "else": { @@ -390,20 +452,28 @@ }, "then": { "properties": { - "attribute": { - "const": "percentage" - }, - "service": { - "const": "fan.set_percentage" - }, - "data_attribute": { - "const": "percentage" - }, - "min": { - "const": 0 - }, - "max": { - "const": 100 + "tap_action": { + "properties": { + "service": { + "const": "fan.set_percentage" + }, + "picker": { + "properties": { + "attribute": { + "const": "percentage" + }, + "data_attribute": { + "const": "percentage" + }, + "min": { + "const": 0 + }, + "max": { + "const": 100 + } + } + } + } } } }, @@ -417,20 +487,28 @@ }, "then": { "properties": { - "attribute": { - "const": "position" - }, - "service": { - "const": "valve.set_valve_position" - }, - "data_attribute": { - "const": "position" - }, - "min": { - "const": 0 - }, - "max": { - "const": 100 + "tap_action": { + "properties": { + "service": { + "const": "valve.set_valve_position" + }, + "picker": { + "properties": { + "attribute": { + "const": "position" + }, + "data_attribute": { + "const": "position" + }, + "min": { + "const": 0 + }, + "max": { + "const": 100 + } + } + } + } } } }, @@ -443,48 +521,122 @@ } }, "then": { - "properties": { - "attribute": { - "const": "position" + "allOf": [ + { + "properties": { + "tap_action": { + "properties": { + "service": { + "enum": [ + "cover.set_position", + "cover.set_tilt_position" + ] + } + } + } + } }, - "service": { - "const": "cover.set_position" - }, - "data_attribute": { - "const": "position" - }, - "min": { - "const": 0 - }, - "max": { - "const": 100 + { + "if": { + "properties": { + "tap_action": { + "properties": { + "service": { + "const": "cover.set_tilt_position" + } + } + } + } + }, + "then": { + "properties": { + "tap_action": { + "properties": { + "service": { + "const": "cover.set_tilt_position" + }, + "picker": { + "properties": { + "attribute": { + "const": "tilt_position" + }, + "data_attribute": { + "const": "tilt_position" + }, + "min": { + "const": 0 + }, + "max": { + "const": 100 + } + } + } + } + } + } + }, + "else": { + "properties": { + "tap_action": { + "properties": { + "service": { + "const": "cover.set_position" + }, + "picker": { + "properties": { + "attribute": { + "const": "position" + }, + "data_attribute": { + "const": "position" + }, + "min": { + "const": 0 + }, + "max": { + "const": 100 + } + } + } + } + } + } + } } - } + ] }, "else": { "if": { "properties": { "entity": { - "pattern": "^cover\\.[^.]+$" + "pattern": "^media_player\\.[^.]+$" } } }, "then": { "properties": { - "attribute": { - "const": "tilt_position" - }, - "service": { - "const": "cover.set_tilt_position" - }, - "data_attribute": { - "const": "tilt_position" - }, - "min": { - "const": 0 - }, - "max": { - "const": 100 + "tap_action": { + "properties": { + "service": { + "const": "media_player.volume_set" + }, + "picker": { + "properties": { + "attribute": { + "const": "volume_level" + }, + "data_attribute": { + "const": "volume_level" + }, + "min": { + "const": 0 + }, + "max": { + "const": 1 + } + } + } + } } } }, @@ -492,47 +644,32 @@ "if": { "properties": { "entity": { - "pattern": "^media_player\\.[^.]+$" + "pattern": "^climate\\.[^.]+$" } } }, "then": { - "properties": { - "attribute": { - "const": "volume_level" - }, - "service": { - "const": "media_player.volume_set" - }, - "data_attribute": { - "const": "volume_level" - }, - "min": { - "const": 0 - }, - "max": { - "const": 1 - } - } - }, - "else": { - "if": { + "tap_action": { "properties": { - "entity": { - "pattern": "^climate\\.[^.]+$" - } - } - }, - "then": { - "properties": { - "attribute": { - "const": "temperature" - }, - "service": { - "const": "climate.set_temperature" - }, - "data_attribute": { - "const": "temperature" + "properties": { + "service": { + "const": "climate.set_temperature" + }, + "picker": { + "properties": { + "attribute": { + "const": "temperature" + }, + "data_attribute": { + "const": "temperature" + } + }, + "not": { + "required": [ + "attribute" + ] + } + } } } } @@ -580,96 +717,132 @@ "type": "numeric", "name": "Example", "entity": "light.example", - "attribute": "brightness", - "service": "light.turn_on", - "data_attribute": "brightness", - "min": 0, - "max": 255, - "step": 1 + "tap_action": { + "service": "light.turn_on", + "picker": { + "attribute": "brightness", + "data_attribute": "brightness", + "min": 0, + "max": 255, + "step": 1 + } + } }, { "type": "numeric", "name": "Example", "entity": "input_number.example", - "service": "input_number.set_value", - "data_attribute": "value", - "min": 0, - "max": 100, - "step": 1 + "tap_action": { + "service": "input_number.set_value", + "picker": { + "data_attribute": "value", + "min": 0, + "max": 100, + "step": 1 + } + } }, { "type": "numeric", "name": "Example", "entity": "number.example", - "service": "number.set_value", - "data_attribute": "value", - "min": 0, - "max": 100, - "step": 1 + "tap_action": { + "service": "number.set_value", + "picker": { + "data_attribute": "value", + "min": 0, + "max": 100, + "step": 1 + } + } }, { "type": "numeric", "name": "Example", "entity": "fan.example", - "attribute": "percentage", - "service": "fan.set_percentage", - "data_attribute": "percentage", - "min": 0, - "max": 100, - "step": 1, - "display_format": "%.0f%%" + "tap_action": { + "service": "fan.set_percentage", + "picker": { + "attribute": "percentage", + "data_attribute": "percentage", + "min": 0, + "max": 100, + "step": 1, + "display_format": "%.0f%%" + } + } }, { "type": "numeric", "name": "Example", "entity": "valve.example", - "attribute": "position", - "service": "valve.set_valve_position", - "data_attribute": "position", - "min": 0, - "max": 100, - "step": 1 + "tap_action": { + "service": "valve.set_valve_position", + "picker": { + "attribute": "position", + "data_attribute": "position", + "min": 0, + "max": 100, + "step": 1 + } + } }, { "type": "numeric", "name": "Example", "entity": "cover.example", - "attribute": "position", - "service": "cover.set_position", - "data_attribute": "position", - "min": 0, - "max": 100, - "step": 1 + "tap_action": { + "service": "cover.set_position", + "picker": { + "attribute": "position", + "data_attribute": "position", + "min": 0, + "max": 100, + "step": 1 + } + } }, { "type": "numeric", "name": "Example", "entity": "cover.example", - "attribute": "tilt_position", - "service": "cover.set_tilt_position", - "data_attribute": "tilt_position", - "min": 0, - "max": 100, - "step": 1 + "tap_action": { + "service": "cover.set_tilt_position", + "picker": { + "attribute": "tilt_position", + "data_attribute": "tilt_position", + "min": 0, + "max": 100, + "step": 1 + } + } }, { "type": "numeric", "name": "Example", "entity": "media_player.example", - "attribute": "volume_level", - "service": "media_player.volume_set", - "data_attribute": "volume_level", - "min": 0, - "max": 1, - "step": 0.01 + "tap_action": { + "service": "media_player.volume_set", + "picker": { + "attribute": "volume_level", + "data_attribute": "volume_level", + "min": 0, + "max": 1, + "step": 0.01 + } + } }, { "type": "numeric", "name": "Example", "entity": "climate.example", - "attribute": "temperature", - "service": "climate.set_temperature", - "data_attribute": "temperature" + "tap_action": { + "service": "climate.set_temperature", + "picker": { + "attribute": "temperature", + "data_attribute": "temperature" + } + } } ], "allOf": [ @@ -779,66 +952,16 @@ "tap_action": { "type": "object", "title": "Action", - "description": "'picker' field is required for 'numeric' menu type. 'confirm' and 'pin' fields are optional.", + "description": "'confirm' and 'pin' fields are optional.", "properties": { - "picker": { - "$ref": "#/$defs/picker" - }, "confirm": { "$ref": "#/$defs/confirm" }, "pin": { "$ref": "#/$defs/pin" } - }, - "if": { - "properties": { - "type": { - "const": "numeric" - } - } - }, - "then": { - "required": [ - "picker" - ] } }, - "picker": { - "type": "object", - "title": "Number picker configuration", - "description": "'attribute' field is optional.", - "properties": { - "min": { - "type": "number", - "title": "Minimum Value" - }, - "max": { - "type": "number", - "title": "Maximum Value" - }, - "step": { - "type": "number", - "title": "Step Size" - }, - "attribute": { - "type": "string", - "title": "Attribute on the entity", - "description": "Attribute on the entity with the current numeric value. To use the state of the entity, do not specify." - }, - "data_attribute": { - "type": "string", - "title": "Attribute on the service data", - "description": "Attribute on the service data for the value to set." - } - }, - "required": [ - "min", - "max", - "step", - "data_attribute" - ] - }, "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.",