diff --git a/.github/workflows/json_validate.yml b/.github/workflows/json_validate.yml new file mode 100644 index 00000000..92b0401e --- /dev/null +++ b/.github/workflows/json_validate.yml @@ -0,0 +1,14 @@ +name: Validate JSONs + +on: [push, pull_request] + +jobs: + verify-json-validation: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Validate JSON + uses: docker://orrosenblatt/validate-json-action:latest + env: + INPUT_SCHEMA: ./schema.json + INPUT_JSONS: custom_components/battery_notes/data/library.json diff --git a/custom_components/battery_notes/data/library.json b/custom_components/battery_notes/data/library.json index 8d3f79c2..c83173d2 100644 --- a/custom_components/battery_notes/data/library.json +++ b/custom_components/battery_notes/data/library.json @@ -11,24 +11,24 @@ "model": "[Flower sensor](http://modkam.ru/?p=1700) (DIYRuZ_Flower)", "battery_type": "AAA", "battery_quantity": 2 - }, + }, { "manufacturer": "Fantem", "model": "4 in 1 multi sensor (ZB003-X)", "battery_type": "CR123A", "battery_quantity": 2 - }, + }, { "manufacturer": "GiEX", "model": "Water irrigation valve (QT06_2)", "battery_type": "AA", "battery_quantity": 4 - }, + }, { "manufacturer": "HEIMAN", "model": "Smart carbon monoxide sensor (HS1CA-E)", "battery_type": "CR123A" - }, + }, { "manufacturer": "OSRAM", "model": "Smart+ switch mini (AC0251100NJ/AC0251600NJ/AC0251700NJ)", @@ -70,24 +70,24 @@ "manufacturer": "SONOFF", "model": "Motion sensor (SNZB-03)", "battery_type": "CR2450" - }, + }, { "manufacturer": "Sonoff", "model": "Temperature and humidity sensor (SNZB-02)", "battery_type": "CR2430" - }, + }, { "manufacturer": "Sure Petcare", "model": "Pet flap", "battery_type": "C", "battery_quantity": 4 - }, + }, { "manufacturer": "SwitchBot", "model": "W340001X", "battery_type": "AAA", "battery_quantity": 2 - }, + }, { "manufacturer": "Tado", "model": "RU01", @@ -99,13 +99,13 @@ "model": "VA02", "battery_type": "AA", "battery_quantity": 2 - }, + }, { "manufacturer": "TT Lock", "model": "SN511-180MS_PV53", "battery_type": "AA", "battery_quantity": 4 - }, + }, { "manufacturer": "TuYa", "model": "Soil sensor (TS0601_soil)", @@ -153,12 +153,12 @@ "manufacturer": "Xiaomi", "model": "Aqara D1 double key wireless wall switch (WXKG07LM)", "battery_type": "CR2032" - }, + }, { "manufacturer": "Xiaomi", "model": "Aqara D1 single key wireless wall switch (WXKG06LM)", "battery_type": "CR2032" - }, + }, { "manufacturer": "Xiaomi", "model": "Aqara wireless switch (WXKG11LM)", @@ -169,7 +169,7 @@ "model": "Aqara TVOC air quality monitor (VOCKQJK11LM)", "battery_type": "CR2450", "battery_quantity": 2 - }, + }, { "manufacturer": "Xiaomi", "model": "Aqara water leak sensor (SJCGQ11LM)", @@ -184,16 +184,16 @@ "manufacturer": "Xiaomi", "model": "HHCCJCY01", "battery_type": "CR2032" - }, + }, { "manufacturer": "Xiaomi", "model": "LYWSD03MMC", "battery_type": "CR2032" - }, + }, { "manufacturer": "Xiaomi", "model": "MiJia wireless switch (WXKG01LM)", "battery_type": "CR2032" } ] -} +} \ No newline at end of file diff --git a/schema.json b/schema.json new file mode 100644 index 00000000..076de006 --- /dev/null +++ b/schema.json @@ -0,0 +1,44 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "$id": "https://github.com/andrew-codechimp/HA-Battery-Notes.schema.json", + "title": "Battery Notes Library", + "description": "Library of battery types for devices", + "type": "object", + "properties": { + "version": { + "description": "Version of the library schema", + "type": "integer" + }, + "devices": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "required": [ + "manufacturer", + "model", + "battery_type" + ], + "properties": { + "manufacturer": { + "type": "string" + }, + "model": { + "type": "string" + }, + "battery_type": { + "type": "string" + }, + "battery_quantity": { + "type": "integer" + } + } + } + } + }, + "additionalProperties": false, + "required": [ + "version", + "devices" + ] +} \ No newline at end of file