Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
en:protocole_json [2014/05/20 00:29] naguirre created |
en:protocole_json [2021/09/16 21:39] (current) mifrey [In url with HTTP GET] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Calaos Webservice protocol ====== | ====== Calaos Webservice protocol ====== | ||
- | Calaos server has a communication protocol | + | Calaos server has a communication protocol |
===== Requests details ===== | ===== Requests details ===== | ||
- | Requests are made via HTTPS directly on calaos server. Requests have the following URL :: | + | Requests are made via HTTPS directly on calaos server. Requests have to be done on the following URL : |
https:// | https:// | ||
Line 11: | Line 11: | ||
===== Testing ===== | ===== Testing ===== | ||
- | It' | + | ==== Wget ==== |
+ | It is possible to test the API using command line tools like [[http:// | ||
- | ==== Wget Example ==== | + | Data in JSON format are placed in the file // |
- | Data to be sent has the JSON format and are places in the file //query.json//. The resulting file will be then //result.json// | + | wget --no-check-certificate --post-file query.json |
+ | |||
+ | ==== In url with HTTP GET ==== | ||
- | wget --no-check-certificate --post-file query.json --output-document result.json https:// | + | The requests must be made with HTTP POST with Calaos v2. |
- | ==== Wget Example | + | Examples: |
+ | * Get the config: https:// | ||
+ | * Get a picture from a camera: https:// | ||
+ | * Set an output: https:// | ||
+ | * Set an intern variable: https:// | ||
+ | * Read a variable : https:// | ||
- | TBC | + | That allows an external system that only supports HTTP GET to easily communicate to Calaos. |
+ | |||
+ | ==== HTML Page ==== | ||
+ | |||
+ | Calaos v3 includes a debug web page to test the POST and Websocket requests. | ||
+ | |||
+ | We need first to activate the debug mode with following command: | ||
+ | < | ||
+ | calaos_config set debug_enabled true | ||
+ | </ | ||
+ | or directly add it in the file /// | ||
+ | |||
+ | The page is then accessible from https:// | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | ==== Use the API with other languages ==== | ||
+ | |||
+ | * [[json_python2|Python 2]] | ||
+ | * [[json_python3|Python 3]] | ||
===== API Calaos Network ===== | ===== API Calaos Network ===== | ||
Line 33: | Line 60: | ||
With this command you can get the complete configuration of the house. | With this command you can get the complete configuration of the house. | ||
- | === Exeaple | + | === Example |
- | Json Data to be send : | + | Json Data to be sent : |
{ | { | ||
" | " | ||
Line 152: | Line 179: | ||
} | } | ||
| | ||
- | The answer | + | The answer |
==== get_state ==== | ==== get_state ==== | ||
- | This command may be used to get the state of one or many Input/ | + | This command may be used to get the state of one or many Input/ |
- | === Exeample | + | === Example |
- | JSON Data to be send | + | JSON Data to be sent |
{ | { | ||
" | " | ||
Line 199: | Line 226: | ||
} | } | ||
- | The answer | + | Answer |
==== set_state ==== | ==== set_state ==== | ||
- | This command is used to change the state of one or many I/O. Parameters contains the ID of I/o, those found in the [[protocole_tcp|the TCP Protocole]]. | + | This command is used to change the state of one or many I/O. Parameters contains the ID of I/O, as in the [[protocole_tcp|TCP |
- | === Exemple | + | === Example |
- | JSON data to be send : | + | JSON data to be sent : |
{ | { | ||
" | " | ||
Line 223: | Line 250: | ||
} | } | ||
- | If you want to force the value of an input, you can chante the type by : | + | If you want to force the value of an input, you need to set type to " |
" | " | ||
| | ||
- | Command may also be sent to the music zone. Those commande | + | Command may also be sent to the music zones. Those commands |
- | === Exemple | + | === Example |
- | JSON Data to be send : | + | JSON Data to be sent : |
{ | { | ||
" | " | ||
Line 240: | Line 267: | ||
} | } | ||
- | We can also send data to a motorised | + | We can also send data to a camera |
=== Example === | === Example === | ||
- | JSON Data to be send : | + | JSON Data to be sent : |
{ | { | ||
" | " | ||
Line 261: | Line 288: | ||
=== Example === | === Example === | ||
- | Données | + | JSON Data to be sent : |
{ | { | ||
" | " | ||
Line 269: | Line 296: | ||
} | } | ||
- | You can alos add the parameters // | + | You can also add the parameters // |
Answer: | Answer: | ||
Line 302: | Line 329: | ||
} | } | ||
- | The answer contains the list of tracks | + | The answer contains the list of tracks |
==== poll_listen ==== | ==== poll_listen ==== | ||
- | This command is used to monitor all the changes of an IO of the server. | + | This command is used to monitor all the changes of an IO of the server. |
=== Register === | === Register === | ||
- | To register and get an unique ID, you have to send the following request : | + | To register and get a unique ID, you have to send the following request : |
{ | { | ||
" | " | ||
Line 323: | Line 350: | ||
} | } | ||
- | This ID is unique and is valid as long as you used it. If it' | + | This ID is unique and is valid as long as you used it. If not used within 5 min, it becomes |
=== Remove === | === Remove === | ||
- | When you have finished listening changes on an IO, you can remove this ID. Deleting an ID is not mandatory, as it's always done after 5min on inactivity. | ||
- | JSON Data to be send : | + | When you have finished listening changes on an IO, you can remove this ID. Deleting an ID is not mandatory, as it's always done after 5 min on inactivity. |
+ | |||
+ | JSON Data to be sent : | ||
{ | { | ||
" | " | ||
Line 344: | Line 372: | ||
=== Get Events === | === Get Events === | ||
- | Once the registration is done and you get an unique ID, you can ask the server periodically to know what happens | + | Once the registration is done and you have your unique ID, you can ask the server periodically to know what happens. The answer are the same as those sent by the //listen// command |
- | JSON Data to be send: | + | JSON Data to be sent: |
{ | { | ||
" | " | ||
Line 371: | Line 399: | ||
=== get === | === get === | ||
- | To retrieve the whole config you can use the following request : | + | To retrieve the whole config you need to use the following request : |
{ | { | ||
" | " | ||
Line 390: | Line 418: | ||
=== put === | === put === | ||
- | To send the configuration on the server you can use the following request | + | To send the configuration on the server you need to use the following request |
{ | { | ||
" | " |