|  Developer
Updated on January 4, 2022

Plugin Types

MiOS has 3 types of plugin.
1 – Gateway Plugin:
config.json example:
				
					{
  "id": "example",
  "version": "1.0",
  "type": "gateway",

<snip - rest of config.json file >
				
			
Once you have created a gateway plugin, you can select the devices created by the plugin as a (logical) device in a meshbot trigger. This screenshot shows a target device called ‘Fake Switch’ which was created by plugin:
Logical / Virtual devices – You can create any type of virtual/logical device via a gateway plugin. Virtual devices work just like physical devices and can save you time via automation. They can also act as a ‘universal translator’ for unsupported devices. You can read more about the advantages of logical / virtual devices here

Items (aka ‘capabilities’) and settings

  • Item is the word used throughout our API to describe a capability of a device. For example ‘Thermostat Fan State’ is a capability (item) of a thermostat device. ‘Start Recording’ and ‘Stop Recording’ are capabilities (items) of a camera device. Items can be set or just read (get). Capabilities which can be set are exposed as ‘Actions’ in meshbots. Capabilities which also can be read are exposed as ‘Triggers’ in meshbots.
  • Setting
    Settings are direct settings for device capabilities/items. With gateway plugins, you can create settings for your logical devices. These can provide data sources in the ‘trigger’ part of a meshbot.
You can read more about devices, settings and items in the Concepts and Terminology section of the quick start guide.
2 – Library Plugin
Plugins that are used as a dependency by other plugins. Library plugins are usually called as a module by another plugin script. Here’s an example of library plugin usage with a library called ‘example’:
				
					local lib = require( "example" )
lib.print( "LIB" )
lib.hello()
				
			
config.json example:
				
					{
  "id": "example",
  "version": "1.0",
  "type": "library",
  "permissions": [],
  "dependencies": {
    "firmware": "1.0",
    "addons": [
      {
        "id": "lua",
        "version": "1.0"
      }
    ]
  },
  "library": {
    "entryPoint": "HUB:example/scripts/main",
  }
}
				
			
In the example above, the entrypoint script is run once the first time the library is required:
				
					local result = {}
result.print = function(...)
     print(...)
end
result.hello = function()
     print( "hello" )
end
result.add = function(a,b)
     return a + b
end
result.print_time = function(a,b)
     local core = require "core"
     print( core.get_local_time() )
end
return result
				
			
3 – Extension Plugin
These plugins add functionality to an existing plugin without modifying the original plugin. Extensions can work with existing devices but cannot create their own devices. Extension plugins are not yet ready but are coming soon.
Lua is the language used for MiOS plugins.