Troubleshooting API2
Jump to navigation
Jump to search
API also works via WebSocket connection, so you can interact with your Larnitech server from a browser using extensions (such as WebSocket Test Client).
To get started, you should:
1. Establish a web socket connection.
ws://IPADDR:PORT/api
Where: IPADDR – ip address of your metaforsa or DE-MG;
PORT – port for API2 (you can get it from LT_Setup => General => API => Websocket port (2041 by default);
2. Authorize
{
"request": "authorize",
"key": "XXXXXXXXXXXXXXX"
}
Where XXXXXXXXXXXXXXX - key from LT_Setup => Security => Show API key
3.After this you can send json requests:
Fields of JSON_REQUEST:
- "requestType" - Type of request:
- “getDevicesList” – request for getting the list of all devices;
- “getDeviceStatus” – request for getting device status;
- “setDeviceStatus” – request for setting device status;
- “setDeviceStatusRaw” – request for setting device status (status in hex format);
- “getAllDevicesStatus” – request for getting all devices status.
- “key” – key for API plugin (you can get it from LT Setup=>Plugins=>API=>Configure button).
- “addr” – address of device.
- “status” – status of device.
Examples of requests and responses:
1request:
2{"requestType":"getDevicesList","key":"0000000000000000"}
3
4response:
5{
6 "requestType":"devicesList",
7 "devices": [
8 {
9 "type": "lamp",
10 "name": "Ceiling",
11 "addr":"401:1"
12 },
13
14 {
15 "type": "conditioner",
16 "name": "AC",
17 "addr":"158:200",
18 "t-min":"16",
19 "t-delta":"16"
20 }
21
22 ]
23}
24
25request:
26{"requestType":"getDeviceStatus","addr":"310:1","key":"0000000000000000"}
27response:
28{
29 "requestType" : "deviceStatus",
30 "status" : {
31 "addr" : "310:1",
32 "state" : "middle",
33 "type" : "jalousie"
34 }
35}
36
37request:
38{"requestType":"setDeviceStatus","addr":"310:1","key":"0000000000000000","status":{"state": "on"}}
39
40response:
41{
42 "requestType":"setDeviceStatus",
43 "addr":"410:1",
44 "status":{
45 "state": "on"
46 }
47
48}
49
50request:
51{"requestType":"getAllDevicesStatus","key":"0000000000000000"}
52
53response:
54{
55 "requestType":"allDevicesStatus",
56 "statuses": [
57 {
58 "addr":"401:1",
59 "state": "off",
60 },
61
62 {
63 "addr":"158:200",
64 "state": "on",
65 "temp":"25",
66 "mode":"cool",
67 "fan":"low",
68 "vane-ver":"1",
69 "vane-hor":"4"
70 }
71 ]
72}
73
74request:
75{"requestType":"setDeviceStatusRaw","addr":"310:1","key":"0","status":{"state":"ff00"}}
76
77response:
78{
79 "addr" : "310:1",
80 "key" : "0",
81 "requestType" : "setDeviceStatusRaw",
82 "status" : {
83 "state" : "ff00"
84}