Ubidots Developer Guides
Help CenterAPI ReferenceData APICommunity
  • Welcome to our Dev Guides
  • ⚡️ Getting Started
    • What is Ubidots?
    • Devices, Variables, and Dots
    • Technical FAQs
    • Business FAQs
  • 🧩Integration Guides
    • Industrial IoT
      • Advantech
      • Amplified Engineering
      • AWS
      • Azimut
      • Balena
      • Bivocom
      • CESVA
      • Controllino
      • Digital Communications Technologies (DCT)
      • Everactive
      • Golioth
      • Kepware
      • Kunbus
      • Monnit
      • MultiTech
      • NCD.io
      • Node-RED
      • Omicron IoT
      • Red Lion
      • Robustel
      • Senquip
      • Sielco
      • Siemens
      • Strega
      • vNode
      • WAGO
      • Weintek
      • YuDash
    • Cellular
      • Blues Wireless
      • Digi International
      • Hologram
      • Monogoto
      • Particle
      • Quectel
      • Soracom
    • LoRaWAN
      • AonChip
      • Chirpstack
      • Decentlab
      • Helium
      • ioThings
      • LORIOT
      • Milesight
      • MOKOSmart
      • RAKwireless
      • Sagemcom
      • Seeed Studio
      • Senet
      • The Things Industries
        • The Things Stack
        • The Things Network
    • Sigfox
      • Digital Matter
      • McThings
      • Sigfox
      • Suntech
      • Thinxtra
      • UnaBiz
    • Satellite
      • Swarm
    • Dev Kits
      • Adafruit
      • Advantech
      • AloriumTech
      • Arduino
      • Blues Wireless
      • DFRobot
      • Dragino
      • Electric Imp
      • Espressif Systems
      • McThings
      • Microchip Technology
      • Onion
      • Particle
      • Pycom
      • RAKwireless
      • Raspberry Pi
      • Seeed Studio
      • Sodaq
      • STMicroelectronics
      • Texas Instruments
      • Thinxtra
      • Verse Technology
    • Weather
      • Weather Plugins
      • Ambient Weather
    • Tools
      • Gambit Communications
      • PubNub
  • 📊Dashboards & Widgets
    • HTML Canvas
      • 3rd party packages
      • Preload Dashboard data
      • Built-in library
        • Properties
        • Methods
        • Listening events
        • API
      • Examples
        • Basics
        • Create an LCD screen with the HTML Canvas
        • Interacting with dashboard data
        • Change header's custom style
        • Adding real time using Socket.IO
        • Delete Variable data from a Device
        • Delete Variable data from Groups or Types of Devices
        • Navigation through Dashboard
        • Using a React library
      • Code editor
        • HTML Tab
        • CSS Tab
        • JavaScript Tab
    • Custom UI
      • Paragraph
      • Input combo
        • Text
        • Numeric
        • Numeric with buttons
        • Date
        • Time
        • Toggle
        • Dropdown
        • Multiple selection dropdown
      • Button
    • Custom Style
      • Dashboards
      • Widgets
    • Line chart
    • Pages
      • Getting started
      • Development
      • API
        • Page creation
        • Publish
  • 🤖UbiFunctions
    • Getting Started
      • Creating an UbiFunction
      • Coding an UbiFunction
      • Testing an UbiFunction
      • Authentication
      • Execution Time
      • Logs
    • Runtimes
      • Python
      • NodeJS
      • Custom Runtimes
    • Invocation
      • Time-based Trigger
      • HTTPS
      • MQTT Publish
      • Ubidots Event
    • Advanced
      • Account Token
      • Execution time
      • Raw Functions
      • CORS Policy
      • Async Execution
      • DaaS (Decoder as a Service)
      • Developing and Managing UbiFunctions with Ubidots CLI
    • Examples
    • Specs and Limits
    • Storage
      • File Storage API
      • Mutiple files
  • 🧩Plugins
    • What is a plugin?
    • Public vs. Private
    • Public plugins
      • Cron
      • Webhook
    • Private Plugins
      • Cron
      • Webhook
      • Widget
      • Device
    • Plugins development
      • Getting started
      • Cron
      • Webhook
      • Widget
      • Device
      • view.xml
      • view_widget.xml
    • Plugins deployment
      • Cron and Webhook
      • Widget
      • Device
    • Using the plugins
      • Cron and Webhook
      • Widget
      • Device
  • 📈SYNTHETIC VARIABLES
    • Getting started
      • Creating synthetic variables
      • Synthetic Variables' editor
    • Expressions
      • Mathematical
      • Date range
      • Rolling
      • Special functions
    • Specs and limits
    • Examples
      • Mathematical
      • Date range
      • Rolling
      • Special functions
  • ⌨️Developer tools
    • Javascript SDK
      • Overview
      • Getting started
      • Ubidots class
        • Get methods
        • Filter methods
        • Ubidots objects
          • Entity object
          • Paginator
      • Examples
    • CLI
      • Overview
      • Installing
      • Usage
      • SDK for UbiFunctions
  • 🏗️Apps
    • App builder
      • Custom sidebar
Powered by GitBook
On this page
  • Definition
  • Required files
  • src and static directory
  • widget.css
  • widget.html
  • widget.js
  • Naming convention
  • view.xml
  • view_widget.xml
  • LICENSE and README.md files
  • Manifest.toml

Was this helpful?

Export as PDF
  1. Plugins
  2. Private Plugins

Widget

PreviousWebhookNextDevice

Last updated 1 year ago

Was this helpful?

Definition

A private widget plugin is a custom-developed widget that is made available as if they were Ubidots native. As any other widget, it offers both, logic execution and a user graphical interface for interaction.

