ThingWorx WebSocket-based Edge MicroServer (WS EMS) and Lua Script Resource (LSR) > Remote Things > Remote Thing Configuration at the Device
Remote Thing Configuration at the Device
The Remote Thing at the device level is implemented using the Lua Script Resource (luaScriptResource.exe). This component shares the configuration file with the WSEMS (config.lua, or per your configuration). Make a copy of the file and place it in the etc folder. The example configuration file is self-documented.
scripts.MyEdgeThing = {
file = "thing.lua",
template = "example",
This section defines a Thing, and references a Template = example. In this case, that refers to a file named config.lua.example in the microserver\etc\custom\templates folder. This file is installed with the WS EMS to be used for reference. The template file is for defining properties, services, and tasks at the edge software.
Any of the Remote Thing configuration parameters can be inserted between the brackets { } defined by scripts.MyEdgeThing=.
The template setting is critical. The template file is the definition of the behavior for this edge thing. Each edge thing utilizing the Lua script engine requires a template file reference. The template file should be placed in the \microserver\etc\custom\templates folder. An example file is available after install.
Basic Configuration
The config.lua.example file has a section for module configuration.
The require statements pull a specified shape's functionality into the template. A shape can define properties, services, and tasks, just like a template. If the template defines a property, service, or task with the same name as one defined in a shape, then the definition in the shape will be ignored. Therefore, you must take care not to define characteristics with duplicate names. require "thingworx.shapes.myshapeā€¯
The following line is required in all user-defined templates: 'template.example' should be replaced with the name of template, for example: 'template.mydevice'. module ("templates.example", thingworx.template.extend)
A shape file is the same in structure as a template file. The idea is to create building block files of properties, services, and tasks, and identify them as shapes, which is consistent with the server model terminology. The expected location for these shape files is the \microserver\etc\custom\shapes folder. Using the require statement essentially adds the shape file configuration to the configuration in the template