{
    "id": "node_test_plugin",
    "version": "1.1",
    "meta": {
        "name": {
            "text": "Node test plugin"
        },
        "description": {
            "text": "This plugin will create a fake switch with an item upon installation."
        },
        "author": {
            "text": "Ezlo Cloud Device Integration team"
        },
        "type": "node",
        "language": "lua",
        "placement": {
            "static": true,
            "custom": true
        }
    },
    "type": "gateway",
    "dependencies": {
        "firmware": "2.0",
        "addons": [
            {
                "id": "lua",
                "version": "1.0"
            }
        ]
    },
    "permissions": [
        "core",
        "http",
        "json",
        "logging",
        "storage",
        "timer"
    ],
    "executionPolicy": "restoreLastScriptState",
    "startup": "scripts/startup",
    "teardown": "scripts/teardown",
    "gateway": {
        "name": "Node test plugin",
        "label": "Node test plugin",
        "forceRemoveDeviceCommand": "HUB:node_test_plugin/scripts/delete_device",
        "setItemValueCommand": "HUB:node_test_plugin/scripts/set_item_value",
        "setItemValueResponsePolicy": "auto"
    }
}
				
			
				
					// 'config.json' is where you define configuration attributes, dependencies and metadata:

// Name
// Version
// Type
// Metadata (User friendly name, description, author)
// Dependencies
// References
// Execution Policy
// Entry and Exit points

// 'config.json' must be in the top level directory. Its name cannot be changed.

