| Both sides previous revision Previous revision | |
| indigo_2024.2_documentation:plugin_guide [2025/04/10 13:47] – [Custom HTML Config Dialogs] jay | indigo_2024.2_documentation:plugin_guide [2025/04/14 20:10] (current) – external edit 127.0.0.1 |
|---|
| Indigo's folder structure looks like this: | Indigo's folder structure looks like this: |
| |
| {{folder_structure.png?nolink|}} | {{folder_structure.png?nolink|Folder Structure Image}} |
| |
| in this location: | in this location: |
| We created a macOS Finder bundle type, the Indigo plugin bundle (//''.indigoPlugin''//), which has a very specific structure to encapsulate everything that a plugin needs to perform its functions: | We created a macOS Finder bundle type, the Indigo plugin bundle (//''.indigoPlugin''//), which has a very specific structure to encapsulate everything that a plugin needs to perform its functions: |
| |
| {{bundle_layout.png?nolink|}} | {{bundle_layout.png?nolink|Bundle Layout Image}} |
| |
| The first thing you’ll notice is that this is actually a real Finder bundle - so it appears to be a single file called //''Example.indigoPlugin''//. It’s moved around and treated as a single file, and all the user has to do to install your solution is to double-click it in the Finder and Indigo will install and enable it for you. | The first thing you’ll notice is that this is actually a real Finder bundle - so it appears to be a single file called //''Example.indigoPlugin''//. It’s moved around and treated as a single file, and all the user has to do to install your solution is to double-click it in the Finder and Indigo will install and enable it for you. |
| The structure of the //''Server Plugin''// directory in the plugin bundle is something like this: | The structure of the //''Server Plugin''// directory in the plugin bundle is something like this: |
| |
| {{ServerPluginFolder.png?nolink}} | {{ServerPluginFolder.png?nolink|Server Plugin Folder Image}} |
| |
| Each of the XML files describes the components that your plugin provides. You must also have at least the //''plugin.py''// file which is the entry point into the Python code that executes your plugin. Beyond that, you may create any other structure you like inside the folder. We’ll go over each file in detail, but first we should discuss the general characteristics of the XML files. | Each of the XML files describes the components that your plugin provides. You must also have at least the //''plugin.py''// file which is the entry point into the Python code that executes your plugin. Beyond that, you may create any other structure you like inside the folder. We’ll go over each file in detail, but first we should discuss the general characteristics of the XML files. |
| The ConfigUI definition will result in the following dialog being presented to the user: | The ConfigUI definition will result in the following dialog being presented to the user: |
| |
| {{ConfigUIRendering.png?nolink}} | {{ConfigUIRendering.png?nolink|Configuration UI Rendering Image}} |
| |
| When each component type (device, event, action) needs a configuration user interface, and most will need some kind of configuration, it will have a ConfigUI element that describes the UI field elements along with a URL. When the user clicks on help button in the lower left corner (as shown above) their browser will be opened to the URL provided. If no URL is specified then the user will be directed to the main URL specified in the //''Info.plist''// file. | When each component type (device, event, action) needs a configuration user interface, and most will need some kind of configuration, it will have a ConfigUI element that describes the UI field elements along with a URL. When the user clicks on help button in the lower left corner (as shown above) their browser will be opened to the URL provided. If no URL is specified then the user will be directed to the main URL specified in the //''Info.plist''// file. |
| === Text Field === | === Text Field === |
| |
| {{ConfigUI_textfield.png?nolink}} | {{ConfigUI_textfield.png?nolink|Configuration UI Textfield Image}} |
| |
| <code><Field id="simpleTextField" type="textfield" enabledBindingId="checkboxSample" defaultValue="Default Value"> | <code><Field id="simpleTextField" type="textfield" enabledBindingId="checkboxSample" defaultValue="Default Value"> |
| === Popup Menu === | === Popup Menu === |
| |
| {{ConfigUI_menu.png?nolink}} | {{ConfigUI_menu.png?nolink|Configuration UI Menu Image}} |
| |
| <code><Field type="menu" id="simplePopUpButton" defaultValue="item2"> | <code><Field type="menu" id="simplePopUpButton" defaultValue="item2"> |
| === List === | === List === |
| |
| {{ConfigUI_list.png?nolink}} | {{ConfigUI_list.png?nolink|COnfiguration UI List Image}} |
| |
| <code><Field type="list" id="listSample" defaultValue="item1,item3"> | <code><Field type="list" id="listSample" defaultValue="item1,item3"> |
| === Serial Port === | === Serial Port === |
| |
| {{:indigo_2024.2_documentation:configui_serialport_local.png?nolink}} | {{:indigo_2024.2_documentation:configui_serialport_local.png?nolink|Configuration UI Serial Port Local Image}} |
| |
| {{:indigo_2024.2_documentation:configui_serialport_socket.png?nolink}} | {{:indigo_2024.2_documentation:configui_serialport_socket.png?nolink|Configuration Serial Port Socket Image}} |
| |
| {{:indigo_2024.2_documentation:configui_serialport_rfc2217.png?nolink}} | {{:indigo_2024.2_documentation:configui_serialport_rfc2217.png?nolink|Configuration Serial Port RFC2217 Image}} |
| |
| <code><Field type="serialport" id="devicePortFieldId" /></code> | <code><Field type="serialport" id="devicePortFieldId" /></code> |
| === Checkbox === | === Checkbox === |
| |
| {{ConfigUI_checkbox.png?nolink}} | {{ConfigUI_checkbox.png?nolink|Configuration UI Checkbox Image}} |
| |
| <code><Field type="checkbox" id="checkboxSample" defaultValue="true"> | <code><Field type="checkbox" id="checkboxSample" defaultValue="true"> |
| === Label === | === Label === |
| |
| {{ConfigUI_label.png?nolink}} | {{ConfigUI_label.png?nolink|Configuration UI Label Image}} |
| |
| <code><Field id="exampleLabel" type="label"> | <code><Field id="exampleLabel" type="label"> |
| === Separator === | === Separator === |
| |
| {{ConfigUI_separator.png?nolink}} | {{ConfigUI_separator.png?nolink|Configuration UI Separator Image}} |
| |
| <code><Field id="simpleSeparator1" | <code><Field id="simpleSeparator1" |
| === Button === | === Button === |
| |
| {{ConfigUI_button.png?nolink}} | {{ConfigUI_button.png?nolink|Configuration UI Button Image}} |
| |
| <code><Field id="exampleButton" | <code><Field id="exampleButton" |
| === Color Picker === | === Color Picker === |
| |
| {{color_picker_control.png?nolink}} | {{color_picker_control.png?nolink|Color Picker Control Image}} |
| |
| <code><Field id="exampleColorPicker" | <code><Field id="exampleColorPicker" |
| Color Picker fields allow your user to choose a color value. For example, you might provide a method for a user to select a color for an RGB LED device. When the user clicks the color button, Indigo will open the standard macOS color selector dialog. | Color Picker fields allow your user to choose a color value. For example, you might provide a method for a user to select a color for an RGB LED device. When the user clicks the color button, Indigo will open the standard macOS color selector dialog. |
| |
| {{color_selector_dialog.png?nolink}} | {{color_selector_dialog.png?nolink|Color Selector Dialog Image}} |
| |
| After the user selects a color, the color's value will be passed back to your plugin as a ''//values_dict//'' value when the user executes/closes the configuration dialog. Note that the value provided is a standard RGB value as a space-delimited string. You are responsible for converting that value into the format you need like ''//#8000FF//''. | After the user selects a color, the color's value will be passed back to your plugin as a ''//values_dict//'' value when the user executes/closes the configuration dialog. Note that the value provided is a standard RGB value as a space-delimited string. You are responsible for converting that value into the format you need like ''//#8000FF//''. |
| </code> | </code> |
| |
| {{ :indigo_2024.2_documentation:device_sub_type_example.png?nolink&600 |}} | {{ :indigo_2024.2_documentation:device_sub_type_example.png?nolink&600 |Device Subtype Example Image}} |
| |
| In Python: | In Python: |
| === Device Factory === | === Device Factory === |
| |
| {{:indigo_2024.2_documentation:screenshot_2023-02-22_at_1.07.12_pm.png?600&nolink|}} | {{:indigo_2024.2_documentation:screenshot_2023-02-22_at_1.07.12_pm.png?nolink&600|Device Factory Edit Device Group Image}} |
| |
| One way to create "multifunction" devices is to use Indigo's Device Factory method. Device Factory devices are defined by using a special ''%%<DeviceFactory>%%'' node in ''Devices.xml''. A basic Device Factory device definition would look something like this: | One way to create "multifunction" devices is to use Indigo's Device Factory method. Device Factory devices are defined by using a special ''%%<DeviceFactory>%%'' node in ''Devices.xml''. A basic Device Factory device definition would look something like this: |
| The ''self.indigo_log_handler'' is an instance of a custom [[https://docs.python.org/3.10/library/logging.html#handler-objects|Handler]] object that will write (or emit in Python Handler speak) your log messages into the Indigo Event Log. The message type (the left part in the Event Log) is modified so that it reflects the level of the log message (with the exception of the `info` level). For convenience, the various log levels are also represented in color. Here's an example of each level: | The ''self.indigo_log_handler'' is an instance of a custom [[https://docs.python.org/3.10/library/logging.html#handler-objects|Handler]] object that will write (or emit in Python Handler speak) your log messages into the Indigo Event Log. The message type (the left part in the Event Log) is modified so that it reflects the level of the log message (with the exception of the `info` level). For convenience, the various log levels are also represented in color. Here's an example of each level: |
| |
| {{indigo_2024.2_documentation:embedded_script_logging.png?nolink&600}} | {{indigo_2024.2_documentation:embedded_script_logging.png?nolink&600|Embedded Script Logging Image}} |
| |
| |
| and then logging messages will appear with the colors above. Result: | and then logging messages will appear with the colors above. Result: |
| |
| {{indigo_2024.2_documentation:embedded_script_logging.png?nolink&600}} | {{indigo_2024.2_documentation:embedded_script_logging.png?nolink&600|Embedded Script Logging Image}} |
| |
| |