Listening events

Definition:

Ubidots Listening events on are custom events that allow users to programatically interact with Ubidots through the HTML Canvas widget. This way, Ubidots users can register callbacks for said events and execute logic upong their trigerring. They are designed specifically to get information from Ubidots.

Usage:

After declaring an instance of the Ubidots class as:

var ubidots = new Ubidots();

You can set a callback function on that instance for a particular event as:

ubidots.on('UbidotsEvent', function(data){
    //Some logic
});

Where:

  • Ubidots: is the constructor of the Ubidots class

  • ubidots: is an instance of the Ubidots class

  • UbidotsEvent: is any of the following events available on Ubidots.

Listening events:

EventDescriptionResult

receivedToken

Default account token

BBFF-XXXXXXXXXX

selectedDashboardDateRange

Actual selected date range in the dynamic dashboard (timestamp in milliseconds).

{"start":1637006467592,"end":1637095008866}

isRealTimeActive

This event is triggered every time the Real Time button in the Dashboard is clicked.

true or false

dashboardRefreshed

This event is activated when a user clicks the refresh button in the dashboard.

true

selectedDevices

Returns a list containing the ids of the selected devices in a dynamic dashboard

['device-1-id', 'device-2-id', ... ]

selectedDeviceObjects

Returns a list containing the device objects of the selected devices in a dynamic dashboard

[{"name": "device-name", "id": "device-id", "label": "device-label"}, ... ]

selectedDevice

[DEPRECATED] Use selectedDevices instead.

Returns the id of the currently selected device in a dynamic dashboard.

'device-1-id'

selectedDeviceObject

[DEPRECATED] Use electedDeviceObjects instead.

Returns the device object of the currently selected device in a dynamic dashboard.

{"name": "device-name", "id": "device-id", "label": "device-label"}

selectedDashboardObject

Return the whole object of a Dashboard as received when loading the dashboard

{"id": "dashboard-id", "name": "dashboard-name", "organization_data": {"id": 25, "name": "My First Customer", "properties": {"color": "#00BCD4"}}, "timeframe": {"endDate": "now", "startDate": "now-24h"}}

ready

Returns an object with the information of all the other events. See example.

BBFF-XXXXX

{"start":1651761902036,"end":1651848302036}

5e8bb8644763e72e09658f76

Go to the Examples/Interacting with dashboard data section for examples on how to use this events.

Last updated