How can I set min/max value point by sending json data measurements with rest api

I want to determine the minimum maximum point that will appear on the graph when sending the temperature measurement results to the cumulociyt with REST API.

If I don’t do this, the graph is automatically scaled according to my measurements.

Since the minimum value in the measurements is 24.8, the minimum value appears as 24.8 on the graph.

I want the graphic range to be between -20 and 100 regardless of the measurement values.

The json I sent is like this;

{
  "measurements": [
    {
      "source": {
        "id": "1113"
      },
      "time": "2023-07-06T10:50:15",
      "type": "TEST",
      "TEST_Temperatur": {
        "Field2": {
          "unit": "°C(int)",
          "value": "24,8"
        }
      }
    },
    {
      "source": {
        "id": "1113"
      },
      "time": "2023-07-06T11:00:31",
      "type": "TEST",
      "TEST_Temperatur": {
        "Field2": {
          "unit": "°C(int)",
          "value": "24,9"
        }
      }
    },
    {
      "source": {
        "id": "1113"
      },
      "time": "2023-07-06T11:10:39",
      "type": "TEST",
      "TEST_Temperatur": {
        "Field2": {
          "unit": "°C(int)",
          "value": "25,1"
        }
      }
    },
    {
      "source": {
        "id": "1113"
      },
      "time": "2023-07-06T11:20:32",
      "type": "TEST",
      "TEST_Temperatur": {
        "Field2": {
          "unit": "°C(int)",
          "value": "25,1"
        }
      }
    },
    {
      "source": {
        "id": "1113"
      },
      "time": "2023-07-06T11:30:34",
      "type": "TEST",
      "TEST_Temperatur": {
        "Field2": {
          "unit": "°C(int)",
          "value": "25,0"
        }
      }
    },
    {
      "source": {
        "id": "1113"
      },
      "time": "2023-07-06T11:40:19",
      "type": "TEST",
      "TEST_Temperatur": {
        "Field2": {
          "unit": "°C(int)",
          "value": "25,1"
        }
      }
    },
    {
      "source": {
        "id": "1113"
      },
      "time": "2023-07-06T11:50:23",
      "type": "TEST",
      "TEST_Temperatur": {
        "Field2": {
          "unit": "°C(int)",
          "value": "25,1"
        }
      }
    },
    {
      "source": {
        "id": "1113"
      },
      "time": "2023-07-06T12:00:22",
      "type": "TEST",
      "TEST_Temperatur": {
        "Field2": {
          "unit": "°C(int)",
          "value": "25,4"
        }
      }
    },
    {
      "source": {
        "id": "1113"
      },
      "time": "2023-07-06T12:10:14",
      "type": "TEST",
      "TEST_Temperatur": {
        "Field2": {
          "unit": "°C(int)",
          "value": "25,4"
        }
      }
    }
  ]
}

How do I determine the min/max points when sending data with rest API?

Hi,

you can use the data point library to define the minimum and maximum value for the specific combination of fragment (TEST_Temperatur) and series (Field2).

Check the documentation here: https://cumulocity.com/guides/users-guide/cockpit/#data-point-library on how to add such an entry to the data point library.

2 Likes

Just noticed that you are also sending your measurement value (e.g. "24,8") as a string and that you are using a comma as the decimal separator.
Instead you should probably send your measurements in this format (using a dot as decimal separator and without the quotation marks):

{
      "source": {
        "id": "1113"
      },
      "time": "2023-07-06T10:50:15",
      "type": "TEST",
      "TEST_Temperatur": {
        "Field2": {
          "unit": "°C",
          "value": 24.8
        }
      }
}

For more details check: Cumulocity IoT - OpenAPI Specification

2 Likes

Thanks for your attention :grin:
When making a request, I convert the string to numeric value and make post request.

Thanks for the solution, I’ll look into the documentation you sent. :+1:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.