Get - HTML Canvas with Dynamic Dashboard


#1

I am stuck in the development of a variable that needs to be input and displayed from the dynamic dashboard.

I have reviewed and tried multiple ways based on the Demos you have displayed, the closest one is https://help.ubidots.com/developer-guides/html-canvas-widget-introductory-demo

But the problem is that here the variables are based on the Variable Id, and after reviewing some information I was trying to access to the last result with Device Lable and not Device ID as follows:

var ubidots = new Ubidots();
var TOKEN = ubidots.token;  
var VARIABLE_Label = 'container';  
var DEVICE_Label = ubidots.selectedDevice; // <<<<<<----- This is the problem - which should be the Label of the device and not the ID


    function getValue(device, variable, token, callback) {
  var url = 'https://industrial.api.ubidots.com/api/v1.6/devices/' + device + '/' + variable + '/values';

  var headers = {
    'Content-Type': 'application/json',
    'X-Auth-Token': token 
  };
  
  $notification.hide();

  $.ajax({
    method: 'GET',
    url: url,
    headers: headers,
    success: function (res) {
     
      document.getElementById('info').innerText = res.results[0].value;

  	}
  });
}

#2

Greetings @mr_3r , you can interact with the actual selected device using its ID, to know how to retrieve the actual device ID please refer to this guide:

With the actual device ID, you may get its device label using the datasources endpoint.

All the best