Changes

Marked this version for translation
Line 1: Line 1:  
<languages/>
 
<languages/>
 
<translate>
 
<translate>
 +
<!--T:1-->
 
'''Webhooks''' connect the Larnitech system with any internet service that can send or receive HTTP requests (for example [[IFTTT (IF This, Then That)|IFTTT]]). They are set up in LT Setup on the '''Webhooks''' tab, which has two parts:
 
'''Webhooks''' connect the Larnitech system with any internet service that can send or receive HTTP requests (for example [[IFTTT (IF This, Then That)|IFTTT]]). They are set up in LT Setup on the '''Webhooks''' tab, which has two parts:
 
* '''Events''': the Larnitech server sends an HTTP request to an external URL when something happens in the system.
 
* '''Events''': the Larnitech server sends an HTTP request to an external URL when something happens in the system.
 
* '''Actions''': an external service sends an HTTP request to the Larnitech server, and the server changes the state of an item.
 
* '''Actions''': an external service sends an HTTP request to the Larnitech server, and the server changes the state of an item.
   −
== Events ==
+
== Events == <!--T:2-->
 
An event has the following fields:
 
An event has the following fields:
 
{|class="wikitable"
 
{|class="wikitable"
Line 20: Line 21:  
The event is sent from a script. In LT Setup open '''Scripts → Scripts from logic → Add Blockly script''', add the device event on the '''Triggers''' tab, put the '''Make webhook''' block from the '''Automation''' tab into it and choose the event name.
 
The event is sent from a script. In LT Setup open '''Scripts → Scripts from logic → Add Blockly script''', add the device event on the '''Triggers''' tab, put the '''Make webhook''' block from the '''Automation''' tab into it and choose the event name.
   −
== Actions ==
+
== Actions == <!--T:3-->
 
An action has a name, an item and the state to set (on, off, reverse, level, mode, target temperature and so on, depending on the item type).
 
An action has a name, an item and the state to set (on, off, reverse, level, mode, target temperature and so on, depending on the item type).
    +
<!--T:4-->
 
To run an action, call the URL:
 
To run an action, call the URL:
 
* in the local network: <code><nowiki>http://CONTROLLER_IP/webhook/?key=API_KEY&name=ACTION_NAME</nowiki></code>
 
* in the local network: <code><nowiki>http://CONTROLLER_IP/webhook/?key=API_KEY&name=ACTION_NAME</nowiki></code>
Line 31: Line 33:  
* <code>ACTION_NAME</code>: name of the action from the '''Name''' field.
 
* <code>ACTION_NAME</code>: name of the action from the '''Name''' field.
    +
<!--T:5-->
 
The server answers with JSON. An error answer has <code>"result":"ERROR"</code> and a message, for example <code>Error Key</code> (wrong key) or <code>Action not found</code>.
 
The server answers with JSON. An error answer has <code>"result":"ERROR"</code> and a message, for example <code>Error Key</code> (wrong key) or <code>Action not found</code>.
   −
== Example ==
+
== Example == <!--T:6-->
 
The settings are stored in <code>/home/settings/webhooks.json</code>. Example with one event with feedback and two actions:
 
The settings are stored in <code>/home/settings/webhooks.json</code>. Example with one event with feedback and two actions:
 
<syntaxhighlight lang="json" line>
 
<syntaxhighlight lang="json" line>
Line 62: Line 65:  
</syntaxhighlight>
 
</syntaxhighlight>
    +
<!--T:7-->
 
See also: [[IFTTT (IF This, Then That)]], [[API2]].
 
See also: [[IFTTT (IF This, Then That)]], [[API2]].
 
</translate>
 
</translate>