Webhooks

Revision as of 12:37, 5 November 2026 by Mark (talk | contribs) (ru)
Other languages:
English • ‎русский

Webhooks связывают систему Larnitech с любым интернет-сервисом, который умеет отправлять или принимать HTTP-запросы (например, IFTTT). Они настраиваются в LT Setup на вкладке Webhooks, у которой две части:

  • Events (события): сервер Larnitech отправляет HTTP-запрос на внешний адрес, когда в системе что-то происходит.
  • Actions (действия): внешний сервис отправляет HTTP-запрос серверу Larnitech, и сервер меняет состояние элемента.

Events

An event has the following fields:

Field Description
Name Name of the event. It is used in the script that sends the event.
URL Address that the server calls.
Method GET (default) or POST.
Feedback Optional. Item address and a regular expression: the value found in the answer is written to that item.

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

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).

To run an action, call the URL:

  • in the local network: http://CONTROLLER_IP/webhook/?key=API_KEY&name=ACTION_NAME
  • over the internet: https://service.larnitech.com/webhook/?key=API_KEY&sn=SERIAL&name=ACTION_NAME

where:

  • API_KEY: API key of the server (the TCP-API key, see API2);
  • SERIAL: serial number of the server;
  • ACTION_NAME: name of the action from the Name field.

The server answers with JSON. An error answer has "result":"ERROR" and a message, for example Error Key (wrong key) or Action not found.

Example

The settings are stored in /home/settings/webhooks.json. Example with one event with feedback and two actions:

 1{
 2  "events": [
 3    {
 4      "name": "997:1_button_pressed",
 5      "url": "https://maker.ifttt.com/trigger/997:1_button_pressed/with/key/YOUR_IFTTT_KEY",
 6      "method": "POST"
 7    },
 8    {
 9      "name": "447:145_sensor_state",
10      "url": "https://example.com/weather.json",
11      "feedback": { "addr": "447:145", "regexp": "/\"temp\":\"(-?[0-9]+)\",/" }
12    }
13  ],
14  "actions": [
15    {
16      "name": "401:1_lamp_on",
17      "status": [ { "request": "status-set", "addr": "401:1", "status": { "state": "on" } } ]
18    },
19    {
20      "name": "401:1_lamp_reverse",
21      "status": [ { "request": "status-set", "addr": "401:1", "status": { "state": "reverse" } } ]
22    }
23  ]
24}

See also: IFTTT (IF This, Then That), API2.