Package lynx

Functions

apiCall

Perform an authenticated call to the API using the gateways credentials. Returning the response as a LUA object.

Parameters

NameOptionalDescription
MethodNoHTTP Method to use
PathNoPath of the URL to request
BodyYesInclude a body in the request
IoTCfgYesConfig to load parameters and authentication from

Example

local res = lynx.apiCall("POST", "/api/v2/functionx/1", {
    type = "test",
    meta = {key1 = "val1"}
})

apiCallRaw

Perform a GET request to the API using the gateways or provided credentials. The result is returned as a string if success or error object.

Parameters

NameOptionalDescription
PathNoPath in the Lynx API to use
IoTCfgYesConfig to load parameters and authentication from

Example

local resRaw = lynx.apiCallRaw("/api/vw/functionx/1")

getFunctions

Fetch a list of functionx objects for the installation using the API.

See API Specification

Parameters

NameOptionalDescription
FilterYesMetadata or type used to filter the functions

Example

local functions = lynx.getFunctions({
    key1 = "value1",
    key2 = "value2"
})

createFunction

Create a new function in the installation using the API.

See API Specification

Parameters

NameOptionalDescription
fnNoThe complete FunctionX object

Example

local fn = {
    type = "example",
    installation_id = 12,
    meta = {
        name = "My exmaple",
        topic_read = "obj/example/sensor/1/value"
    }
}
lynx.createFunction(fn)

deleteFunction

Delete a function in the installation using the API.

See API Specification

Parameters

NameOptionalDescription
idNoID of the function to delete

Example

lynx.deleteFunction(7)

getApps

Performs an API-request and fetches all configured for the current installation.

See API Specification

Example

local apps = lynx.getApps()

downloadApp

Performs a file download using the API to fetch the executable code for an app. The app is returned as a text string.

See API Specification

Parameters

NameOptionalDescription
App-IDYesID of the app to download
VersionYesVersion of the app to download

Example

local appCode = lynx.downloadApp(1, "0.3.5")

getStatus

Fetch last know values from the backend. There is a small delay until published values are available.

See API Specification

Parameters

NameOptionalDescription

Example

local statuses = lynx.getStatus()

getLog

Fetch a log for recorded mqtt values. Usually contains a lot of data.

See API Specification

Parameters

NameOptionalDescription
toNoOnly fetch logs to this time as unix-timestamp
fromNoOnly fetch logs from this time as unix-timestamp
limitNoLimit the amount of log rows fetched

Example

local logs = lynx.getLog(1603365159, 1603355159, 100)

getDevices

Fetch a list of DeviceX objects for the installation using the API.

See API Specification

Parameters

NameOptionalDescription
FilterYesMetadata or type used to filter the devices

Example

local devices = lynx.getDevices({
    key1 = "value1",
    key2 = "value2"
})

createDevice

Create a new DeviceX in the installation using the API.

See API Specification

Parameters

NameOptionalDescription
fnNoThe complete DeviceX object

Example

local dev = {
    type = "example",
    installation_id = 12,
    meta = {
        name = "A device",
        serial = "ABCD1234"
    }
}
lynx.createDevice(fn)

deleteDevice

Delete a device in the installation using the API.

See API Specification

Parameters

NameOptionalDescription
idNoID of the device to delete

Example

lynx.deleteDevice(7)

notify(id, body)

Trigger the backend to handle notifications for a specific output using the API.

See API Specification

Parameters

NameOptionalDescription
idNoID of the output to trigger
bodyYesPayload to include in the request, can be used in templates

Example

local myData = {
    value = 23.5,
    action = "over"
}
lynx.notify(12, myData)