Data Provider Catalog Plugin Requests

From MiOS
Revision as of 04:06, 3 December 2008 by Micasaverde (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Here are the possible requests you can make on port 3451 to the Data Provider Catalog Plugin. For a general overview, see Data_Provider_Catalog_Plugin

Built-in requests

user_data
Optional URL Parameters: outputformat=json
Post Variables: parm=[json data to update]

This is the main request to retrieve the configuration and to make changes to it. This returns the current configuration, which is stored in JSON format: http://192.168.81.1:3451/user_data?output_format=json
Go to http://www.jsonlint.com/ to format it nicely for easy reading.

To update information, such as adding rooms, renaming devices, and so on, put the new JSON in the post variable 'parm'. When you are including a JSON object your new objects are by default merged into the current ones unless you can attach the special tag json_action with "add" or "del" to explicitly add or remove something. For example, assume that the data is currently like this:

 "Room": {
       "PK_Room_1": {
           "Description": "Living Room",
           "FK_Section": "1" 
       },
       "PK_Room_2": {
           "Description": "Bedroom",
           "FK_Section": "1" 
       } 

You want to remove the bedroom and add a new room called "Den" and change the Living Room to be called Kitchen. You put the following in the parm post:

{

   "Room": {
       "PK_Room_2": {
           "json_action": "del" 
       },
       "PK_Room_1": {
           "Description": "Kitchen",
       },
       "PK_Room_1000002": {
           "Description": "Den",
           "FK_Section": "1",
           "json_action": "add" 
       } 
   }

}

Note that Sections, Rooms, Devices, and Scenes are all numbered: PK_Room_1, scene_2, etc. When are adding new Sections, Rooms, Devices, and Scenes, use a number that is very high (> 1,000,000) to prevent conflicts. See how Room

Personal tools