{
    "id": "node_test_plugin",
    "version": "1.1",
    
// 'id' is The name of your plugin as it will be known in the file-system. This id should be unique among your plugins on a specific hub.

// The plugin install folder on the firmware and the tar.gz archive name should have the same name as this config.json “id” value.

// Your custom plugin is referenced in the API by the name you assign to it in this “id” line. For example, ‘node_test_plugin’ is the name of the plugin defined here:

//  {
//     "id": "node_test_plugin",
//      "version": "1.1",

// This identifier is used in the path when calling scripts and other API components. For example,

// constants = require(HUB:node_test_plugin/scripts/definitions/constants”),

    "meta": {

// 'meta' is an object which contains public-facing/general information about the plugin. 

// This object is described in our API documents at https://developer.mios.com/api/hub/user-functionality/custom-scripts/hub-custom-nodes-list/ 
 
        "name": {
            "text": "Node test plugin"
        },
        "description": {
            "text": "This plugin will create a fake switch with an item upon installation."
        },
        "author": {
            "text": "Ezlo Cloud Device Integration team"
        },
        "type": "node",
        "language": "lua",
        "placement": {
            "static": true,
            "custom": true
            
// “name”/”description”/”author” - public-facing information about the plugin.

// “type” - this should always be “node”.

// “language” - must be set to “lua”.

// "placement": {
//      “static”: true
//      “custom”: true 

//       You must have "static": true and "custom": true as shown. The plugin will fail 
//       if these are omitted or are specified as a different type. 
        }
    },
    "type": "gateway",

// The type of plugin you are creating. You must use 'gateway' as the type here. 

// 'gateway' plugins can create logical (virtual) devices, items (device capabilities) and settings (capability values).

// After creating a gateway plugin, you can select the devices created by the plugin as a (logical/virtual) device in a meshbot trigger.

// You can read more about the gateway type of plugin at https://developer.mios.com/docs/create-plugins/plugin-types/

// You can read more about devices, items and settings at https://developer.mios.com/docs/create-plugins/quick-start-guide/#concepts-and-terminology 

    "dependencies": {
        
// The 'dependencies' section lists the minimum firmware version and addon versions that are required for your plugin to run. 

        "firmware": "2.0",
        "addons": [
            {
                "id": "lua",
                "version": "1.0"
            }
        ]
    },
    "permissions": [

// 'Permissions' is a list of the Lua modules that you want to use in the plugin. End-users will have to agree to let the plugin use these permissions when they install it.

// For example, a plugin which requires http requests will need to specify the HTTP module and its events as listed at https://developer.mios.com/api/scripting/modules/http/functionality/http-request/. 

// Full list of Lua modules for which you can request permissions: https://developer.mios.com/api/scripting/lua/list-of-lua-modules/ 

        "core",
        "http",
        "json",
        "logging",
        "storage",
        "timer"
    ],
    "executionPolicy": "restoreLastScriptState",

// 'executionPolicy' lets you specify that a plugin saves a global state and restores it when the plugin is re-started. 

// Read more on execution policy options at https://developer.mios.com/api/hub/plugins/executionpolicy/

    "startup": "scripts/startup",
    
// 'startup' refers to 'startup.lua'. 

// This line lets you specify a path to a startup script that is called every time the firmware is started or rebooted. In our example, ‘startup.lua’ is loaded next after config.json and can call other scripts from within it. 

// Users must first login to their account before we can begin adding devices to the plugin. This is because we need to know how many devices they already have on the plugin.

// Once access rights have been verified, the script will call the device creation script with the following command:

// loadfile(“HUB:node_test_plugin/scripts/functions/create_device””)()

// This loads ‘create_device.lua’ which contains a call to 'core.add.device' in the core module. 

// See the annotated startup.lua file in this section for more info on startup.lua

// See the annotated create_device.lua in this section for more info on create_device.lua 

    "teardown": "scripts/teardown",

// This line calls 'teardown.lua' when the plugin is uninstalled. 'teardown.lua' is a script which contains cleanup logic to remove devices, temporary files, timers etc created by the plugin on the hub. This saves resources on the hub.

    "gateway": {
        
// Configure the name, label and commands for the plugin. ‘Gateway’ is the entity created to orchestrate all the devices and items created by the plugin.

// All commands and fields you can add to the “gateway” section are listed at https://developer.mios.com/api/hub/plugins/api/gateway/. 

// Some are required and others optional. You should include all ‘required’ commands and any ‘optional’ commands that are needed by your plugin.

        "name": "Node test plugin",

// [Required] - "name:" is the internal id of the plugin. This name identifies the plugin in the list of hub plugins at https://developer.mios.com/api/hub/gateways-api/hub-gateways-list/

// This allows the system to call and reference the plugin. The gateways list mentioned above contains references to generic scripts about each plugin. These include gateway value set commands, dictionary value set commands, ready status, unreachable actions and so forth. 

        "label": "Node test plugin",
        
// [Required] - "label:" is the public-facing name of the plugin for end-users.

        "forceRemoveDeviceCommand": "HUB:node_test_plugin/scripts/delete_device",

// [Required] - "forceRemoveDeviceCommand" calls a script to uninstall a device. Example:

// "forceRemoveDeviceCommand": "HUB:node_test_plugin/scripts/delete_device",

// In the example above, ‘delete_device’ calls ‘delete_device.lua’, which uses the following command to remove a device:

// hub.device.force_remove (https://developer.mios.com/api/hub/devices/api/hub-device-force_remove/)

        "setItemValueCommand": "HUB:node_test_plugin/scripts/set_item_value",

//  [Required] - "setItemValueCommand" calls a script which defines a device capability (aka ‘item’). For example, ‘Take a snapshot’ on a camera device. Example:

// "setItemValueCommand": "HUB:node_test_plugin/scripts/set_item_value",

// In the example above, ‘set_item_value' calls ‘set_item_value.lua’ which uses one of the following three commands to specify a device capability (item):

// 1) https://developer.mios.com/api/hub/items/api/hub-item-value-set-single-item/
// 2) https://developer.mios.com/api/hub/items/api/hub-item-value-set-multiply-items-with-one-value/
// 3) https://developer.mios.com/api/hub/items/api/hub-item-value-set-different-items-with-different-values/

        "setItemValueResponsePolicy": "auto"

// [Optional] - "setItemValueResponsePolicy" specifies the response type for requests sent by hub.item.value.set (single or multiple version - see above). The response policy field applies to Linux firmware only. Example:

// "setItemValueResponsePolicy": "auto"

// Possible values: 

// “auto” - The firmware sends the response immediately after receiving the hub.item.value.set request. This is the default setting.

// “custom” - The plugin is responsible for sending the response to the hub.item.value.set request. It must call core.send_response() to do this. You must specify an additional parameter, “operation id”, in the script you call in setSettingValueCommand. The firmware will send a timeout error if the plugin was unable to send a response within 2 minutes.

// ** The next command *is not included* in the "gateway" section of our example config,json file. We include it here as just another example of a command you can use:

// "setSettingValueCommand": 
   
// [Optional] - "setSettingValueCommand" calls a script to modify the value of a device capability (aka ‘item’). Example:

// "setSettingValueCommand": "HUB:node_test/scripts/set_setting_value"

// In the example above, ‘set_setting_value’calls a script named ‘set_setting_value.lua’ which uses the following command to specify a capability value:

// hub.device.setting.value.set (https://developer.mios.com/api/hub/devices/settings/api/hub-device-setting-value-set/)

    }
}