From b5b1f3b424aa7c1e3d2085bee96c6246bf34ed23 Mon Sep 17 00:00:00 2001 From: tyeth Date: Tue, 5 Nov 2024 14:46:04 +0000 Subject: [PATCH 1/2] Add example for feed suffix and multi light types --- components/i2c/as7262/definition.json | 40 +++++++++++++++++++++++++++ components/i2c/ltr303/definition.json | 2 +- components/i2c/ltr329/definition.json | 2 +- components/i2c/schema.json | 6 ++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 components/i2c/as7262/definition.json diff --git a/components/i2c/as7262/definition.json b/components/i2c/as7262/definition.json new file mode 100644 index 00000000..f9b3a762 --- /dev/null +++ b/components/i2c/as7262/definition.json @@ -0,0 +1,40 @@ +{ + "vendor": "Adafruit", + "productURL": "https://www.adafruit.com/product/3779", + "documentationURL": "https://learn.adafruit.com/adafruit-as7262-6-channel-visible-light-sensor", + "displayName": "AS7262", + "published": true, + "i2cAddresses": [ "0x49" ], + "subcomponents": [ + { + "displayName": "Violet / Magenta", + "sensorType": "light", + "feedSuffix": "violet" + }, + { + "displayName": "Blue", + "sensorType": "light", + "feedSuffix": "blue" + }, + { + "displayName": "Green", + "sensorType": "light", + "feedSuffix": "green" + }, + { + "displayName": "Yellow", + "sensorType": "light", + "feedSuffix": "yellow" + }, + { + "displayName": "Orange", + "sensorType": "light", + "feedSuffix": "orange" + }, + { + "displayName": "Red", + "sensorType": "light", + "feedSuffix": "red" + } + ] +} diff --git a/components/i2c/ltr303/definition.json b/components/i2c/ltr303/definition.json index a29fed70..46401c1e 100644 --- a/components/i2c/ltr303/definition.json +++ b/components/i2c/ltr303/definition.json @@ -12,7 +12,7 @@ }, { "displayName": "Infrared", - "sensorType": "raw" + "sensorType": "light" } ] } diff --git a/components/i2c/ltr329/definition.json b/components/i2c/ltr329/definition.json index 54996024..4491fd60 100644 --- a/components/i2c/ltr329/definition.json +++ b/components/i2c/ltr329/definition.json @@ -12,7 +12,7 @@ }, { "displayName": "Infrared", - "sensorType": "raw" + "sensorType": "light" } ] } diff --git a/components/i2c/schema.json b/components/i2c/schema.json index edb0a949..c576229e 100644 --- a/components/i2c/schema.json +++ b/components/i2c/schema.json @@ -21,6 +21,12 @@ "minLength": 3, "maxLength": 24 }, + "feedSuffix": { + "description": "A unique string used to create the feed name for this sub-component, e.g.'red' suffix and type='light' would give ws-001-light-red.", + "type": "string", + "minLength": 1, + "maxLength": 24 + }, "sensorType": { "description": "One of the supported I2C sensor type strings (found in README).", "type": "string", From 3a155d50ba75d16d3ef323af8744bde32edffafc Mon Sep 17 00:00:00 2001 From: tyeth Date: Tue, 5 Nov 2024 20:53:16 +0000 Subject: [PATCH 2/2] Add SGP30 custom properties and schema validation --- components/i2c/schema.json | 57 ++++++++++++++++++++++++++++ components/i2c/sgp30/definition.json | 24 +++++++++++- 2 files changed, 80 insertions(+), 1 deletion(-) diff --git a/components/i2c/schema.json b/components/i2c/schema.json index c576229e..0f197f63 100644 --- a/components/i2c/schema.json +++ b/components/i2c/schema.json @@ -87,6 +87,63 @@ "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" ] + } + } + } + } + } + } } } } diff --git a/components/i2c/sgp30/definition.json b/components/i2c/sgp30/definition.json index 8da4840c..40f4f96a 100644 --- a/components/i2c/sgp30/definition.json +++ b/components/i2c/sgp30/definition.json @@ -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 + } + } + ] }