Skip to content

Commit

Permalink
Add SGP30 custom properties and schema validation
Browse files Browse the repository at this point in the history
  • Loading branch information
tyeth committed Nov 5, 2024
1 parent b5b1f3b commit 00204b1
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
56 changes: 56 additions & 0 deletions components/i2c/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,62 @@
"description": "List of sensors on this I2C component.",
"type": "array",
"items": { "$ref": "#/$defs/subcomponent" }
},
"customProperties": {
"description": "A list of custom properties that this component supports.",
"type": "array",
"items": {
"type": "object",
"required": [ "name", "type", "description", "default", "displayed" ],
"properties": {
"name": {
"description": "The name and key of the custom property.",
"type": "string",
"minLength": 3,
"maxLength": 24
},
"type": {
"description": "The type of the custom property.",
"type": "string",
"pattern": "^(color|string|number|boolean|range|list)$"
},
"description": {
"description": "A brief description of the custom property.",
"type": "string",
"minLength": 3,
"maxLength": 255
},
"default": {
"description": "The default value of the custom property.",
"type": ["string", "number", "boolean"]
},
"displayed": {
"description": "If true, this custom property will be displayed in the UI.",
"type": "boolean"
},
"displayName": {
"description": "The human-friendly name of this custom property.",
"type": "string",
"minLength": 3,
"maxLength": 150
},
"displayOptions": {
"description": "Options or values for the custom property.",
"type": "object",
"optionalProperties": {
"min": { "type": "number" },
"max": { "type": "number" },
"step": { "type": "number" },
"values": {
"type": "array",
"items": {
"type": "object",
"required": [ "key", "displayText" ]
}
}
}
}
}
}
}
}
24 changes: 23 additions & 1 deletion components/i2c/sgp30/definition.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,27 @@
"documentationURL": "https://learn.adafruit.com/adafruit-sgp30-gas-tvoc-eco2-mox-sensor",
"published": true,
"i2cAddresses": [ "0x58" ],
"subcomponents": [ "eco2", "tvoc" ]
"subcomponents": [ "eco2", "tvoc" ],
"customProperties": [
{
"name": "input-temp",
"displayName": "Reference Ambient Temperature (°C)",
"type": "number",
"default": 20,
"description": "The reference ambient temperature in degrees Celsius.",
"displayed": true
},
{
"name": "input-humidity",
"displayName": "Reference Relative Humidity (%)",
"type": "number",
"default": 50,
"description": "The reference relative humidity in percent.",
"displayed": true,
"displayOptions": {
"min": 0,
"max": 100
}
}
]
}

0 comments on commit 00204b1

Please sign in to comment.