### Install and Start Web Report Service Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/install/ubuntu-webreport-service.md Install the Web Report service using the downloaded .deb package and then start the service. ```bash sudo dpkg -i tb-web-report-{{ site.release.pe_ver }}.deb sudo service tb-web-report start ``` -------------------------------- ### Install and Start Web Report Service Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/install/rhel-webreport-service.md Installs the Web Report service using the downloaded RPM package and then starts the service. ```bash sudo rpm -Uvh tb-web-report-{{ site.release.pe_ver }}.rpm sudo service tb-web-report start ``` -------------------------------- ### Start Cassandra Service Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/edge/install/cassandra-rhel-install.md Starts the Cassandra service after installation. ```bash sudo service cassandra start ``` -------------------------------- ### Install and Initialize PostgreSQL Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/install/postgres-install-rhel.md Installs PostgreSQL 16 packages, disables the default module, initializes the database cluster, and starts the PostgreSQL service. Optionally configures it to start on boot. ```bash sudo dnf -qy module disable postgresql sudo dnf -y install postgresql16 postgresql16-server postgresql16-contrib # Initialize your PostgreSQL DB sudo /usr/pgsql-16/bin/postgresql-16-setup initdb sudo systemctl start postgresql-16 # Optional: Configure PostgreSQL to start on boot sudo systemctl enable --now postgresql-16 ``` -------------------------------- ### Install and Initialize PostgreSQL Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/edge/install/postgres-install-rhel.md Installs PostgreSQL 16 packages, initializes the database cluster, and enables the PostgreSQL service to start on boot. ```bash sudo dnf -qy module disable postgresql && \ sudo dnf -y install postgresql16 postgresql16-server postgresql16-contrib && \ sudo /usr/pgsql-16/bin/postgresql-16-setup initdb && \ sudo systemctl enable --now postgresql-16 ``` -------------------------------- ### Install and Run TBMQ on Windows Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/docs/mqtt-broker/install/docker-windows.md Execute this command to download the installation script, set up necessary Docker volumes, install the database, and start the TBMQ service. ```shell .\tbmq-install-and-run.ps1 ``` -------------------------------- ### Example Install Command for Custom Statistics Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/iot-gateway/gateway-dashboard-statistics-conf.md Provide a command to install necessary packages for custom statistics collection. This command will be executed before the custom statistics commands if needed. ```bash apt-get install -y curl ``` -------------------------------- ### Install ThingsBoard as a Windows Service Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/docs/user-guide/install/pe/windows.md Execute the install script to install ThingsBoard as a Windows service. Use the `--loadDemo` flag to also load demo data. This ensures ThingsBoard starts automatically on system startup. ```text C:\Program Files (x86)\thingsboard>.\install.bat --loadDemo Detecting Java version installed. CurrentVersion 170 Java 17 found! Installing thingsboard ... ... ThingsBoard installed successfully! ``` -------------------------------- ### Install CoAP CLI (Linux/macOS) Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/docs/reference/coap-api.md Install the CoAP CLI tool globally using npm. This tool is used for the CoAP examples in this guide. ```bash npm install coap-cli -g ``` -------------------------------- ### Example Configuration with Parameters Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/edge/install/integration/coap-ubuntu.md An example of how the configuration block should look after uncommenting and entering your actual connection parameters. ```bash # UNCOMMENT NEXT LINES AND PUT YOUR CONNECTION PARAMETERS: export RPC_HOST=127.0.0.1 # THE IP ADDRESS OF YOUR EDGE INSTANCE export RPC_PORT=9090 export INTEGRATION_ROUTING_KEY=b75**************************34d export INTEGRATION_SECRET=vna**************mik ``` -------------------------------- ### Widget Configuration Example Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/docs/pe/user-guide/contribution/ui/basic-widget-api.md Illustrates how to define widget configuration options. ```json { "title": "My Custom Widget", "type": "myWidget", "config": { "defaultData": [], "settings": { "color": "#000000" } } } ``` -------------------------------- ### OPC-UA GUID Identifier Example Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/docs/iot-gateway/config/opc-ua.md Uses a globally unique identifier (GUID) to uniquely reference an OPC-UA node. Example format: ${ns=3;g=550e8400-e29b-41d4-a716-446655440000}. ```text ${ns=3;g=550e8400-e29b-41d4-a716-446655440000} ``` -------------------------------- ### Full REST Client Example Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/docs/pe/reference/rest-client.md This comprehensive example demonstrates a full workflow including authentication, tenant and user creation, API key generation, and resource loading. It shows how to re-initialize the client with an API key for subsequent operations. ```java // ThingsBoard REST API URL final String url = "http://localhost:8080"; // Default System Administrator credentials final String username = "sysadmin@thingsboard.org"; final String password = "sysadmin"; // creating new rest restClient and auth with system administrator credentials restClient = new RestClient(url); login(username, password); // Creating Tenant Tenant tenant = new Tenant(); tenant.setTitle("Test Tenant"); tenant = restClient.saveTenant(tenant); final String tenantUsername = "testtenant@thingsboard.org"; final String tenantPassword = "testtenant"; // Created User for Tenant User tenantUser = new User(); tenantUser.setAuthority(Authority.TENANT_ADMIN); tenantUser.setEmail(tenantUsername); tenantUser.setTenantId(tenant.getId()); tenantUser = restClient.saveUser(tenantUser, false); restClient.activateUser(tenantUser.getId(), tenantPassword); // create API key for Tenant User ApiKeyInfo apiKeyInfo = new ApiKeyInfo(); apiKeyInfo.setUserId(tenantUser.getId()); apiKeyInfo.setDescription(tenantUsername + " API key"); ApiKey savedApiKey = restClient.saveApiKey(apiKeyInfo); // API key value of Tenant User String apiKeyValue = savedApiKey.getValue(); // re-init restClient with Tenant User's API key restClient = RestClient.withApiKey(url, apiKeyValue); // Loading Widget from file Path widgetFilePath = Paths.get("src/main/resources/custom_widget.json"); JsonNode widgetJson = mapper.readTree(Files.readAllBytes(widgetFilePath)); loadWidget(widgetJson); // Loading Rule Chain from file Path ruleChainFilePath = Paths.get("src/main/resources/rule_chain.json"); JsonNode ruleChainJson = mapper.readTree(Files.readAllBytes(ruleChainFilePath)); loadRuleChain(ruleChainJson, false); // Creating Dashboard Group on the Tenant Level EntityGroup sharedDashboardsGroup = new EntityGroup(); sharedDashboardsGroup.setName("Shared Dashboards"); sharedDashboardsGroup.setType(EntityType.DASHBOARD); sharedDashboardsGroup = restClient.saveEntityGroup(sharedDashboardsGroup); // Loading Dashboard from file JsonNode dashboardJson = mapper.readTree(RestClientExample.class.getClassLoader().getResourceAsStream("watermeters.json")); Dashboard dashboard = new Dashboard(); dashboard.setTitle(dashboardJson.get("title").asText()); dashboard.setConfiguration(dashboardJson.get("configuration")); dashboard = restClient.saveDashboard(dashboard); // Adding Dashboard to the Shared Dashboards Group restClient.addEntitiesToEntityGroup(sharedDashboardsGroup.getId(), Collections.singletonList(dashboard.getId())); // Creating Customer 1 Customer customer1 = new Customer(); customer1.setTitle("Customer 1"); customer1 = restClient.saveCustomer(customer1); Device waterMeter1 = new Device(); waterMeter1.setCustomerId(customer1.getId()); waterMeter1.setName("WaterMeter1"); waterMeter1.setType("waterMeter"); waterMeter1 = restClient.saveDevice(waterMeter1); // Update device token DeviceCredentials deviceCredentials = restClient.getDeviceCredentialsByDeviceId(waterMeter1.getId()).get(); deviceCredentials.setCredentialsId("new_device_token"); restClient.saveDeviceCredentials(deviceCredentials); // Fetching automatically created "Customer Administrators" Group. EntityGroupInfo customer1Administrators = restClient.getEntityGroupInfoByOwnerAndNameAndType(customer1.getId(), EntityType.USER, "Customer Administrators").get(); // Creating Read-Only Role Role readOnlyRole = restClient.createGroupRole("Read-Only", Arrays.asList(Operation.READ, Operation.READ_ATTRIBUTES, Operation.READ_TELEMETRY, Operation.READ_CREDENTIALS)); // Assigning Shared Dashboards to the Customer 1 Administrators GroupPermission groupPermission = new GroupPermission(); groupPermission.setRoleId(readOnlyRole.getId()); groupPermission.setUserGroupId(customer1Administrators.getId()); groupPermission.setEntityGroupId(sharedDashboardsGroup.getId()); groupPermission.setEntityGroupType(sharedDashboardsGroup.getType()); groupPermission = restClient.saveGroupPermission(groupPermission); // Creating User for Customer 1 with default dashboard from Tenant "Shared Dashboards" group. String userEmail = "user@thingsboard.org"; String userPassword = "secret"; User user = new User(); user.setAuthority(Authority.CUSTOMER_USER); user.setCustomerId(customer1.getId()); user.setEmail(userEmail); ObjectNode additionalInfo = mapper.createObjectNode(); additionalInfo.put("defaultDashboardId", dashboard.getId().toString()); additionalInfo.put("defaultDashboardFullscreen", false); user.setAdditionalInfo(additionalInfo); user = restClient.saveUser(user, false); restClient.activateUser(user.getId(), userPassword); restClient.addEntitiesToEntityGroup(customer1Administrators.getId(), Collections.singletonList(user.getId())); ``` -------------------------------- ### Initialize Database Schema and System Assets Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/docs/user-guide/install/pe/docker-windows.md Run this command to install the core database schema, system resources, and optionally load demo data for evaluation. Use this before starting the main ThingsBoard services. ```bash docker compose run --rm -e INSTALL_TB=true -e LOAD_DEMO=true thingsboard-pe ``` -------------------------------- ### Widget Configuration Example Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/docs/paas/eu/user-guide/contribution/ui/basic-widget-api.md Shows how to define widget settings and configurations. Requires JSON. ```json { "settings": { "title": "My Widget Title", "dataKey": "temperature", "color": "#FF0000" }, "state": { "lastUpdated": "2023-10-27T10:00:00Z" } } ``` -------------------------------- ### IoT Gateway MQTT GET Method Example Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/iot-gateway/get-set-connector-rpc/mqtt.md Example of reading the room light level using the GET method. It specifies the topics for requests and responses, and a placeholder for the value. ```bash get requestTopicExpression=data/get_light_level;responseTopicExpression=data/response;value=${params}; ``` -------------------------------- ### Full .env File Example Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/docs/edge/user-guide/config/edge-cluster-setup.md This is an example of a complete .env file, showing all possible configurations for ThingsBoard Edge. ```liquid # redis or redis-cluster or redis-sentinel CACHE=redis DOCKER_REPO=thingsboard {% if docsPrefix == "pe/edge/" -%} TB_EDGE_NODE_DOCKER_NAME=tb-edge-pe-node TB_EDGE_VERSION=latest {%- else -%} TB_EDGE_NODE_DOCKER_NAME=tb-edge-node TB_EDGE_VERSION=latest {%- endif -%} # Database used by ThingsBoard, can be either postgres (PostgreSQL) or hybrid (PostgreSQL for entities database and Cassandra for timeseries database). # According to the database type corresponding docker service will be deployed (see docker-compose.postgres.yml, docker-compose.hybrid.yml for details). DATABASE=postgres TB_QUEUE_TYPE=kafka CLOUD_ROUTING_KEY=PUT_YOUR_EDGE_KEY_HERE # e.g. 19ea7ee8-5e6d-e642-4f32-05440a529015 CLOUD_ROUTING_SECRET=PUT_YOUR_EDGE_SECRET_HERE # e.g. bztvkvfqsye7omv9uxlp {% if docsPrefix == "pe/edge/" -%} CLOUD_RPC_HOST=thingsboard.cloud CLOUD_RPC_PORT=7070 CLOUD_RPC_SSL_ENABLED=true {%- else -%} CLOUD_RPC_HOST=PUT_YOUR_THINGSBOARD_SERVER_DOMAIN_OR_IP_HERE # e.g. thingsboard.cloud CLOUD_RPC_PORT=7070 {%- endif -%} LOAD_BALANCER_NAME=haproxy-certbot # If enabled Prometheus and Grafana containers are deployed along with other containers MONITORING_ENABLED=false ``` -------------------------------- ### Manage Device Example Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/docs/pe/reference/rest-client.md This example demonstrates basic concepts of device management API, including adding, getting, and deleting devices, as well as getting and saving device attributes. ```APIDOC ## Manage Device Example This example demonstrates basic concepts of device management API (add/get/delete device, get/save device attributes). ```java // ThingsBoard REST API URL String url = "http://localhost:8080"; // Perform login with default Customer User API key String apiKey = "YOUR_API_KEY_VALUE"; RestClient client = RestClient.withApiKey(url, apiKey); // Construct device object String newDeviceName = "Test Device"; Device newDevice = new Device(); newDevice.setName(newDeviceName); // Create Json Object Node and set it as additional info ObjectMapper mapper = new ObjectMapper(); ObjectNode additionalInfoNode = mapper.createObjectNode().put("description", "My brand new device"); newDevice.setAdditionalInfo(additionalInfoNode); // Save device Device savedDevice = client.saveDevice(newDevice); System.out.println("Saved device: " + savedDevice); // Find device by device id or throw an exception otherwise Optional optionalDevice = client.getDeviceInfoById(savedDevice.getId()); DeviceInfo foundDevice = optionalDevice.orElseThrow(() -> new IllegalArgumentException("Device with id " + newDevice.getId().getId() + " hasn't been found")); // Save device shared attributes ObjectNode requestNode = mapper.createObjectNode().put("temperature", 22.4).put("humidity", 57.4); boolean isSuccessful = client.saveEntityAttributesV2(foundDevice.getId(), "SHARED_SCOPE", requestNode); System.out.println("Attributes have been successfully saved: " + isSuccessful); // Get device shared attributes var attributes = client.getAttributesByScope(foundDevice.getId(), "SHARED_SCOPE", List.of("temperature", "humidity")); System.out.println("Found attributes: "); attributes.forEach(System.out::println); // Delete the device client.deleteDevice(savedDevice.getId()); // Perform logout of current user and close client client.close(); ``` ``` -------------------------------- ### Install Cassandra and Tools on Ubuntu Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/edge/install/cassandra-ubuntu-install.md Installs Cassandra and associated tools by adding the official repository and running apt-get. ```bash echo "deb https://debian.cassandra.apache.org 41x main" | sudo tee /etc/apt/sources.list.d/cassandra.sources.list curl https://downloads.apache.org/cassandra/KEYS | sudo apt-key add - sudo apt-get update ## Cassandra installation sudo apt-get install cassandra ## Tools installation sudo apt-get install cassandra-tools ``` -------------------------------- ### Install OpenJDK 17 Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/install/ubuntu-java-install.md Installs the OpenJDK 17 JDK headless package on Ubuntu. This is the primary command to get Java 17 installed. ```bash sudo apt update && sudo apt install openjdk-17-jdk-headless ``` -------------------------------- ### TBMQ Helm Installation Output Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/mqtt-broker/install/helm/common/install-chart.md This is an example of the output you should expect after a successful TBMQ Helm chart installation. ```bash NAME: my-tbmq-cluster LAST DEPLOYED: Wed Mar 26 17:42:49 2025 NAMESPACE: tbmq STATUS: deployed REVISION: 1 TEST SUITE: None NOTES: TBMQ Cluster my-tbmq-cluster will be deployed in few minutes. Info: Namespace: tbmq ``` -------------------------------- ### Start ThingsBoard Gateway (manual) Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/iot-gateway/upgrade-instructions/python-pip.md If you were running the Gateway manually in a terminal, use this command to start it after the upgrade. ```bash thingsboard-gateway ``` -------------------------------- ### Successful Installation Log Output Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/docs/trendz/install/python-executor-configuration.md Example log output indicating that the custom Python requirement has been successfully installed. ```text Installing custom Python requirements... Requirement already satisfied: emoji==2.2.0 in /usr/local/lib/python3.9/site-packages ``` -------------------------------- ### open Method Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/docs/iot-gateway/custom/serial-connector.md Called to start the connector. In the example, this method is used to start the main connector loop in a separate thread. ```APIDOC ## open Method ### Description Starts the connector. This method is invoked by the core system to initiate the connector's operation, often by starting a new thread for the main processing loop. ### Parameters #### Parameters - **self** (object) - The current connector instance. ``` -------------------------------- ### Install curl for Linux Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/docs/reference/http-api.md Installs the curl command-line tool on Linux systems, which is used for making HTTP requests in the examples. ```bash sudo apt-get install curl ``` -------------------------------- ### Example Load Balancer Output Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/install/cloud-cluster-common/http-lb.md This is an example of the output you should see once the load balancer is provisioned. ```text NAME CLASS HOSTS ADDRESS PORTS AGE tb-http-loadbalancer * 34.111.24.134 80 7m25s ``` -------------------------------- ### Install Required Libraries and Tools Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/docs/device-library/guides/banana-pi-bpi-m5.md Install the necessary Python libraries and tools for your single-board computer. Ensure you have Python 3.7 or higher and the tb-mqtt-client library. ```bash sudo pip install tb-mqtt-client sudo pip install Adafruit-Blinka ``` -------------------------------- ### Example Kinesis Get Records Command Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/docs/pe/user-guide/integrations/aws-kinesis.md An example of the 'get-records' command using a specific ShardIterator. This demonstrates how to retrieve data from the stream. ```bash aws kinesis get-records --shard-iterator AAAAAAAAAAFQtL3oAo74irn+ccC3vghADqqmh2MH+HKI9qYTi1NP957vDe8KyV6VdQ+I4shIP0HIRRVYyTZs0W9v6jaai9LevlJayMw6TgdPkVIGmV5SYZF8sGWgtd0wJuRqB+6QwCAUHQ52dgT4m+lypNSzJJw4Mo6h+9Wdk5fpwQxu/GlM8J+Uqblnq4EEr17FkWLahikaSZXktfLq5dh23+LEIc22 ``` -------------------------------- ### Install ThingsBoard with Demo Data Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/install/docker/docker-compose-setup-running.md Execute this command to install ThingsBoard and load additional demo data. ```bash ./docker-install-tb.sh --loadDemo ``` -------------------------------- ### Send Telemetry to Local ThingsBoard Installation Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/helloworld/coap.md Example of sending telemetry to a locally installed ThingsBoard instance using 'localhost' as the host. ```bash echo -n '{"temperature": 25}' | coap post coap://localhost/api/v1/ABC123/telemetry ``` -------------------------------- ### Run Initial Database Setup Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/install/aws/eks-installation.md Execute this command to initialize the database schema and load demo data if the --loadDemo argument is provided. Ensure your PostgreSQL connection details are correctly configured in tb-node-db-configmap.yml. ```bash ./k8s-install-tb.sh --loadDemo ``` -------------------------------- ### Run Gateway Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/docs/iot-gateway/install/source-installation.md Starts the ThingsBoard Gateway to verify the installation. ```bash python3 ./thingsboard_gateway/tb_gateway.py ``` -------------------------------- ### Install OpenJDK 17 Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/install/rhel-java-install.md Installs the OpenJDK 17 headless package using dnf. This is the primary command to get Java 17 on your system. ```bash sudo dnf install java-17-openjdk-headless ``` -------------------------------- ### Install ThingsBoard MQTT Broker (Community Edition) Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/mqtt-broker/install/linux-macos/linux-macos-install.md Use this command to download and run the installation script for the community edition of the ThingsBoard MQTT Broker. Ensure you have wget installed and execute with sudo for necessary permissions. ```shell wget https://raw.githubusercontent.com/thingsboard/tbmq/{{ site.release.broker_branch }}/msa/tbmq/configs/tbmq-install-and-run.sh && sudo chmod +x tbmq-install-and-run.sh && ./tbmq-install-and-run.sh ``` -------------------------------- ### Run Device Provisioning Script Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/provisioning/mqtt-basic-credentials-type.md Execute the Python script using the python3 interpreter to start the device provisioning process. ```bash python3 device-provision-example.py ``` -------------------------------- ### Start ThingsBoard Service Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/windows-start-service.md Execute this command in an Administrator command prompt to start the ThingsBoard service. Ensure the service is installed and configured correctly. ```shell net start thingsboard ``` -------------------------------- ### Example Kubernetes Service Output Source: https://github.com/thingsboard/thingsboard.github.io/blob/master/_includes/templates/mqtt-broker/install/helm/aws/validate-mqtt.md This is an example of the output you should expect when running 'kubectl get services'. The EXTERNAL-IP field is crucial for connecting to the MQTT broker. ```text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE my-tbmq-cluster-mqtt-lb LoadBalancer 10.100.119.170 k8s-tbmq-mytbmq-b9f99d1ab6-1049a98ba4e28403.elb.eu-west-1.amazonaws.com 1883:30308/TCP,8883:31609/TCP 6m58s ```