[ST Edge] Custom capability 'object' data type

Hi,

says it is possible to create a capability with object and array types.

object	{x: 12, y: 24}	A map of name value pairs, where the values can be of different types.
array	["heat", "cool"]	A list of values of a single type.

However, I couldn’t find anything about how to define the presentation for such capability.
Any help would be greatly appreciated.

capability.json

{
    "version": 1,
    "status": "proposed",
    "name": "Object",
    "attributes": {
        "data": {
            "schema": {
                "type": "object",
                "properties": {
                    "value": {
                        "type": "object"
                    }
                },
                "additionalProperties": false,
                "required": [
                    "value"
                ]
            },
            "enumCommands": []
        }
    },
    "commands": {},
    "public": true
}

My presentation looks like this:

dashboard:
  states:
    - label: '{{data.value}}'
      alternatives: null
  actions: []
  basicPlus: []
detailView:
  - label: 'Generic Object'
    displayType: state
    state:
      label: '{{data.value}}'
automation:
  conditions: []
  actions: []
id: amberpiano10217.object
version: 1

It is shown as

[object Object]

in the APP.

Pending someone who knows what they are talking about, I’d look at capabilities that use those types. For example:

objectDetection

id: objectDetection
version: 1
status: live
name: Object Detection
attributes:
  detected:
    schema:
      type: object
      properties:
        value:
          title: ObjectDetectionValue
          type: object
          additionalProperties: false
          properties:
            value:
              title: String
              type: string
              maxLength: 255
            qty:
              title: PositiveInteger
              type: integer
              minimum: 0
            data:
              title: JsonObject
              type: object
          required:
            - value
      additionalProperties: false
      required:
        - value
    enumCommands: []
  supportedValues:
    schema:
      type: object
      properties:
        value:
          type: array
          items:
            title: String
            type: string
            maxLength: 255
      additionalProperties: false
      required: []
    enumCommands: []
commands: {}

objectDetection Presentation

detailView:
  - label: '{{i18n.label}}'
    displayType: state
    state:
      label: '{{detected.value.value}}'
      alternatives:
        - key: human
          value: '{{i18n.attributes.detected.i18n.value.human.label}}'
          type: active
        - key: pet
          value: '{{i18n.attributes.detected.i18n.value.pet.label}}'
          type: active
        - key: parcel
          value: '{{i18n.attributes.detected.i18n.value.parcel.label}}'
          type: active
        - key: none
          value: '{{i18n.attributes.detected.i18n.value.none.label}}'
          type: active
  - label: '{{i18n.label}}'
    displayType: state
    state:
      label: '{{detected.value.qty}}'
automation:
  conditions:
    - label: '{{i18n.label}}'
      displayType: list
      list:
        alternatives:
          - key: human
            value: '{{i18n.attributes.detected.i18n.value.human.label}}'
            type: active
          - key: pet
            value: '{{i18n.attributes.detected.i18n.value.pet.label}}'
            type: active
          - key: parcel
            value: '{{i18n.attributes.detected.i18n.value.parcel.label}}'
            type: active
          - key: none
            value: '{{i18n.attributes.detected.i18n.value.none.label}}'
            type: active
        supportedValues: supportedValues.value
        value: detected.value.value
  actions: []
id: objectDetection
version: 1

threeAxis

id: threeAxis
version: 1
status: live
name: Three Axis
attributes:
  threeAxis:
    schema:
      type: object
      properties:
        value:
          type: array
          items:
            type: integer
            minimum: -10000
            maximum: 10000
          minItems: 3
          maxItems: 3
        unit:
          type: string
          enum:
            - mG
          default: mG
      additionalProperties: false
      required:
        - value
    enumCommands: []
commands: {}

threeAxis Presentation

detailView:
  - label: '{{i18n.label}}'
    displayType: state
    state:
      label: '{{threeAxis.value}}'
      unit: threeAxis.unit
id: threeAxis
version: 1
1 Like