From 9884293ba4ceeeb87a647d8c3b450cb595bf9106 Mon Sep 17 00:00:00 2001 From: Andrew Jackson Date: Tue, 12 Dec 2023 14:00:31 +0000 Subject: [PATCH] Test json validate --- .github/workflows/json_validate.yml | 1 + .../battery_notes/data/library.json | 1 + schema.json | 18 ++++++++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/json_validate.yml b/.github/workflows/json_validate.yml index ef4fa18d6..d60c042ea 100644 --- a/.github/workflows/json_validate.yml +++ b/.github/workflows/json_validate.yml @@ -1,6 +1,7 @@ name: Validate JSONs on: + workflow_dispatch: push: paths: - 'custom_components/battery_notes/data/**' diff --git a/custom_components/battery_notes/data/library.json b/custom_components/battery_notes/data/library.json index 6c3625993..81854ee19 100644 --- a/custom_components/battery_notes/data/library.json +++ b/custom_components/battery_notes/data/library.json @@ -1,4 +1,5 @@ { + "$schema": "../../../schema.json", "version": 1, "devices": [ { diff --git a/schema.json b/schema.json index 076de0064..f7e79e064 100644 --- a/schema.json +++ b/schema.json @@ -5,6 +5,10 @@ "description": "Library of battery types for devices", "type": "object", "properties": { + "$schema": { + "description": "Schema reference", + "type": "string" + }, "version": { "description": "Version of the library schema", "type": "integer" @@ -21,16 +25,21 @@ ], "properties": { "manufacturer": { - "type": "string" + "type": "string", + "description": "The manufacturer of the device as it appears in Home Assistant." }, "model": { - "type": "string" + "type": "string", + "description": "The model of the device as it appears in Home Assistant." }, "battery_type": { - "type": "string" + "type": "string", + "description": "The type of battery for the device. Should be the most common naming for general batteries, and the IEC naming for battery cells according to Wikipedia." }, "battery_quantity": { - "type": "integer" + "type": "integer", + "exclusiveMinimum": 1, + "description": "The number of batteries required by the device. If a device only has one battery this property should be omitted." } } } @@ -38,6 +47,7 @@ }, "additionalProperties": false, "required": [ + "$schema", "version", "devices" ]