Its visuals displaying and logic execution are performed at the moment of loading the dashboard and will only take place as long as the dashboard containing it remains open.

For instance, consider the following widget using the JavaScript HighCharts library for data plotting:

When a user accesses the dashboard containing this widget, the browser renders its visuals, and the logic—fetching and plotting the data—runs during the dashboard's load time.

After leaving the dashboard containing the widget, all tasks within its logic will stop.

Required files

As stated before any Private plugin regardless of its type, and, particularly, a private widget plugin, is composed by the file structure shown below:

├── src
│   ├── static                    
│   │   ├── widget.css      
│   │   ├── widget.html 
│   │   ├── widget.js             
│   ├── view.xml
│   ├── view_widget.xml
│   ├── control.py | control.js
│   ├── function.py | function.js
│   ├── user_code.py | user_code.js      
├── LICENSE
├── README.md
├── manifest.toml

src and static directory

Unlike Cron and Webhook plugins, the Widget plugin includes an additional directory called static. This directory holds the widget's HTML, CSS and JavaScript files.

Placing the CSS, HTML and JS files within the root of src and not inside static will cause deployment errors.

widget.css

Written in CSS, it styles the widget's visual components.

widget.html

Written in HTML, this file dictates the arrangement of the widget's visual elements.

widget.js

Written in JavaScript, this handles the plugin's core logic and potentially altering the CSS styles and HTML dynamically.

Naming convention

You ought to retain the names of all files and directories mentioned in the "required files" section, as the plugins engine specifically searches for these files and their extensions.

If the name of a file or directory is changed, the plugin won't be able to be deployed.

view.xml

Though this file is only relevant when using Cron and Webhook type plugins, it still must contain valid placeholder data to deploy the plugin.

view_widget.xml

The form to display its required parameters is created using view_widget.xml, not the view.xml file.

For example, suppose that you are creating a widget that uses HighCharts to plot data, for that reason, the widget requires the following information from the user :

  • Variable label

  • Title

  • Subtitle

  • X axis label

  • Y axis label

  • Series name

A form containing those fields might look like this:

The form above can be built using the view_widget.xml as:

<form>
    <inputcombo
        id="variable_label"
        type="text"
        label="Variable label"
        description="Device's variable label to which send the data"
        placeholder=""
        value=""
    />
    <inputcombo
        id="title"
        type="text"
        label="Chart's title"
        description="Chart's title"
        placeholder=""
        value=""
    />
    <inputcombo
        id="subtitle"
        type="text"
        label="Chart's subtitle"
        description="Chart's subtitle"
        placeholder=""
        value=""
    />
    <inputcombo
        id="x_axis_name"
        type="text"
        label="X-axis name "
        description="X-axis subtitle"
        placeholder=""
        value=""
    />
    <inputcombo
        id="y_axis_name"
        type="text"
        label="Y-axis name "
        description="Y-axis subtitle"
        placeholder=""
        value=""
    />
    <inputcombo
        id="series_name"
        type="text"
        label="Series name"
        description="Name for the Series"
        placeholder="series 1"
        value=""
    />
</form>

All of these parameters in the form are accessible to the widget.js script using the Ubidots JavaScript class.

For detailed information regarding how to access the XML properties from within the widget.js script, refer to the its corresponding section in the Plugins development page

For detailed information about the supported form elements, please head to the view_widget.xml section in the Plugins development page

LICENSE and README.md files

Refer to Private Plugins page to get detailed information:

Manifest.toml

Aside from previously mentioned manifest components common to all plugin types, the following ones are specific to Widget type plugin:

Section/subsection
key
Value
Description
Example

[settings.widget]

name

Any string

This is the name that the Widget will display on the plugins drawer

[settings.widget]

js_thirdparty_libraries*

A list of valid CDN URL

This is the list of libraries that the widget will import to be used on its logic

[settings.widget]

css_thirdparty_libraries*

A list of valid CDN URL

This is the list of libraries that the widget will import to be used on its styling

[settings.widget]

enable_lazy_load

true or false

Enables or disables lazy load for the widget's visual components

With this in mind, a typical Widget plugin manifest file looks like:

manifest_version = 2.0

[settings]
version = "1.1.1"
plugin_type = "widget"
license_name = "MIT license"

[settings.widget]
name = "Send data to device widget"  
js_thirdparty_libraries = [
  "https://code.jquery.com/jquery-3.6.0.min.js",
  "https://code.jquery.com/moment-3.6.0.min.js"
]
css_thirdparty_libraries = [
  "https://code.jquery.com/jquery-3.6.0.min.css",
  "https://code.jquery.com/moment-3.6.0.min.css"
]
enable_lazy_load = true

The keys marked with a * in the table, are not mandatory to be set, that is, you are not complied to import either JS or CSS libraries, however, you should define the key as an empty list.

For instance, if no JS or CSS libraries want to be imported, the manifest will look like:

manifest_version = 2.0

[settings]
version = "1.1.1"
plugin_type = "widget"
license_name = "MIT license"

[settings.widget]
name = "Send data to device widget"  
js_thirdparty_libraries = [ ] //No JS libraries are imported
css_thirdparty_libraries = [ ] //No CSS libraries are imported
enable_lazy_load = true

🧩
nae = " my first Widget plugin"
js_thirdparty_libraries = [
  "https://code.jquery.com/jquery-3.6.0.min.js",
  "https://code.jquery.com/moment-3.6.0.min.js"
]
css_thirdparty_libraries = [
  "https://code.jquery.com/jquery-3.6.0.min.css",
  "https://code.jquery.com/moment-3.6.0.min.css"
]
enable_lazy_load = true
Widget
view_widget.xml
Private Plugins