User Tools

Site Tools


api

Differences

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

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
api [2013/09/26 20:21]
curlymo
api [2014/09/21 13:09]
pilino1234 Removed "order" as said in forums, and fixed spelling
Line 1: Line 1:
 **Identification** **Identification**
  
-All programs ​communicatie ​with each other by using JSON objects. The normal identification process is as follows:+All programs ​communicate ​with each other by using JSON objects. The normal identification process is as follows:
  
   * Connect to ''​pilight-daemon''​ through ''​x.x.x.x:​5000''​   * Connect to ''​pilight-daemon''​ through ''​x.x.x.x:​5000''​
Line 44: Line 44:
 **Receiver** **Receiver**
  
-The receiver does nothing more than connecting to the ''​pilight-daemon'',​ and receiving the same JSON objects that were sended ​by the sender. The only difference it that the receiver will receive JSON objects that notify if the messages were send or received. An example:+The receiver does nothing more than connecting to the ''​pilight-daemon'',​ and receiving the same JSON objects that were sent by the sender. The only difference it that the receiver will receive JSON objects that notify if the messages were send or received. An example:
 <code js> <code js>
 +{
 + "​origin":​ "​receiver",​
 + "​protocol":​ "​kaku_switch",​
 + "​code":​ {
 + "​id":​ 1234,
 + "​unit":​ 0,
 + "​off":​ 1
 + }
 +}
 { {
  "​origin":​ "​sender",​  "​origin":​ "​sender",​
Line 66: Line 75:
 } }
 </​code>​ </​code>​
-After this command, the ''​pilight-daemon''​ will send the raw JSON config file in which all locations and devices are defined. This can help the controller to validate the sended ​codes.+After this command, the ''​pilight-daemon''​ will send the raw JSON config file in which all locations and devices are defined. This can help the controller to validate the sent codes. ​ 
 + 
 +//​(development version) Additionally the config can contain a version array. The first number in the array is the currently running version, the second number is the latest upstream version.//​ 
 +<code js> 
 +
 + "​config":​ { 
 + "​living":​ { 
 + "​name":​ "​Living",​ 
 + "​bookshelf":​ { 
 + "​name":​ "Book Shelf Light",​ 
 + "​protocol":​ ["​kaku_switch"​],​ 
 + "​id":​ [{ 
 + "​id":​ 1234, 
 + "​unit":​ 0 
 + }], 
 + "​state":​ "​off"​ 
 + }, 
 + "​television":​ { 
 + "​name":​ "​Television",​ 
 + "​protocol":​ ["​relay"​],​ 
 + "​id":​ [{ 
 + "​gpio":​ 3 
 + }], 
 + "​state":​ "​off"​ 
 +
 +
 + }, 
 + "​version":​ [ "​2.0",​ "​2.0"​ ] 
 +
 +</​code>​
  
 The goal of the controller is to send a specific location and device that needs to be controlled. Additionally,​ a state can be send or else the next value in the values array will be used. Again, the ''​pilight-daemon''​ does error checking but doesn'​t report back if it failed. The controller should thereby check everything itself before sending codes. This is an example of the controller JSON object: The goal of the controller is to send a specific location and device that needs to be controlled. Additionally,​ a state can be send or else the next value in the values array will be used. Again, the ''​pilight-daemon''​ does error checking but doesn'​t report back if it failed. The controller should thereby check everything itself before sending codes. This is an example of the controller JSON object:
Line 109: Line 147:
  "​humidity":​ 800,  "​humidity":​ 800,
  "​battery":​ 1,  "​battery":​ 1,
- "temparature": 3100+ "temperature": 3100
  }  }
 } }
 </​code>​ </​code>​
 The ''​pilight-daemon''​ will keep the connection open to the receiver until either the daemon is stopped or the receiver is closed. The webgui also acts like a normal gui however all communication is done on the webserver port. The rest is exactly the same. The ''​pilight-daemon''​ will keep the connection open to the receiver until either the daemon is stopped or the receiver is closed. The webgui also acts like a normal gui however all communication is done on the webserver port. The rest is exactly the same.
- + 
 +**Webserver** 
 + 
 +//This feature is part of the development version of pilight// 
 + 
 +The webserver has two special pages.  
 + 
 +The ''​config''​ page will present the latest config json object. 
 + 
 +The ''​send''​ page can be used to control devices. To use this function call the send page with a send object url encoded like this: 
 +<​code>​ 
 +send?​%7B%0A%09%22message%22%3A%20%22send%22%2C%0A%09%22code%22%3A%20%7B%0A%09%09%22location%22%3A%20%22living%22%2C%0A%09%09%22device%22%3A%20%22mainlight%22%2C%0A%09%09%22state%22%3A%20%22on%22%2C%0A%09%09%22values%22%3A%20%7B%0A%09%09%09%22dimlevel%22%3A%20%2210%22%0A%09%09%7D%0A%09%7D%0A%7D 
 +</​code>​ 
 +This will send object as described under the controller. 
 **Heartbeat** **Heartbeat**
  
api.txt · Last modified: 2015/11/27 21:09 (external edit)