I was browsing through my list of custom templates and noticed that each of template contains a time entry in the preview section of the API.
In my Angular program, I want to filter the measurements I am getting and place them in a 12-length array where each index equals a month of the year, so that I can then display it in a bar chart using ChartJS.
I made a model of such a data in TypeScript, and I wanted to confirm if this would translate into the object shown in the preview above.
I have modelled a new method to load the latest ModeUsage Measurements but I am having trouble extracting the time property from the response object I receive
I’m not sure what you are trying to achieve with the getSupportedMeasurements as it does not expect a function to be passed as parameter but as it is not actually being used any further, I guess we can ignore it…
The second method is to get tube set usage data from a certain period of time. I just needed the measurements, so I was unsure as to whether I should have placed getMeasurementsAndSeries or if getSupportedMeasurements would have sufficed.
actually response.data[0].time should already be a string and I guess it is just typed incorrectly on our end as time: string | Date;.
With getSupportedMeasurements we are basically just calling this endpoint: Cumulocity IoT - OpenAPI Specification which only provides you the information regarding what kind of fragments your device supports.
getMeasurementsAndSeries does something similar and will provide you the supported fragment/series combinations of your device by combining the above mentioned endpoint with Cumulocity IoT - OpenAPI Specification
Both methods only allow/require you to filter by deviceId and do not allow filtering by a time frame.
In case you are just interested in the first value, you can also add a pageSize of 1 to your filter: