Update schema to support numeric items

This commit is contained in:
Joseph Abbey
2025-10-19 21:23:34 +01:00
parent edef4ef464
commit 4fbe4135b1

View File

@@ -17,11 +17,21 @@
"$ref": "#/$defs/items" "$ref": "#/$defs/items"
} }
}, },
"required": ["title", "items"], "required": [
"title",
"items"
],
"additionalProperties": false, "additionalProperties": false,
"$defs": { "$defs": {
"toggle": { "toggle": {
"type": "object", "type": "object",
"examples": [
{
"type": "toggle",
"name": "Example",
"entity": "switch.example"
}
],
"properties": { "properties": {
"entity": { "entity": {
"$ref": "#/$defs/entity" "$ref": "#/$defs/entity"
@@ -37,15 +47,7 @@
"$ref": "#/$defs/content" "$ref": "#/$defs/content"
}, },
"tap_action": { "tap_action": {
"type": "object", "$ref": "#/$defs/tap_action",
"properties": {
"confirm": {
"$ref": "#/$defs/confirm"
},
"pin": {
"$ref": "#/$defs/pin"
}
},
"additionalProperties": false "additionalProperties": false
}, },
"enabled": { "enabled": {
@@ -55,7 +57,11 @@
"$ref": "#/$defs/exit" "$ref": "#/$defs/exit"
} }
}, },
"required": ["entity", "name", "type"], "required": [
"entity",
"name",
"type"
],
"additionalProperties": false "additionalProperties": false
}, },
"template": { "template": {
@@ -86,7 +92,11 @@
"$ref": "#/$defs/enabled" "$ref": "#/$defs/enabled"
} }
}, },
"required": ["name", "content", "type"], "required": [
"name",
"content",
"type"
],
"additionalProperties": false "additionalProperties": false
}, },
{ {
@@ -109,7 +119,20 @@
"description": "Use 'info' or 'tap' instead." "description": "Use 'info' or 'tap' instead."
}, },
"tap_action": { "tap_action": {
"$ref": "#/$defs/tap_action" "$ref": "#/$defs/tap_action",
"properties": {
"service": {
"$ref": "#/$defs/service"
},
"data": {
"type": "object",
"title": "Your services'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."
}
},
"required": [
"service"
]
}, },
"enabled": { "enabled": {
"$ref": "#/$defs/enabled" "$ref": "#/$defs/enabled"
@@ -118,7 +141,12 @@
"$ref": "#/$defs/exit" "$ref": "#/$defs/exit"
} }
}, },
"required": ["name", "content", "type", "tap_action"], "required": [
"name",
"content",
"type",
"tap_action"
],
"additionalProperties": false "additionalProperties": false
} }
] ]
@@ -140,11 +168,27 @@
"$ref": "#/$defs/enabled" "$ref": "#/$defs/enabled"
} }
}, },
"required": ["name", "content", "type"], "required": [
"name",
"content",
"type"
],
"additionalProperties": false "additionalProperties": false
}, },
"tap": { "tap": {
"type": "object", "type": "object",
"examples": [
{
"type": "tap",
"name": "Example",
"tap_action": {
"service": "notify.notify",
"data": {
"message": "Example"
}
}
}
],
"properties": { "properties": {
"entity": { "entity": {
"$ref": "#/$defs/entity" "$ref": "#/$defs/entity"
@@ -160,13 +204,26 @@
"$ref": "#/$defs/content" "$ref": "#/$defs/content"
}, },
"service": { "service": {
"$ref": "#/$defs/entity", "$ref": "#/$defs/service",
"deprecated": true, "deprecated": true,
"title": "Schema change:", "title": "Schema change:",
"description": "Use 'tap_action' instead to mirror Home Assistant." "description": "Use 'tap_action' instead to mirror Home Assistant."
}, },
"tap_action": { "tap_action": {
"$ref": "#/$defs/tap_action" "$ref": "#/$defs/tap_action",
"properties": {
"service": {
"$ref": "#/$defs/service"
},
"data": {
"type": "object",
"title": "Your services'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."
}
},
"required": [
"service"
]
}, },
"enabled": { "enabled": {
"$ref": "#/$defs/enabled" "$ref": "#/$defs/enabled"
@@ -175,11 +232,22 @@
"$ref": "#/$defs/exit" "$ref": "#/$defs/exit"
} }
}, },
"required": ["name", "type"], "required": [
"name",
"type"
],
"additionalProperties": false "additionalProperties": false
}, },
"group": { "group": {
"type": "object", "type": "object",
"examples": [
{
"type": "group",
"name": "Example",
"title": "Example",
"items": []
}
],
"properties": { "properties": {
"entity": { "entity": {
"$ref": "#/$defs/entity", "$ref": "#/$defs/entity",
@@ -210,9 +278,435 @@
"$ref": "#/$defs/enabled" "$ref": "#/$defs/enabled"
} }
}, },
"required": ["name", "title", "type", "items"], "required": [
"name",
"title",
"type",
"items"
],
"additionalProperties": false "additionalProperties": false
}, },
"numeric": {
"type": "object",
"examples": [
{
"type": "numeric",
"name": "Example",
"entity": "light.example",
"attribute": "brightness",
"service": "light.turn_on",
"service_attribute": "brightness",
"min": 0,
"max": 255,
"step": 1
},
{
"type": "numeric",
"name": "Example",
"entity": "input_number.example",
"service": "input_number.set_value",
"service_attribute": "value",
"min": 0,
"max": 100,
"step": 1
},
{
"type": "numeric",
"name": "Example",
"entity": "number.example",
"service": "number.set_value",
"service_attribute": "value",
"min": 0,
"max": 100,
"step": 1
},
{
"type": "numeric",
"name": "Example",
"entity": "fan.example",
"attribute": "percentage",
"service": "fan.set_percentage",
"service_attribute": "percentage",
"min": 0,
"max": 100,
"step": 1
},
{
"type": "numeric",
"name": "Example",
"entity": "valve.example",
"attribute": "position",
"service": "valve.set_valve_position",
"service_attribute": "position",
"min": 0,
"max": 100,
"step": 1
},
{
"type": "numeric",
"name": "Example",
"entity": "cover.example",
"attribute": "position",
"service": "cover.set_position",
"service_attribute": "position",
"min": 0,
"max": 100,
"step": 1
},
{
"type": "numeric",
"name": "Example",
"entity": "cover.example",
"attribute": "tilt_position",
"service": "cover.set_tilt_position",
"service_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",
"service_attribute": "volume_level",
"min": 0,
"max": 1,
"step": 0.01
},
{
"type": "numeric",
"name": "Example",
"entity": "climate.example",
"attribute": "temperature",
"service": "climate.set_temperature",
"service_attribute": "temperature",
"min": 0,
"max": 100,
"step": 1
}
],
"allOf": [
{
"properties": {
"name": {
"$ref": "#/$defs/name"
},
"type": {
"$ref": "#/$defs/type",
"const": "numeric"
},
"content": {
"$ref": "#/$defs/content"
},
"tap_action": {
"$ref": "#/$defs/tap_action"
},
"enabled": {
"$ref": "#/$defs/enabled"
},
"exit": {
"$ref": "#/$defs/exit"
},
"min": {
"type": "number",
"title": "Minimum value"
},
"max": {
"type": "number",
"title": "Maximum value"
},
"step": {
"type": "number",
"title": "Step size"
},
"decimals": {
"type": "number",
"title": "Number of decimals to display",
"minimum": 0,
"maximum": 10,
"default": 1
},
"entity": {
"$ref": "#/$defs/entity"
},
"attribute": {
"type": "string",
"title": "Attribute on the entity with the current numeric value. To use the state of the entity, do not specify."
},
"service": {
"$ref": "#/$defs/service"
},
"service_attribute": {
"type": "string",
"title": "Attribute on the service data for the value to set."
}
},
"required": [
"name",
"type",
"min",
"max",
"step",
"entity",
"service",
"service_attribute"
],
"additionalProperties": false
},
{
"properties": {
"entity": {
"pattern": "^(light|input_number|number|fan|valve|cover|media_player|climate)\\.[^.]+$"
}
},
"if": {
"properties": {
"entity": {
"pattern": "^light\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "brightness"
},
"service": {
"const": "light.turn_on"
},
"service_attribute": {
"const": "brightness"
},
"min": {
"const": 0
},
"max": {
"const": 255,
"description": "Lights are not a percentage."
}
}
},
"else": {
"if": {
"properties": {
"entity": {
"pattern": "^input_number\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "value"
},
"service": {
"const": "input_number.set_value"
},
"service_attribute": {
"const": "value"
}
},
"not": {
"required": [
"attribute"
]
}
},
"else": {
"if": {
"properties": {
"entity": {
"pattern": "^number\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "value"
},
"service": {
"const": "number.set_value"
},
"service_attribute": {
"const": "value"
}
},
"not": {
"required": [
"attribute"
]
}
},
"else": {
"if": {
"properties": {
"entity": {
"pattern": "^fan\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "percentage"
},
"service": {
"const": "fan.set_percentage"
},
"service_attribute": {
"const": "percentage"
},
"min": {
"const": 0
},
"max": {
"const": 100
}
}
},
"else": {
"if": {
"properties": {
"entity": {
"pattern": "^valve\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "position"
},
"service": {
"const": "valve.set_valve_position"
},
"service_attribute": {
"const": "position"
},
"min": {
"const": 0
},
"max": {
"const": 100
}
}
},
"else": {
"if": {
"properties": {
"entity": {
"pattern": "^cover\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "position"
},
"service": {
"const": "cover.set_position"
},
"service_attribute": {
"const": "position"
},
"min": {
"const": 0
},
"max": {
"const": 100
}
}
},
"else": {
"if": {
"properties": {
"entity": {
"pattern": "^cover\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "tilt_position"
},
"service": {
"const": "cover.set_tilt_position"
},
"service_attribute": {
"const": "tilt_position"
},
"min": {
"const": 0
},
"max": {
"const": 100
}
}
},
"else": {
"if": {
"properties": {
"entity": {
"pattern": "^media_player\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "volume_level"
},
"service": {
"const": "media_player.volume_set"
},
"service_attribute": {
"const": "volume_level"
},
"min": {
"const": 0
},
"max": {
"const": 1
}
}
},
"else": {
"if": {
"properties": {
"entity": {
"pattern": "^climate\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "temperature"
},
"service": {
"const": "climate.set_temperature"
},
"service_attribute": {
"const": "temperature"
}
}
}
}
}
}
}
}
}
}
}
}
]
},
"type": { "type": {
"title": "Menu item type", "title": "Menu item type",
"description": "One of 'info', 'tap', 'toggle' or 'group'." "description": "One of 'info', 'tap', 'toggle' or 'group'."
@@ -235,6 +729,9 @@
}, },
{ {
"$ref": "#/$defs/group" "$ref": "#/$defs/group"
},
{
"$ref": "#/$defs/numeric"
} }
] ]
} }
@@ -258,22 +755,13 @@
"title": "Action", "title": "Action",
"description": "'confirm' field is optional.", "description": "'confirm' field is optional.",
"properties": { "properties": {
"service": {
"$ref": "#/$defs/service"
},
"confirm": { "confirm": {
"$ref": "#/$defs/confirm" "$ref": "#/$defs/confirm"
}, },
"pin": { "pin": {
"$ref": "#/$defs/pin" "$ref": "#/$defs/pin"
},
"data": {
"type": "object",
"title": "Your services'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."
} }
}, }
"required": ["service"]
}, },
"content": { "content": {
"title": "Home Assistant Template", "title": "Home Assistant Template",
@@ -307,7 +795,10 @@
"$ref": "#/$defs/content" "$ref": "#/$defs/content"
} }
}, },
"required": ["type", "content"] "required": [
"type",
"content"
]
}, },
{ {
"properties": { "properties": {
@@ -317,7 +808,9 @@
"const": "status" "const": "status"
} }
}, },
"required": ["type"] "required": [
"type"
]
} }
] ]
}, },