Skip to content

Commit

Permalink
model.json validation (#82)
Browse files Browse the repository at this point in the history
  • Loading branch information
bramstroker committed Aug 17, 2021
1 parent 9b438b6 commit 6c81e86
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/model-json-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
pull_request:
branches:
- master
paths:
- '**/model.json'
name: Validate model.json files
jobs:
validate_model_json:
name: Validate files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate model.json against schema
uses: snapcart/json-schema-validator@v1.0.0
with:
token: ${{ secrets.GH_API_TOKEN }}
json_schema: ./custom_components/powercalc/data/model_schema.json
json_path_pattern: .*model.json$
send_comment: true
clear_comments: true
64 changes: 64 additions & 0 deletions custom_components/powercalc/data/model_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"description": "model.json described a light model",
"type": "object",
"required": [
"name",
"standby_usage",
"supported_modes",
"measure_method",
"measure_device"
],
"properties": {
"name": {
"type": "string",
"description": "The full name"
},
"standby_usage": {
"type": "number",
"description": "Power draw when the light is turned of. When you are not able to measure set to 0.4"
},
"supported_modes": {
"type": "array",
"items": {
"type": "string",
"enum": ["lut", "linear", "fixed"]
},
"description": "Supported calculation modes"
},
"measure_method": {
"type": "string",
"enum": ["manual", "script"],
"description": "How the light was measured"
},
"measure_device": {
"type": "string",
"description": "Device which was used to measure"
},
"measure_description": {
"type": "string",
"description": "Add more information about how you measured the light or any remarks"
},
"linear_config": {
"type": "object",
"description": "Configuration for linear calculation mode",
"properties": {
"min_watt": {
"type": "number"
},
"max_watt": {
"type": "number"
}
}
},
"fixed_config": {
"type": "object",
"description": "Configuration for fixed calculation mode",
"properties": {
"watt": {
"type": "number"
}
}
}
}
}

0 comments on commit 6c81e86

Please sign in to comment.