Skip to content

Instantly share code, notes, and snippets.

@AlexDoanTB
AlexDoanTB / Entity info button and form
Created February 14, 2020 09:16
Entity info button code (ThingsBoard Custom action)
JavaScript
var $injector = widgetContext.$scope.$injector;
var types = $injector.get('types'),
attributeService = $injector.get('attributeService'),
$q = $injector.get('$q'),
$mdDialog = $injector.get('$mdDialog'),
$filter = $injector.get('$filter'),
$document = $injector.get('$document');
getInfoAttributes().then(
@AlexDoanTB
AlexDoanTB / CSS_HTML settings
Created February 14, 2020 09:07
Entity info button settings for ThingsBoard Custom action configuration
CSS
.tb-image-select-wrapper {
width: 100%;
margin-bottom: 32px;
}
.tb-image-select-wrapper>label {
display: none;
}
@AlexDoanTB
AlexDoanTB / AddingPhoneNumber
Created February 13, 2020 12:35
This is the HTML code for adding phone number input field for Add entity button
<div layout="row">
<md-input-container flex class="md-block">
<label>Phone</label>
<input name="phoneNumber" pattern="^[0-9-+\s()]*$" ng-model="vm.attributes.phone">
<div ng-messages="addEntityForm.phoneNumber.$error">
<div ng-message="pattern">Invalid format</div>
</div>
</md-input-container>
</div>
@AlexDoanTB
AlexDoanTB / Scripts and generators
Created December 3, 2019 15:12
This is a file with scripts for ThingsBoard Map widget configuration video guide
Temperature generator (for Thermometer)
var msg = { temperature: +(Math.random()*6 + 25).toFixed(1)};
var msgType = "POST_TELEMETRY_REQUEST";
return { msg: msg, msgType: msgType };
_____________________________________________________________
Telemetry generator (for Asset)
@AlexDoanTB
AlexDoanTB / Uplink converter
Created October 23, 2019 08:21
This is an uplink converter for ThingsBoard Remote integration tutorial
@AlexDoanTB
AlexDoanTB / emulator.js
Created June 24, 2019 06:56
Thermostat emulator for RPC response example (Community edition free education course)
var mqtt = require('mqtt');
const ACCESS_TOKEN = process.argv[2];
var client = mqtt.connect('mqtt:localhost',{
username: ACCESS_TOKEN
});
var controlValue,
realValue = 25;
@AlexDoanTB
AlexDoanTB / Uplink_RPC
Created June 3, 2019 07:26
The Encoder function of simulated two-way RPC call via MQTT Integration from ThingsBoard tutorial
@AlexDoanTB
AlexDoanTB / Downlink_converter_two-way
Created June 3, 2019 07:23
The Encoder function for simulated two-way RPC downlink
@AlexDoanTB
AlexDoanTB / Downlink_converter
Created June 3, 2019 07:22
Downlink Encoder function for RPC call to device via MQTT Integration on ThingsBoard
@AlexDoanTB
AlexDoanTB / Uplink_decoder
Created May 31, 2019 05:47
Uplink decoder function for MQTT Integration to ThingsBoard tutorial