I have written the code for create measurement for creating measurement on managed object update but I wanted to create measurement only for location update event
action onload() {
monitor.subscribe(ManagedObject.SUBSCRIBE_CHANNEL);
string device := "";
on all ManagedObject() as mo {
if(mo.isCreate() or mo.isUpdate() and mo.params.hasKey("c8y_IsDevice")) {
device := mo.id;
listenAndActOnMeasurements(device);
}
}
}
action listenAndActOnMeasurements(string deviceId)
{
requestIface := CumulocityRequestInterface.connectToCumulocity();
string REQUEST_ROOT:= "/service/demo-microservice/api/custom/" + deviceId;
Request demoserviceRequest:=requestIface.createRequest("GET",
REQUEST_ROOT, any());
demoserviceRequest.execute(responseCallback);
log "EPL execution completed." at INFO;
}