Title: | 'ThingsBoard' API |
---|---|
Description: | The goal of 'Rthingsboard' is to provide interaction with the API of 'ThingsBoard' (<https://thingsboard.io/>), an open-source IoT platform for device management, data collection, processing and visualization. |
Authors: | David Dorchies [aut, cre] |
Maintainer: | David Dorchies <[email protected]> |
License: | AGPL-3 |
Version: | 0.2.7 |
Built: | 2024-11-24 03:54:53 UTC |
Source: | https://github.com/ddorch/rthingsboard |
This function allows to convert epoch timestamp in seconds to an epoch in milliseconds
Date2EpochMilli(ts) ## S3 method for class 'POSIXt' Date2EpochMilli(ts) ## S3 method for class 'numeric' Date2EpochMilli(ts)
Date2EpochMilli(ts) ## S3 method for class 'POSIXt' Date2EpochMilli(ts) ## S3 method for class 'numeric' Date2EpochMilli(ts)
ts |
a character of the epoch in milliseconds
Date2EpochMilli(as.numeric(Sys.time()))
Date2EpochMilli(as.numeric(Sys.time()))
Convert an epoch in milliseconds into a date
EpochMilli2Date(x, timezone = "GMT")
EpochMilli2Date(x, timezone = "GMT")
x |
A character or a numeric representing an epoch in milliseconds |
timezone |
A character with the time zone used for the conversion |
A POSIXct, the date corresponding to the epoch
epoch <- Date2EpochMilli(as.numeric(Sys.time())) EpochMilli2Date(epoch)
epoch <- Date2EpochMilli(as.numeric(Sys.time())) EpochMilli2Date(epoch)
This method is automatically call by each other methods of the class ThingsboardApi. So, except for debugging purpose, it's not useful to call directly.
Fetch data keys for an entity
entityId |
character entity ID |
entityType |
character (default "DEVICE") |
The description of this operation in API documentation is here: https://thingsboard.io/docs/user-guide/telemetry/#get-telemetry-keys
A vector of character with the keys available for the requested device.
Fetch telemetry data of an entity.
It uses the following API: https://thingsboard.io/docs/user-guide/telemetry/#get-telemetry-values
The method getValues
has a strong limitation as the 'ThingsBoard' API only send the
100 last values of each key. The method getTelemetry
overcomes this limitation by
automatically by calling getValues
in a loop.
entityId |
A character with the entity ID given (See https://thingsboard.io/docs/user-guide/entity-views/) |
keys |
Vector of character with the list of keys from which getting the telemetry values |
entityType |
A character (default "DEVICE") |
startTs |
A numeric or a POSIXct representing respectively the epoch or the date of the start of data extraction period |
endTs |
A numeric or a POSIXct representing respectively the epoch or the date of the end of data extraction period |
A data.frame with one row per data and 3 columns:
key
: a character with the key
ts
: a POSIXct with the timestamp of the data
value
: a numeric with the value of the data
This method is automatically called by ThingsboardApi_checkToken, and so by any other methods of the class ThingsboardApi as needed. Except for debugging purpose, it's not useful to call directly.
timeOut |
numeric number of second before token timeout (default field |
A list with keys 'token' and 'refreshtoken'
Thingboard API Class
url
character URL of the 'ThingsBoard' IoT platform.
publicId
character the public ID of the device
token
character the current token
tokenTimeOut
A numeric contains the time out of a token in seconds (default 300)
tokenEpiration
A numeric with the Epoch of the expiration date time of current token
The ThingsboardApi
class methods :
ThingsboardApi_checkToken for checking and refreshing the token
ThingsboardApi_getToken for getting authorisation token from Thingsboard server for a specific device
ThingsboardApi_getKeys for fetching data keys of an entity
ThingsboardApi_getValues and ThingsboardApi_getTelemetry for fetching telemetry of an entity
thinksboard_api = tryCatch( { ThingsboardApi(url="http://scada.g-eau.fr", publicId="299cedc0-f3e9-11e8-9dbf-cbc1e37c11e3") }, error = function(e) { message("An error occured:\n", e) return(FALSE) } )
thinksboard_api = tryCatch( { ThingsboardApi(url="http://scada.g-eau.fr", publicId="299cedc0-f3e9-11e8-9dbf-cbc1e37c11e3") }, error = function(e) { message("An error occured:\n", e) return(FALSE) } )