IoT Open Tech
Home
  • Platform
  • Modules
  • Devices
Guides
Changelog
  • English
  • Svenska
Home
  • Platform
  • Modules
  • Devices
Guides
Changelog
  • English
  • Svenska
  • Platform

    • IoT Open Lynx Platform
    • Lynx Architecture
    • Main objects
    • DeviceX / FunctionX
    • Metadata
      • Known meta-keys
    • Icons
    • Schedules
    • Edge Apps
      • The app.json file
      • Package edge.lynx
      • Package timer
      • Package json
      • Package mq
      • Package log
      • Package edge
    • Notifications
      • Templating language
      • Executors
    • Events
    • Permissions
    • API Reference and Libraries

Package edge

Matching criterias

Criterias are a collection of key/value pairs that must all match for a given device or function in order to return true.

Values are matched with wildcard and runs the fnmatch function under the hood with FNM_EXTMATCH as flags.

eg:

-- find a temperature sensor in the kitchen
local kitchenTemperature = edge.findFunction({type = "*temp*", room = "kitchen"})

Functions

edge:time

Get the current unix time with millisecond precision.

Example

local t = edge:time()

edge:tick

Get the current tick. This is a monotonic clock.

Example

local t = edge:tick()

edge.findFunction

Find the first function matching a criteria from the local cache.

Example

local func1 = edge.findFunction(153)
local func2 = edge.findFunction({type="temperature"})
log.i("function1 name %s", func1.meta.name)
log.i("function2 name %s", func2.meta.name)

edge.findDevice

Find the first device matching a criteria from the local cache.

Example

local device1 = edge.findDevice(153)
local device2 = edge.findDevice({type="temperature"})
log.i("device1 name %s", device1.meta.name)
log.i("device2 name %s", device2.meta.name)

edge.findDevices

Find the devices matching a criteria from the local cache.

Example

-- find the specific functions with id 123 and 124
local devs1 = edge.findFunctions({123,124})
-- find all functions of type temperature
local devs2 = edge.findFunction({type="temperature"})
for i, dev in ipairs(devs1) do
    log.i("Functionlist1: name %s", dev.meta.name)
end
for i, dev in ipairs(devs2) do
    log.i("Functionlist2: name %s", dev.meta.name)
end

edge.findFunctions

Find the functions matching a criteria from the local cache.

Example

-- find the specific devices with id 123 and 124
local funcs1 = edge.findFunctions({123,124})
-- find all devices of type lora
local funcs2 = edge.findFunction({type="lora"})
for i, fn in ipairs(funcs1) do
    log.i("Functionlist1: name %s", fn.meta.name)
end
for i, fn in ipairs(funcs2) do
    log.i("Functionlist2: name %s", fn.meta.name)
end
Last updated:
Prev
Package log