# Websockets Interface documentation All requests and responses are sent as json objects. ## Request Every request must conatin at least one value: `command` ``` { "command": "" } ``` ### Device manager commands #### Save config `dm_save` Saves config to ./flapconfig.json. Request: ``` { "command": "dm_load" } ``` Response: ``` { "ack": true } ``` #### Load config `dm_load` Loads config from ./flapconfig.json. Request: ``` { "command": "dm_load" } ``` Response: ``` { "ack": true } ``` #### Dump config `dm_dump` Dumps current config to socket. Request: ``` { "command": "dm_dump" } ``` Response: ``` { "devices_all": "devices_online": , "devices": , "map": <2D array of device locations> } ``` #### Describe single device `dm_describe` Gets all information for specified device id. Request: ``` { "command": "dm_describe", "id": } ``` Response: ``` { ... } ``` #### Register new device `dm_register` Register device, assign new id and assign a location. ``` { "command": "dm_describe", "address": , "x": , "y": , } ``` Response: ``` { "id": } ``` #### Remove device from config `dm_remove` Removes device from config and frees location in screen Request: ``` { "command": "dm_remove", "id": } ``` Response: ``` { "ack": true } ``` #### Remove device from config `dm_refresh` Refresh device config Request: ``` { "command": "dm_refresh" } ``` Response: ``` { "devices_online": } ``` ### Device raw commands #### Ping module `dr_ping` Checks if a module reponds on the given address. Request: ``` { "command": "dr_ping", "address":
} ``` Response: ``` { "success": } ``` #### Set module address `dr_setaddress` Changes the hardware address of an module. Request: ``` { "command": "dr_setaddress", "address":
, "newaddress": } ``` Response: ``` { "success": } ``` #### Set module offset calibration `dr_setcalibration` Sets the offset calibration for an module. Request: ``` { "command": "dr_setcalibration", "address":
, "calibration": } ``` Response: ``` { "success": } ``` #### Reset module `dr_reset` Resets the controller of an module Request: ``` { "command": "dr_reset", "address":
} ``` Response: ``` { "ack": true } ``` #### Display flap `dr_display` Sets the module to the specified flap directly or with recalibration. Request: ``` { "command": "dr_display", "address":
, "flap": , ("full": ) } ``` Response: ``` { "ack": true } ``` #### Power module on/off `dr_power` Sets the power-state for the motor of the given module. Request: ``` { "command": "dr_power", "address":
, "power": } ``` Response: ``` { "ack": true } ``` ## Responses ### Error: ``` { "error": "", "detail": "" } ``` The following responses are valid: - `parsing error`: the json request is malformated and cannot be parsed - `format error`: the json object is missing required fields. Check details for more information. - `internal error`: an internal error occured. This should not happen. Chaeck server logs.