Title: | Access to METER ZentraCloud API |
---|---|
Description: | Provides functions to access the METER ZENTRACLOUD API. |
Authors: | Carola Stolle [cre, aut], Christoph Stepper [aut], Florian Detsch [aut], Tim Appelhans [aut], Eric Scott [ctb] , Joran Beasley [ctb] |
Maintainer: | Carola Stolle <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.4.9 |
Built: | 2024-11-11 06:31:11 UTC |
Source: | https://gitlab.com/meter-group-inc/pubpackages/zentracloud |
Clear package cache of files older then the specified number of days.
clearCache( cache_dir = getOption("ZENTRACLOUD_CACHE_DIR"), file_age = getOption("ZENTRACLOUD_CACHE_MAX_AGE") )
clearCache( cache_dir = getOption("ZENTRACLOUD_CACHE_DIR"), file_age = getOption("ZENTRACLOUD_CACHE_MAX_AGE") )
cache_dir |
|
file_age |
|
clearCache
is automatically called when the package is attached.
Query data from the ZENTRA Cloud API for a specific device serial number and time period.
getReadings( device_sn, start_time, end_time, force_api = FALSE, ignore_cache = FALSE )
getReadings( device_sn, start_time, end_time, force_api = FALSE, ignore_cache = FALSE )
device_sn |
|
start_time , end_time
|
|
force_api |
|
ignore_cache |
|
Options
To use getReadings()
, valid values for the ZENTRACLOUD options must be
set (see setZentracloudOptions()
). Make sure that the token
and
domain
match.
Cache
Per default, a cache directory is created at the location specified in the
ZENTRACLOUD_CACHE_DIR
option at first function-call.
Here, the data are saved, sorted by device, sensor, year and month.
For subsequent calls, the cache is checked for already
existing data before the API is called again.
A list
of data.frames
for the queried time period with columns for
datetime and all values. One list entry for each logger.
Unit and precision of each value are stored as attributes
of the respective columns.
## Not run: setZentracloudOptions( token = Sys.getenv("ZENTRACLOUD_TOKEN") ) dat = getReadings( device_sn = "06-01185" , start_time = "2022-03-20 00:00:00" , end_time = "2022-03-26 23:59:00" ) ## End(Not run)
## Not run: setZentracloudOptions( token = Sys.getenv("ZENTRACLOUD_TOKEN") ) dat = getReadings( device_sn = "06-01185" , start_time = "2022-03-20 00:00:00" , end_time = "2022-03-26 23:59:00" ) ## End(Not run)
Five package options are set, see Arguments. For retrieving the current
set of options use getZentracloudOptions()
.
setZentracloudOptions( token, domain = "default", cache_dir = NULL, cache_max_age = NULL, cache_max_size = NULL ) getZentracloudOptions()
setZentracloudOptions( token, domain = "default", cache_dir = NULL, cache_max_age = NULL, cache_max_size = NULL ) getZentracloudOptions()
token |
valid token for the ZENTRA Cloud API that is to be saved to the options. |
domain |
|
cache_dir |
directory for setting up the cache. If |
cache_max_age |
the maximum file age allowed to be cached (in days).
If |
cache_max_size |
the maximum cache size (in Kb). If |
token
s are only valid for a specific domain
. Currently, the match is not
verified here.
setZentracloudOptions( token = "tkn1!$" , domain = "default" ) str( getZentracloudOptions() )
setZentracloudOptions( token = "tkn1!$" , domain = "default" ) str( getZentracloudOptions() )
The function accesses the v.1 ZENTRA Cloud API to read the device settings for the given serial number. Settings include information on measurement intervals, device location and time settings.
queryDeviceSettings(device_sn)
queryDeviceSettings(device_sn)
device_sn |
|
To use this function, valid values for the ZENTRACLOUD options must be
set (see setZentracloudOptions()
). Make sure that the token
and
domain
match.
A list
object with three entries, containing device settings and meta
information.
## Not run: set = queryDeviceSettings( device_sn = "06-01185" ) ## End(Not run)
## Not run: set = queryDeviceSettings( device_sn = "06-01185" ) ## End(Not run)
Load all files that are saved in the cache.
readCache(cache_dir = getOption("ZENTRACLOUD_CACHE_DIR"))
readCache(cache_dir = getOption("ZENTRACLOUD_CACHE_DIR"))
cache_dir |
|
A list with entries for each device that was found and all associated data, sorted by logger.
## Not run: all_cached = readCache(cache_dir = getOption("ZENTRACLOUD_CACHE_DIR")) ## End(Not run)
## Not run: all_cached = readCache(cache_dir = getOption("ZENTRACLOUD_CACHE_DIR")) ## End(Not run)
Subset of example data return from getReadings
.
zentra_data
zentra_data
A list
with 6 elements for different sensor/port combinations,
each containing a time series of the respective measurements.
METERGROUP
## Not run: zentra_data = getReadings( device_sn = "06-01185" , start_time = "2022-06-01 00:00:00" , end_time = "2022-06-14 23:59:00" , force = FALSE ) ## End(Not run)
## Not run: zentra_data = getReadings( device_sn = "06-01185" , start_time = "2022-06-01 00:00:00" , end_time = "2022-06-14 23:59:00" , force = FALSE ) ## End(Not run)