Skip to content

Commit 6c81e86

Browse files
authored
model.json validation (#82)
1 parent 9b438b6 commit 6c81e86

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
on:
2+
pull_request:
3+
branches:
4+
- master
5+
paths:
6+
- '**/model.json'
7+
name: Validate model.json files
8+
jobs:
9+
validate_model_json:
10+
name: Validate files
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Validate model.json against schema
15+
uses: snapcart/[email protected]
16+
with:
17+
token: ${{ secrets.GH_API_TOKEN }}
18+
json_schema: ./custom_components/powercalc/data/model_schema.json
19+
json_path_pattern: .*model.json$
20+
send_comment: true
21+
clear_comments: true
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"description": "model.json described a light model",
4+
"type": "object",
5+
"required": [
6+
"name",
7+
"standby_usage",
8+
"supported_modes",
9+
"measure_method",
10+
"measure_device"
11+
],
12+
"properties": {
13+
"name": {
14+
"type": "string",
15+
"description": "The full name"
16+
},
17+
"standby_usage": {
18+
"type": "number",
19+
"description": "Power draw when the light is turned of. When you are not able to measure set to 0.4"
20+
},
21+
"supported_modes": {
22+
"type": "array",
23+
"items": {
24+
"type": "string",
25+
"enum": ["lut", "linear", "fixed"]
26+
},
27+
"description": "Supported calculation modes"
28+
},
29+
"measure_method": {
30+
"type": "string",
31+
"enum": ["manual", "script"],
32+
"description": "How the light was measured"
33+
},
34+
"measure_device": {
35+
"type": "string",
36+
"description": "Device which was used to measure"
37+
},
38+
"measure_description": {
39+
"type": "string",
40+
"description": "Add more information about how you measured the light or any remarks"
41+
},
42+
"linear_config": {
43+
"type": "object",
44+
"description": "Configuration for linear calculation mode",
45+
"properties": {
46+
"min_watt": {
47+
"type": "number"
48+
},
49+
"max_watt": {
50+
"type": "number"
51+
}
52+
}
53+
},
54+
"fixed_config": {
55+
"type": "object",
56+
"description": "Configuration for fixed calculation mode",
57+
"properties": {
58+
"watt": {
59+
"type": "number"
60+
}
61+
}
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)