Skip to content

Commit

Permalink
Update config schema
Browse files Browse the repository at this point in the history
  • Loading branch information
0x5e committed Dec 12, 2022
1 parent dd7946e commit c02d5df
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 22 deletions.
2 changes: 1 addition & 1 deletion ADVANCED_OPTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

- `options.deviceOverrides[].schema` - **optional**: An array of schema overriding config objects. When your device have non-standard schemas, this is used for transform them.
- `options.deviceOverrides[].schema[].oldCode` - **required**: Original Schema code.
- `options.deviceOverrides[].schema[].newCode` - **required**: New Schema code.
- `options.deviceOverrides[].schema[].code` - **required**: New Schema code.
- `options.deviceOverrides[].schema[].type` - **optional**: New schema type. One of the `Boolean`, `Integer`, `Enum`, `String`, `Json`, `Raw`.
- `options.deviceOverrides[].schema[].property` - **optional**: New schema property object. For `Integer` type, the object should contains `min`, `max`, `scale`, `step`; For `Enum` type, the object should contains `range`. For detail information, please see `TuyaDeviceSchemaProperty` in [TuyaDevice.ts](./src/device/TuyaDevice.ts).
- `options.deviceOverrides[].schema[].onGet` - **optional**: An one-line JavaScript code convert old value to new value. The function is called with one argument: `value`.
Expand Down
73 changes: 52 additions & 21 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,37 +101,68 @@
"type": "object",
"properties": {
"id": {
"name": "ID",
"title": "ID",
"description": "Device ID or Product ID or `global`",
"type": "string",
"required": true
},
"category": {
"name": "Category",
"title": "Category",
"description": "Category Code or `hidden`",
"type": "string"
},
"schema": {
"name": "Schema Overriding Configs",
"title": "Schema Overriding Configs",
"type": "array",
"properties": {
"oldCode": {
"title": "Original Schema Code",
"type": "string",
"required": true
},
"code": {
"title": "New Schema Code",
"type": "string",
"required": true
},
"type": {
"title": "New Schema Type",
"type": "string"
},
"property": {
"title": "New Schema Property",
"type": "object"
"items": {
"type": "object",
"properties": {
"oldCode": {
"title": "Original Schema Code",
"type": "string",
"required": true
},
"code": {
"title": "New Schema Code",
"type": "string",
"required": true
},
"type": {
"title": "New Schema Type",
"type": "string",
"default": "",
"oneOf": ["Boolean", "Integer", "Enum", "String", "Json", "Raw"]
},
"property": {
"title": "New Schema Property",
"type": "object",
"properties": {
"min": {
"title": "min",
"type": "integer"
},
"max": {
"title": "max",
"type": "integer"
},
"scale": {
"title": "scale",
"type": "integer"
},
"step": {
"title": "step",
"type": "integer"
},
"range": {
"title": "range",
"type": "array",
"items": {
"title": "value",
"type": "string"
}
}
}
}
}
}
}
Expand Down

0 comments on commit c02d5df

Please sign in to comment.