Swagger UI: https://thingsboard.cloud/swagger-ui.html#!/telemetry-controller/saveEntityTelemetryUsingPOST
Thingsboard Source:
class AttributeService
Method:
public saveEntityAttributes(entityId: EntityId, attributeScope: AttributeScope, attributes: Array<AttributeData>,
config?: RequestConfig): Observable<any>
Example:
var attributeService = self.ctx.attributeService;
var entityId = self.ctx.datasources[0].entityId;
var entity = {
entityType: 'DEVICE',
id: entityId
}
attributeService.saveEntityTimeseries(entity, 'CLIENT_SCOPE', [{key: 'BatteryLevel', value: 375}]).subscribe((responseBody) => {
console.log(responseBody);
});
var attributeService = self.ctx.attributeService;
var entityId = self.ctx.datasources[0].entityId;
var entityType = self.ctx.datasources[0].entityType;
var key = self.ctx.datasources[0].dataKeys[0].name;
var entity = {
entityType: entityType, //DEVICE
id: entityId
}
console.log (entityId)
var containerType = $('#containerType option:selected', self.ctx.$container).val()
attributeService.saveEntityAttributes(entity, 'SERVER_SCOPE', [{key: 'Container type', value: containerType }]).subscribe((responseBody) => {
console.log(responseBody);
});
var attributeService = self.ctx.attributeService;
var entityId = self.ctx.datasources[0].entityId;
var entityType = self.ctx.datasources[0].entityType;
var key = self.ctx.datasources[0].dataKeys[0].name;
var entity = {
entityType: entityType, //DEVICE
id: entityId
}
console.log(self.ctx);
if (self.ctx.datasources[0].type != 'function')
{
attributeService.getEntityAttributes(entity, 'SHARED_SCOPE', [key]).subscribe((responseBody) => {
slider[0].noUiSlider.set( [parseFloat(responseBody[0].value)]);
});
<div id="outer" style="transform: scale(1); transform-origin: 0% 0% 0px;">
$('#outer', self.ctx.$container)[0].style.transform = "scale(" + (self.ctx.width / 190) + ")";
https://thingsboard.io/docs/user-guide/contribution/widgets-development/#type-parameters-object
self.typeParameters = function() {
return {
maxDatasources: 1,
maxDataKeys: 1,
singleEntity: true
};
}