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.
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_definitionsandindustrial_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:WRITEon those spaces. Verification needsdatamodelinstances:READandtimeseries:READ. The destination credentials needtimeseries:READ,timeseries:WRITE, anddatamodelinstances: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 valvevalve_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 Wait for the request to succeed before starting data point ingestion.
CogniteTimeSeries instance with type: "state" and a stateSet relation to the state_definitions/valve_states state set.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:numericValuemust be an integer that fits in 32 bits, from -2147483648 to 2147483647.stringValuemust be a string.- At least one of the two fields must be non-null.
- The object can’t contain other fields.
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, setvalue to null and set status to a Bad status symbol. For example, the mapping output looks like this: