For now, there is no option to delete a sensor variable alone from the GUI. So I'm providing an option to delete a sensor variable from a script.
Note: This API available from 1.4.0.Final
version.
- Now get
SensorVariable
id from Sensors page. Resources >> Sensors >> Click on view details
,
![0_1482765833386_upload-d79d7e6b-d0f6-4bc6-b6b6-0366b8968b09](/uploads/files/1482765836776-upload-d79d7e6b-d0f6-4bc6-b6b6-0366b8968b09)
Now click on edit of sensor variable
![0_1482765892413_upload-5797ae73-a6ee-4dec-b810-928013f4c2d3](/uploads/files/1482765894649-upload-5797ae73-a6ee-4dec-b810-928013f4c2d3)
On the URL you can see sensor variable id, This is id is important note it for your target sensor variable
![0_1482765974523_upload-1240a386-2016-4a96-b144-d2444df9fc73](/uploads/files/1482765976080-upload-1240a386-2016-4a96-b144-d2444df9fc73)
Add the following script on your controller,
Extension: JavaScript
Type: Operation
var myImports = new JavaImporter(java.io, java.lang, java.util);
with(myImports) {
// pass sensor variable as bindings, example: { id: 99 }
mcApi.sensor().deleteSensorVariable(id);
}
Execute the script as Run now
(select the script and in Actions
you can see Run now
),
Pass the sensor variable id as bindings, here it is { id: 99 }
,
![0_1539689727209_cb4a5f9a-3264-4844-9f1f-920f7c76d063-image.png](/assets/uploads/files/1539689730684-cb4a5f9a-3264-4844-9f1f-920f7c76d063-image.png)
Click on Run
. All done. Now your Sensor variable
removed from MyController.