User Tools

Site Tools


pluginapi:infounits

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
pluginapi:infounits [2023/06/09 15:53] James Sentmanpluginapi:infounits [2023/06/11 14:29] (current) – Added menu handlers section and hasQuery key James Sentman
Line 43: Line 43:
  
 This defines 3 Units each with a unique tag which is required and used internally for indexing and re-assigning this unit type popup and controlling which unit subclass you create in your plugin and so forth.  This defines 3 Units each with a unique tag which is required and used internally for indexing and re-assigning this unit type popup and controlling which unit subclass you create in your plugin and so forth. 
 +
 +The popup is not sorted and will be presented in the order that you put them into the deviceTypes list. You can also add an entry with the name set to “separator” and no other settings to create a standard line separator in the popup. This can be useful to block different types of Unuits together when it makes more sense than just putting them all in alphabetical order. You can see a separator in the example above.
  
 =====Required Keys:===== =====Required Keys:=====
Line 62: Line 64:
 =====Unit Behavior Keys:===== =====Unit Behavior Keys:=====
 These keys are not required and are not permanent for the Unit. They can be edited at any time by the user or set programattically from your plugin. These settings offer a default setup for the Unit when created by the User. If you create them automatically from inside your plugin you still need to include the appropriate keys for the behavior you wish. These keys are not required and are not permanent for the Unit. They can be edited at any time by the user or set programattically from your plugin. These settings offer a default setup for the Unit when created by the User. If you create them automatically from inside your plugin you still need to include the appropriate keys for the behavior you wish.
 +
 +>**hasQuery** Boolean - defaults to false. If this is set then the interface will present an option to send a query where appropriate. If this is set then the contextual menu for the Unit in any list will also have an option to query the Unit. 
 +  “hasQuery”:true,
 +
  
 >**dimmable** Boolean - defaults to false. With this set to true the Unit will be “dimmable” or just able to hold a numerical value. Without this the Unit will be discrete just being able to be turned on or off. Corresponds to the checkbox of the same name. >**dimmable** Boolean - defaults to false. With this set to true the Unit will be “dimmable” or just able to hold a numerical value. Without this the Unit will be discrete just being able to be turned on or off. Corresponds to the checkbox of the same name.
Line 146: Line 152:
 >or possibly something like: >or possibly something like:
   “address”:[“UP”, “DOWN”, “LEFT”, “RIGHT”],   “address”:[“UP”, “DOWN”, “LEFT”, “RIGHT”],
 +
 +
 +-----
 +=====Menu Handlers:=====
 +You can also add callbacks to the plugin by adding items to the contextual menu for the Unit. This is the same technique that you can use to add menu items to the contextual menu of the Interface itself. In this case the “menuHandlers” key is inside the deviceType dictionary rather than in the root of the info.json where they would be assigned to the Interface as a whole. Items added in this way are also given a button in the Advanced Controls (see dynamic interface section below) so the user can access these from the web remotes or via that mechanism as well as through the contextual menu. Note that there is no way to pass any information to plugin from these handlers. They are simply run with no parameters.
 +
 +The data in this key is a json list of lists. Each of the inner lists has 2 items, first the name of the action as you wish it to appear in the menu, the human readable version, and the second is the name of the script handler callback that will be run when the user selects this.
 +
 +Use the Unit parent class “addScriptHandler” command to register a callback to be run when that action name is run by the user.
 +  “menuHandlers”:[[“Open The Door”, “openTheDoor”], [“Knock On the Door”, “knockOnTheDoor”], [“Run Away”, “runAway”], ...]
 +
 +
 +
 +
  
  
pluginapi/infounits.1686326022.txt.gz · Last modified: 2023/06/09 15:53 by James Sentman