This vignette introduces the main functions with a few examples.
Credentials and base url for cumulocity are stored in a user’s
private .Renviron
file.
The credentials are defined as follows:
CUMULOCITY_base_url = "[tenant url]"
CUMULOCITY_usr = "[username]"
CUMULOCITY_pwd = "[password]"
The tenant url should be of the form “https://tenant_name.cumulocity.com”.
The file .Renviron
can be edited with
usethis::edit_r_environ()
.
Get devices for the tenant and display a few columns. If no arguments
are passed, get_devices()
returns all devices.
Get measurements for device “temp_001 #1” and plot the result.
Datetimes are returned as character strings; we first convert to
POSIXct
before plotting.
device_id <- 141
meas <- get_measurements(device_id = device_id,
num_rows = 100,
date_from = "2019-09-30T19:59:00Z")
kable(head(meas[c("time", "type", "c8y_Temperature.T.value")]))
time_parsed <- as.POSIXct(meas$time, format = "%Y-%m-%dT%H:%M:%OSZ", tz = "Z")
plot(time_parsed, meas$c8y_Temperature.T.value, type = "l",
xlab = "Time", ylab = "Temperature (deg C)")
We can get events for the other device: