MyNixOS website logo
Description

'ThingsBoard' API.

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.

Rthingsboard

License:AGPL-3 R buildstatus

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.

Installation

You can install the released version of ‘Rthingsboard’ from CRAN with:

install.packages("Rthingsboard")

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("DDorch/Rthingsboard")

Example

This is a basic example which shows you how to extract data from the following public dashboard : http://scada.g-eau.fr/dashboard/4db16100-f3e9-11e8-9dbf-cbc1e37c11e3?publicId=299cedc0-f3e9-11e8-9dbf-cbc1e37c11e3

Load library

library(Rthingsboard)

Define the configuration parameters

# Identifier of SupAgro Halle hydraulique SCADA
url = "http://scada.g-eau.fr"
publicId = "299cedc0-f3e9-11e8-9dbf-cbc1e37c11e3"
entityId = "18d56d50-f3e9-11e8-9dbf-cbc1e37c11e3"
startDate = as.POSIXct("2020-11-19 15:00:00", tz = "Europe/Paris")
endDate = as.POSIXct("2020-11-19 18:00:00", tz = "Europe/Paris")

# Set logger threshold to DEBUG to see extra messages for debug purpose
logger::log_threshold(logger::DEBUG)

Connexion to the ‘ThingsBoard’ server

First, you need to create an object of class ThingsboardApi as follow:

# Connection to the API
tb_api = ThingsboardApi(url = url, publicId = publicId)

Retrieve data from the ‘ThingsBoard’ server

You can get the available keys on the specified device defined by its entityId:

# Get list of keys
keys = tb_api$getKeys(entityId = entityId)

Knowing the name of the available keys, you can get the telemetry of this device for a given period defined by startTS and endTS.

Here below, we download the telemetry for all keys beginning by “Y”:

df <- tb_api$getTelemetry(entityId,
                       keys = keys[grep("^Y", keys)],
                       startTs = startDate,
                       endTs = endDate)

Here below the first records of the extracted telemetry:

knitr::kable(head(df))
keytsvalue
Y02020-11-19 17:59:552.9683
Y02020-11-19 17:59:502.7493
Y02020-11-19 17:59:452.6398
Y02020-11-19 17:59:402.7493
Y02020-11-19 17:59:352.7493
Y02020-11-19 17:59:302.7493

You can then record this table into a file in the current directory:

# getwd() # to get the path of the current directory
write.csv2(df, "myData.csv")

And also plot some time series:

library(ggplot2)
ggplot(df, aes(x = ts, y = value)) +
  geom_line(aes(color = key), size = 1) +
  scale_color_brewer(palette = "Set1")
Metadata

Version

0.2.7

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows