Skip to main content
Use a custom mapping to ingest equipment states, such as CLOSED, OPEN, and TRANSITIONING, into a state time series in Cognite Data Fusion (CDF). Each state has a numeric code and a string label in a state set. Multiple time series can share the same state set.
This feature is in public preview and may change.
The mapping uses type: "datapoint" with value set to a state object that contains numericValue, stringValue, or both. Built-in message formats don’t write state data points, and the hosted extractor doesn’t create state sets or state time series, so create them before you start the job. State time series exist only in data modeling. This procedure doesn’t convert an existing numeric or string time series.

Before you start

  • Set up a hosted extractor source, destination, and job.
  • Create the spaces in this procedure, state_definitions and industrial_assets, or use spaces you already have. Keep the same space and external ID in every step.
  • The user or client that creates the instances needs datamodelinstances:WRITE on those spaces. Verification needs datamodelinstances:READ and timeseries:READ. The destination credentials need timeseries:READ, timeseries:WRITE, and datamodelinstances:WRITE. See Access capabilities.
  • Choose an external ID that isn’t already used by a numeric or string time series.

Configure state ingestion

Follow these steps to ingest the state of valve valve_001. Replace the example spaces and external IDs consistently throughout the procedure.
1

Create the state set

Send this request to the data modeling API in your target project. The state set defines the valid codes and labels for the valve.
Wait for the request to succeed before creating the time series. A state set supports at most 100 states, with unique numeric codes and unique string labels. See State constraints for value limits.
2

Create the state time series

Create a CogniteTimeSeries instance with type: "state" and a stateSet relation to the state_definitions/valve_states state set.
Wait for the request to succeed before starting data point ingestion.
3

Define the custom mapping

Configure a custom mapping with JSON input. This example source message reports that the valve is open:
Use this mapping expression:
space and externalId identify the time series instance. timestamp is a Unix timestamp in milliseconds. For a state data point, set value to an object with numericValue, stringValue, or both. When both are present, the code and the label must correspond to the same state in the state set. The state object marks the output as a state data point. The mapping doesn’t change the time series type in CDF.The state object has these constraints:
  • numericValue must be an integer that fits in 32 bits, from -2147483648 to 2147483647.
  • stringValue must be a string.
  • At least one of the two fields must be non-null.
  • The object can’t contain other fields.
If the source sends only a numeric code, omit stringValue from the state object. If the source sends only a label, omit numericValue.Send state values only to state time series. If a batch for one time series mixes state values with numbers or strings, the extractor logs a warning and skips the values that don’t match the time series type.For mapping syntax and handling multiple values in a message, see Custom message formats.
4

Use the mapping in a job

In the job configuration, set the message format to the custom mapping you defined. Use the source and destination from Before you start. Start the job, then send the example message from the source.In job status and metrics, confirm that the job received the example message and that Destination uploaded values increased, with no transform or destination failures.
5

Verify the ingested data point

Retrieve the state data point by instance ID. This request covers the timestamp in the example message:
Confirm that the response contains numericValue: 1 and stringValue: "OPEN" at timestamp 1794484800000.If the data point is missing, check that the mapping uses the correct instance space and external ID. Confirm that the time series has type: "state" and references state_definitions/valve_states. Check job logs for mapping or destination errors:
  • If the state time series doesn’t exist, the extractor drops its data points and logs a warning. Other data points in the same batch are still written.
  • If the target time series isn’t a state time series, the extractor drops the state data points. Other data points in the same batch are still written.

Send a state data point with Bad status

If the source can’t provide a state value, set value to null and set status to a Bad status symbol. For example, the mapping output looks like this:
Don’t use a state object with both fields set to null. The extractor rejects it. See Data point status codes. A null value doesn’t show the type of the time series. The extractor recognizes a time series as a state time series after it has written at least one state data point to it. Until then, a batch with only null values for that time series is treated as numeric and can fail. Ingest a state data point with a value first.

Maintain the state definitions

Add a code and label to the state set before you send a data point that uses them. CDF validates state data points against the state set during ingestion and rejects a data point whose code or label isn’t in the set. If you change the label for a numeric code, queries return the new label for historical data points as well. If you remove a state, historical points keep the numeric code and can omit the label. See State set management. To analyze how long the valve stays in each state or how often it changes state, see Retrieve state aggregates.
Last modified on November 30, 2026