Files
GarminHomeAssistant/config.schema.json
Philip Abbey a5ddb65512 Suggested code changes from philipabbey
1. attribute is option, so needs a different template in the API call when absent.
2. Automatically derive the format string from the picker step value for any precision of step.
3. Changed all Lang.String representations of numbers to Lang.Number or Lang.Float. I'm keen to remove the use of strings to hold a numeric value.
4. Tidied up and completed some code comments.
5. Adjusted the JSON schema definition. This is still not finished as the 'picker' object is required for 'numeric' menu items and must not be present for the others. Additional schema changes are required for greater precision.
6. Moved fields over from 'data' to 'picker'.
2025-10-29 14:26:02 +00:00

894 lines
25 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"properties": {
"$schema": {
"type": "string",
"description": "The schema will prevent JSON file errors."
},
"title": {
"type": "string",
"description": "Top level menu title"
},
"glance": {
"$ref": "#/$defs/glance"
},
"items": {
"$ref": "#/$defs/items"
}
},
"required": [
"title",
"items"
],
"additionalProperties": false,
"$defs": {
"toggle": {
"type": "object",
"properties": {
"entity": {
"$ref": "#/$defs/entity"
},
"name": {
"$ref": "#/$defs/name"
},
"type": {
"$ref": "#/$defs/type",
"const": "toggle"
},
"content": {
"$ref": "#/$defs/content"
},
"tap_action": {
"$ref": "#/$defs/tap_action",
"additionalProperties": false
},
"enabled": {
"$ref": "#/$defs/enabled"
},
"exit": {
"$ref": "#/$defs/exit"
}
},
"required": [
"entity",
"name",
"type"
],
"additionalProperties": false
},
"template": {
"oneOf": [
{
"type": "object",
"properties": {
"entity": {
"$ref": "#/$defs/entity",
"deprecated": true,
"title": "Schema change:",
"description": "Use 'tap_action' instead to mirror Home Assistant."
},
"name": {
"$ref": "#/$defs/name"
},
"content": {
"$ref": "#/$defs/content"
},
"type": {
"$ref": "#/$defs/type",
"const": "template",
"deprecated": true,
"title": "Schema change:",
"description": "Use 'info' or 'tap' instead."
},
"enabled": {
"$ref": "#/$defs/enabled"
}
},
"required": [
"name",
"content",
"type"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"entity": {
"$ref": "#/$defs/entity"
},
"name": {
"$ref": "#/$defs/name"
},
"content": {
"$ref": "#/$defs/content"
},
"type": {
"$ref": "#/$defs/type",
"const": "template",
"deprecated": true,
"title": "Schema change:",
"description": "Use 'info' or 'tap' instead."
},
"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": {
"$ref": "#/$defs/enabled"
},
"exit": {
"$ref": "#/$defs/exit"
}
},
"required": [
"name",
"content",
"type",
"tap_action"
],
"additionalProperties": false
}
]
},
"info": {
"type": "object",
"properties": {
"name": {
"$ref": "#/$defs/name"
},
"content": {
"$ref": "#/$defs/content"
},
"type": {
"$ref": "#/$defs/type",
"const": "info"
},
"enabled": {
"$ref": "#/$defs/enabled"
}
},
"required": [
"name",
"content",
"type"
],
"additionalProperties": false
},
"tap": {
"type": "object",
"properties": {
"entity": {
"$ref": "#/$defs/entity"
},
"name": {
"$ref": "#/$defs/name"
},
"type": {
"$ref": "#/$defs/type",
"const": "tap"
},
"content": {
"$ref": "#/$defs/content"
},
"service": {
"$ref": "#/$defs/service",
"deprecated": true,
"title": "Schema change:",
"description": "Use 'tap_action' instead to mirror Home Assistant."
},
"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": {
"$ref": "#/$defs/enabled"
},
"exit": {
"$ref": "#/$defs/exit"
}
},
"required": [
"name",
"type"
],
"additionalProperties": false
},
"group": {
"type": "object",
"properties": {
"entity": {
"$ref": "#/$defs/entity",
"type": "string",
"deprecated": true,
"title": "Schema change:",
"description": "'entity' is no longer necessary and should now be removed."
},
"name": {
"title": "Menu item's familiar name.",
"type": "string"
},
"title": {
"title": "Sub menu's title once displayed.",
"type": "string"
},
"type": {
"$ref": "#/$defs/type",
"const": "group"
},
"content": {
"$ref": "#/$defs/content"
},
"items": {
"$ref": "#/$defs/items"
},
"enabled": {
"$ref": "#/$defs/enabled"
}
},
"required": [
"name",
"title",
"type",
"items"
],
"additionalProperties": false
},
"numeric": {
"type": "object",
"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"
},
"entity": {
"$ref": "#/$defs/entity"
}
},
"required": [
"name",
"type",
"entity"
],
"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"
},
"data_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"
},
"data_attribute": {
"const": "value"
}
},
"not": {
"required": [
"attribute"
]
}
},
"else": {
"if": {
"properties": {
"entity": {
"pattern": "^number\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "value"
},
"service": {
"const": "number.set_value"
},
"data_attribute": {
"const": "value"
}
},
"not": {
"required": [
"attribute"
]
}
},
"else": {
"if": {
"properties": {
"entity": {
"pattern": "^fan\\.[^.]+$"
}
}
},
"then": {
"properties": {
"attribute": {
"const": "percentage"
},
"service": {
"const": "fan.set_percentage"
},
"data_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"
},
"data_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"
},
"data_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"
},
"data_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"
},
"data_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"
},
"data_attribute": {
"const": "temperature"
}
}
}
}
}
}
}
}
}
}
}
}
]
},
"type": {
"title": "Menu item type",
"description": "One of 'info', 'tap', 'toggle' or 'group'."
},
"items": {
"type": "array",
"items": {
"examples": [
{
"type": "tap",
"name": "Example",
"tap_action": {
"service": "notify.notify",
"data": {
"message": "Example"
}
}
},
{
"type": "toggle",
"name": "Example",
"entity": "switch.example"
},
{
"type": "group",
"name": "Example",
"title": "Example",
"items": []
},
{
"type": "numeric",
"name": "Example",
"entity": "light.example",
"attribute": "brightness",
"service": "light.turn_on",
"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
},
{
"type": "numeric",
"name": "Example",
"entity": "number.example",
"service": "number.set_value",
"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%%"
},
{
"type": "numeric",
"name": "Example",
"entity": "valve.example",
"attribute": "position",
"service": "valve.set_valve_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
},
{
"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
},
{
"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
},
{
"type": "numeric",
"name": "Example",
"entity": "climate.example",
"attribute": "temperature",
"service": "climate.set_temperature",
"data_attribute": "temperature"
}
],
"allOf": [
{
"properties": {
"type": {
"enum": [
"toggle",
"template",
"tap",
"info",
"group",
"numeric"
]
}
}
},
{
"if": {
"properties": {
"type": {
"const": "toggle"
}
}
},
"then": {
"$ref": "#/$defs/toggle"
},
"else": {
"if": {
"properties": {
"type": {
"const": "template"
}
}
},
"then": {
"$ref": "#/$defs/template"
},
"else": {
"if": {
"properties": {
"type": {
"const": "tap"
}
}
},
"then": {
"$ref": "#/$defs/tap"
},
"else": {
"if": {
"properties": {
"type": {
"const": "info"
}
}
},
"then": {
"$ref": "#/$defs/info"
},
"else": {
"if": {
"properties": {
"type": {
"const": "group"
}
}
},
"then": {
"$ref": "#/$defs/group"
},
"else": {
"if": {
"properties": {
"type": {
"const": "numeric"
}
}
},
"then": {
"$ref": "#/$defs/numeric"
}
}
}
}
}
}
}
]
}
},
"name": {
"title": "Your familiar name to display in the menu item",
"type": "string"
},
"entity": {
"type": "string",
"title": "Home Assistant entity name",
"pattern": "^[^.]+\\.[^.]+$"
},
"service": {
"type": "string",
"title": "Home Assistant service name",
"pattern": "^[^.]+\\.[^.]+$"
},
"tap_action": {
"type": "object",
"title": "Action",
"description": "'confirm' field is optional.",
"properties": {
"picker": {
"$ref": "#/$defs/picker"
},
"confirm": {
"$ref": "#/$defs/confirm"
},
"pin": {
"$ref": "#/$defs/pin"
}
}
},
"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.",
"type": "string"
},
"confirm": {
"type": "boolean",
"default": false,
"title": "Confirmation",
"description": "Optional confirmation of the action before execution as a precaution."
},
"pin": {
"type": "boolean",
"default": false,
"title": "PIN Confirmation",
"description": "Optional PIN confirmation of the action before execution as a precaution. Has precedence over 'confirm': true if both are set."
},
"glance": {
"type": "object",
"title": "Glance customisation",
"oneOf": [
{
"properties": {
"type": {
"title": "Glance type",
"description": "One of 'info' or 'status'. 'info' renders the template specified in the 'content' field inside the glance view. 'status' reverts to the default glance view and ignores the 'content' field. This allows for disabling the template temporarily.",
"const": "info"
},
"content": {
"$ref": "#/$defs/content"
}
},
"required": [
"type",
"content"
]
},
{
"properties": {
"type": {
"title": "Glance type",
"description": "One of 'info' or 'status'.",
"const": "status"
}
},
"required": [
"type"
]
}
]
},
"enabled": {
"type": "boolean",
"default": true,
"title": "Enable the menu item",
"description": "Typically used to temporarily disable a menu item, e.g. for seasonal variations. Enabled (true) by default."
},
"exit": {
"type": "boolean",
"default": false,
"title": "Exit on selection",
"description": "Choose to exit the application after this item has been selected. Disabled (false) by default. N.B. Only actionable menu items can have this field added."
}
}
}