Plugin Creation Tutorial
From MiOS
(Difference between revisions)
Line 6: | Line 6: | ||
:The Description file is the prime anchor. All the other files are eventually reached by following the links in the chain or to be more precise; from XML <tag> to XML <tag>. The Description file contains the top level information about the plugin and then links to the Service file(s) as described below: | :The Description file is the prime anchor. All the other files are eventually reached by following the links in the chain or to be more precise; from XML <tag> to XML <tag>. The Description file contains the top level information about the plugin and then links to the Service file(s) as described below: | ||
*Zero or more service files: S_GenericPlugin.xml | *Zero or more service files: S_GenericPlugin.xml | ||
− | :There are many Service files supplied with Vera, which contain the service descriptions for common requirements, such as on/off switches. This allows for consistency among devices. Refer to the [[Luup_UPNP_Files#Device_Files|list of service files provided]]. However in many cases the services you require may not exist. In which case you describe them in your own Service file(s) and then implement them in your Implementation file. | + | :There are many Service files supplied with Vera, which contain the service descriptions for common requirements, such as on/off switches. This allows for consistency among devices. Refer to the [[Luup_UPNP_Files#Device_Files|list of service files provided]] with more [[Luup_Devices|detail here.]] However in many cases the services you require may not exist. In which case you describe them in your own Service file(s) and then implement them in your Implementation file. |
*One device implementation file: I_GenericPlugin.xml | *One device implementation file: I_GenericPlugin.xml | ||
:Refer to [[Luup_Plugins_ByHand]] and [[Luup_Plugins_ByHand]] The Implementation file contains the Actions/Lua code required to implement the services specified in the Service file(s) | :Refer to [[Luup_Plugins_ByHand]] and [[Luup_Plugins_ByHand]] The Implementation file contains the Actions/Lua code required to implement the services specified in the Service file(s) | ||
Line 13: | Line 13: | ||
==Files to help manage User Interface (UIx) executed in the web browser== | ==Files to help manage User Interface (UIx) executed in the web browser== | ||
*Zero or one device interface file: D_GenericPlugin.json | *Zero or one device interface file: D_GenericPlugin.json | ||
− | :Refer to [[Luup_plugins:_Static_JSON_file]] and [[Luup_plugin_tabs]] You only need this file if you want to control the device directly in the User Interface. If it is not present you can still control the device by invoking its services through scenes, Lua code, URL calls and the like. | + | :Refer to [[Luup_plugins:_Static_JSON_file]] and [[Luup_plugin_tabs]] You only need this file if you want to control the device directly in the User Interface. If it is not present you can still control the device by invoking its services through scenes, Lua code, URL calls and the like. This file also contains links to the [[Luup_plugin_icons|Icons]] to be used by the device |
*Zero or more JavaScript files: J_GenericPlugin.xml | *Zero or more JavaScript files: J_GenericPlugin.xml | ||
− | :Called by device JSON file above. Only required when you need the User Interface to do more unusual stuff, rather say just displaying labels, buttons and sliders. The use of this file just depends on how complex the interface to your device is. It's | + | :Called by device JSON file above. Only required when you need the User Interface to do more unusual stuff, rather say just displaying labels, buttons and sliders. The use of this file just depends on how complex the interface to your device is. It's often not needed. |
Revision as of 04:53, 13 June 2013
Plugin structure
A Luup plugin is composed of several types of files that can be broken into two groupings:
Files to manage the creation and execution of code in Vera
- One device description file: D_GenericPlugin.xml
- The Description file is the prime anchor. All the other files are eventually reached by following the links in the chain or to be more precise; from XML <tag> to XML <tag>. The Description file contains the top level information about the plugin and then links to the Service file(s) as described below:
- Zero or more service files: S_GenericPlugin.xml
- There are many Service files supplied with Vera, which contain the service descriptions for common requirements, such as on/off switches. This allows for consistency among devices. Refer to the list of service files provided with more detail here. However in many cases the services you require may not exist. In which case you describe them in your own Service file(s) and then implement them in your Implementation file.
- One device implementation file: I_GenericPlugin.xml
- Refer to Luup_Plugins_ByHand and Luup_Plugins_ByHand The Implementation file contains the Actions/Lua code required to implement the services specified in the Service file(s)
- Zero or more Lua files: L_GenericPlugin.xml
- Typically your Lua code is placed in the Implementation file. However for large programs this can make testing a little difficult and the program hard to read or unwieldy. Instead, you can place all you code in the Lua File and just make calls to it from the Implementation file. The use of this file is therefore optional.
Files to help manage User Interface (UIx) executed in the web browser
- Zero or one device interface file: D_GenericPlugin.json
- Refer to Luup_plugins:_Static_JSON_file and Luup_plugin_tabs You only need this file if you want to control the device directly in the User Interface. If it is not present you can still control the device by invoking its services through scenes, Lua code, URL calls and the like. This file also contains links to the Icons to be used by the device
- Zero or more JavaScript files: J_GenericPlugin.xml
- Called by device JSON file above. Only required when you need the User Interface to do more unusual stuff, rather say just displaying labels, buttons and sliders. The use of this file just depends on how complex the interface to your device is. It's often not needed.