Skip to content

allow non-numeric meta properties in tedge measurements #3768

@reubenmiller

Description

@reubenmiller

Is your feature improvement request related to a problem? Please describe.

Publishing a thin-edge.io measurement which includes non-numeric fragments is not supported where-as the Cumulocity measurement format does support additional meta-information fragments which allows users to contextualize the measurement with additional properties (and avoid those properties being presented as measurements).

tedge mqtt pub 'te/device/main///m/machine_energy_measurement' '{
  "robot_mech_energy": {
     "accumulated_energy": 0.1,
     "ROB_1_axis_1_energy": 0.1,
     "ROB_1_axis_2_energy": 0.2,
     "ROB_1_axis_3_energy": 0.3,
     "ROB_1_axis_4_energy": 0.4,
     "ROB_1_axis_5_energy": 0.5,
     "ROB_1_axis_6_energy": 0.6,
     "ROB_2_axis_1_energy": 0.1,
     "ROB_2_axis_2_energy": 0.2,
     "ROB_2_axis_3_energy": 0.3,
     "ROB_2_axis_4_energy": 0.4,
     "ROB_2_axis_5_energy": 0.5,
     "ROB_2_axis_6_energy": 0.6
  },
  "measurement_context": {
    "status": "nominal",
    "cycle_id": "cycle-98765"
  }
}'

The above measurement format will result in a parsing error due to the measurement_context fragment containing string values.

$ sudo journalctl -fu tedge-mapper-c8y
Aug 22 09:33:08 tedge tedge-mapper[5392]: 2025-08-22T09:33:08.257174875Z ERROR c8y_mapper_ext::converter: Mapping error: Failed to convert a message on topic 'te/device/main///m/machine_energy_measurement': Invalid JSON: Unexpected type within a group at line 18 column 23: `",
Aug 22 09:33:08 tedge tedge-mapper[5392]:     "cycle_id": "cycle-98765"
Aug 22 09:33:08 tedge tedge-mapper[5392]:   }
Aug 22 09:33:08 tedge tedge-mapper[5392]: }
Aug 22 09:33:08 tedge tedge-mapper[5392]: `

Describe the solution you'd like

Allow users to publish measurements which contain additional non-numeric properties outside of the fragments which contain a value.

  • If the user mixes numeric values and non-numeric values under the same property, then the entire property shall be treated as non-numeric property and no measurement conversion should be done on it.

Examples

Example 1

tedge mqtt pub 'te/device/main///m/machine_energy_measurement' '{
  "robot_mech_energy": {
     "accumulated_energy": 0.1
  },
  "measurement_context": {
    "status": "nominal",
    "cycle_id": "cycle-98765"
  }
}'

Output: Topic: c8y/measurement/measurements/create

{
  "robot_mech_energy": {
    "accumulated_energy": {
      "value": 0.1
    }
  },
  "measurement_context": {
    "status": "nominal",
    "cycle_id": "cycle-98765"
  },
  "time": "2025-08-22T09:40:26.979484312Z",
  "type": "machine_energy_measurement"
}

Example 2

tedge mqtt pub 'te/device/main///m/machine_energy_measurement' '{
  "robot_mech_energy": 0.1,
  "prop1": "foo",
  "prop2": false,
  "prop3": ["foo", "bar"]
}'

Output: Topic: c8y/measurement/measurements/create

{
  "robot_mech_energy": {
    "robot_mech_energy": {
      "value": 0.1
    }
  },
  "prop1": "foo",
  "prop2": false,
  "prop3": ["foo", "bar"],
  "time": "2025-08-22T09:40:26.979484312Z",
  "type": "machine_energy_measurement"
}

Example 3

tedge mqtt pub 'te/device/main///m/machine_energy_measurement' '{
  "robot_mech_energy": 0.1,
  "props": {
    "version": 1.2,
    "machine_type": "value",
  }
}'

Note

The props contains both numeric and non-numeric values, however since it has at least one non-numeric value, then the entire property shall be treated as meta information (and not a measurement).

Output: Topic: c8y/measurement/measurements/create

{
  "robot_mech_energy": {
    "robot_mech_energy": {
      "value": 0.1
    }
  },
  "props": {
    "version": 1.2,
    "machine_type": "value",
  }
}

Describe alternatives you've considered

Additional context

This request originated from a user-created ticket, #3767

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions