How to get realtime sensor measurement series data?

Hi,
I implemented functions to get real-time measurement data. Once I subscribed to the realtime API, the measurement returned is true. Then, I call my functionality to get data. If some drops are available.
In the case, if any other approaches are available to get real time sensor measurement series data ?

Please tell me any other approaches available. Then how I’m implementing to achieve the realtime functionality here.

Please find the code below to get Realtime Measurements

fetchRealtimeMeasurements() {
this.realtime.subscribe(
/measurements/${this.poolId},
(measurementNotification) => {
const measurement: IMeasurement = measurementNotification.data.data;
if (measurement) {
this.getConsumptionTrendsData(this.poolId, this.seletedInterval,this.deviceInfo,this.feederName);
}
}
);
}

Hi @ranjithkumar_m,

It seems like you are trying to use the Cumulocity Web SDK to connect to the realtime API?
If so, could you please provide the version that you are using?
Are you trying to use the @c8y/client package in a microservice or an UI application?

In case you are trying to use it in an UI application, we have some additional services for abstraction purposes, that are showcased here: Codex - RealtimeService.

The overall goal of what you are trying to achieve is quite unclear to me, it would be great if you could elaborate a bit more. Why are you checking if measurement is truethy, but then never use measurement?

What are you doing in getConsumptionTrendsData whenever you receive a new measurement?

1 Like

Hi @Tristan_Bastian ,

Sorry for the delayed response.

Here I’m implementing a trend graph using the Realtime subscribe with data. So I want to get Realtime subscription data from the measurement series. For example : whenever the device measurement series data changes happen, they should be displayed on trend graphs.
I’m using @c8y/client package in a microservice.
import { IMeasurement, Realtime } from “@c8y/client”;

const measurement: IMeasurement = measurementNotification.data.data;
if (measurement) {
this.getConsumptionTrendsData(this.poolId, this.seletedInterval,this.deviceInfo,this.feederName);
}
In the above line used to validate measurement data, if the data changes happen, then I call my custom function to fetch the data. So it will take some time,

this.getConsumptionTrendsData(this.Id, this.seletedInterval,this.deviceInfo,this.feederName); Here I’m making a call to get a new series data using a measurement series Api.

If there is any other approach, we have to display the realtime data in a trend graph. ?

Please tell me the approaches and Then how I’m implementing to achieve the realtime functionality here.

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