Skip to content

Commit 00204b1

Browse files
committed
Add SGP30 custom properties and schema validation
1 parent b5b1f3b commit 00204b1

File tree

2 files changed

+79
-1
lines changed

2 files changed

+79
-1
lines changed

components/i2c/schema.json

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,62 @@
8787
"description": "List of sensors on this I2C component.",
8888
"type": "array",
8989
"items": { "$ref": "#/$defs/subcomponent" }
90+
},
91+
"customProperties": {
92+
"description": "A list of custom properties that this component supports.",
93+
"type": "array",
94+
"items": {
95+
"type": "object",
96+
"required": [ "name", "type", "description", "default", "displayed" ],
97+
"properties": {
98+
"name": {
99+
"description": "The name and key of the custom property.",
100+
"type": "string",
101+
"minLength": 3,
102+
"maxLength": 24
103+
},
104+
"type": {
105+
"description": "The type of the custom property.",
106+
"type": "string",
107+
"pattern": "^(color|string|number|boolean|range|list)$"
108+
},
109+
"description": {
110+
"description": "A brief description of the custom property.",
111+
"type": "string",
112+
"minLength": 3,
113+
"maxLength": 255
114+
},
115+
"default": {
116+
"description": "The default value of the custom property.",
117+
"type": ["string", "number", "boolean"]
118+
},
119+
"displayed": {
120+
"description": "If true, this custom property will be displayed in the UI.",
121+
"type": "boolean"
122+
},
123+
"displayName": {
124+
"description": "The human-friendly name of this custom property.",
125+
"type": "string",
126+
"minLength": 3,
127+
"maxLength": 150
128+
},
129+
"displayOptions": {
130+
"description": "Options or values for the custom property.",
131+
"type": "object",
132+
"optionalProperties": {
133+
"min": { "type": "number" },
134+
"max": { "type": "number" },
135+
"step": { "type": "number" },
136+
"values": {
137+
"type": "array",
138+
"items": {
139+
"type": "object",
140+
"required": [ "key", "displayText" ]
141+
}
142+
}
143+
}
144+
}
145+
}
90146
}
91147
}
92148
}

components/i2c/sgp30/definition.json

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,27 @@
55
"documentationURL": "https://learn.adafruit.com/adafruit-sgp30-gas-tvoc-eco2-mox-sensor",
66
"published": true,
77
"i2cAddresses": [ "0x58" ],
8-
"subcomponents": [ "eco2", "tvoc" ]
8+
"subcomponents": [ "eco2", "tvoc" ],
9+
"customProperties": [
10+
{
11+
"name": "input-temp",
12+
"displayName": "Reference Ambient Temperature (°C)",
13+
"type": "number",
14+
"default": 20,
15+
"description": "The reference ambient temperature in degrees Celsius.",
16+
"displayed": true
17+
},
18+
{
19+
"name": "input-humidity",
20+
"displayName": "Reference Relative Humidity (%)",
21+
"type": "number",
22+
"default": 50,
23+
"description": "The reference relative humidity in percent.",
24+
"displayed": true,
25+
"displayOptions": {
26+
"min": 0,
27+
"max": 100
28+
}
29+
}
30+
]
931
}

0 commit comments

Comments
 (0)