Skip to content

Additional Semantic Information for Objects #4

@sAlexander

Description

@sAlexander

(Feature request for consideration. This was based upon my reading of the previous spec, and may be out of sync with the concepts in this spec (such as the object tree))

I really like how the ThingSet protocol supports object names. But it would be nice to have other semantic information about fields, especially for input fields.

Examples of semantic information

To give some concrete examples of semantic information that could be very nice for inputs:

  • name, binary id 0x00 (required): The human readable name of the device.
  • value, binary id 0x01 (required): The current value of this object.
  • minval, binary id 0x02 (optional): The minimum allowable value for the field. Uses the same datatype as the field itself.
  • maxval, binary id 0x03 (optional): The maximum allowable value for the field. Uses the same datatype as the field itself.
  • maxlen, binary id 0x04 (optional): The maximum allowable length for the field. Only applicable to string/byte fields.

An an example of semantic information that could be nice for outputs:

  • readfreq_Hz, binary id 0x05 (optional): The internal read rate for this output. Sampling any more frequent than this value is not recommended.

Advantages of more semantic information

This additional semantic information could be very helpful for clients. For example, if clients know the minval and maxval for an input field, they can correctly send information within that bound. And if they know that output values will be clamped above some level, they can make more intelligent decisions based upon that.

This semantic information could also be very useful for user interface (UI) generation. For example, when displaying a UI to set the maximum allowable current for an MPPT solar converter, it would be nice to know that the minval for that field is 0A and the maxval for that field is 10A. Same with a thermostat or a lightbulb: that additional semantic information can make the UI much richer and more accurate. The UI may be able to rely entirely on the semantic information for generating a beautiful interface.

A possible implementation

With these semantic types, they could be queried as part of the "list" command for each type. For example, you could modify the list results as follows (this is Text Example 2 and Binary Example 3 on https://thingset.github.io/spec/functions):

Text Request:

!output {}

Text Response:

:0 Success. {
  3: {
    "name": "Bat_V", 
    "value": 12.2, 
    "readfreq_Hz": 1000}, 
  4: {
    "name": "Ambient_degC", 
    "value": 22,
    "minval": 0, 
    "maxval": 100},
}

Binary Request:

0x04        Function ID (output)
    0xA0    CBOR empty map

Binary Response:

0x80                # Status code (Success)
0xA2                  # A map with two data items              
   0x03 0xA3            # A map of properties for data item 0x3
      0x00                # Property: name
        0x65 0x4261745F56   # String "Bat_V"
      0x01                # Property: value
        0xFA 0x41633333     # Float 14.2
      0x05                # Property: readfreq_Hz
        0x19 0x03E8         # Unsigned Int: 1000
   0x04 0xA4            # A map of properties for data item 0x4
      0x00                # Property: name
        0x6C 0x416D6269656E745F64656743 # "Ambient_degC"
      0x01                # Property: value
        0x16                # Unsigned Int
      0x02                # Property: minval
        0x00                # Unsigned Int: 0
      0x03                # Property: maxval
        0x18 0x64           # Unsigned Int: 100

There is certainly more overhead associated with the proposal above. For Example 3 in the spec, the simple map{name: value} took up 26 bytes, while this updated map{id: map{properties}} would take 34 bytes to transmit the same information (name + value). With the additional information shown above (minval/maxval/readfreq_Hz), the message would take 43 bytes.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions