Search code examples
javascriptattributeswidgetthingsboard

Thingsboard, access a server side attribute from the widget's javascript


As the title suggests I wanted to know how to access a server side attribute of the thingsboard Map widget.

My goal is to change the color of the polygon based on an attribute but I can't understand how to access this attribute from the javascript snippet in the appropriate area.

Thanks in advance.


Solution

  • you have to select them from Alias panel. By the way you can see the attributes only if you choice a dashboard of type latest values. After you have selected the attribute you can use them from javascript panel:

    self.onInit = function(e) {
        console.log("onInit()");
        console.log(self);
    }
    
    self.onDataUpdated = function() {
        console.log("start onDataUpdated()");
        console.log(self.ctx.defaultSubscription);
    }