Changes

3,119 bytes added ,  13:12, 16 August 2023
Created page with "<languages/> <translate> <!--T:1--> API2 works via WebSocket connection, so you can interact with your Larnitech server from a browser using extensions (such as WebSocket Test..."
<languages/>
<translate>
<!--T:1-->
API2 works via WebSocket connection, so you can interact with your Larnitech server from a browser using extensions (such as WebSocket Test Client).<br>
To get started, you should:<br><br>
1. Establish a web socket connection.<br>
<syntaxhighlight lang="xml">
ws://IPADDR:PORT/api
</syntaxhighlight>
Where: IPADDR – ip address of your metaforsa or DE-MG;<br>
PORT – port for API2 (you can get it from LT_Setup =&gt; General =&gt; API =&gt; Websocket port (2041 by default);<br><br>
2. Authorize
<syntaxhighlight lang="json">
{
"request": "authorize",
"key": "XXXXXXXXXXXXXXX"
}
</syntaxhighlight>
Where XXXXXXXXXXXXXXX - key from LT_Setup =&gt; Security =&gt; Show API key<br><br>
3.After this you can send json requests:

Fields of JSON_REQUEST:
<ul>
<li>"requestType" - Type of request:
<ul>
<li>“getDevicesList” – request for getting the list of all devices;</li>
<li>“getDeviceStatus” – request for getting device status;</li>
<li>“setDeviceStatus” – request for setting device status;</li>
<li>“setDeviceStatusRaw” – request for setting device status (status in hex format);</li>
<li>“getAllDevicesStatus” – request for getting all devices status.</li>

</ul>
</li>
<li>“key” – key for API plugin (you can get it from LT Setup=&gt;Plugins=&gt;API=&gt;Configure button).</li>
<li>“addr” – address of device.</li>
<li>“status” – status of device.</li>
</ul>
Examples of requests and responses:

<!--T:2-->
<syntaxhighlight lang="json" line>
request:
{"requestType":"getDevicesList","key":"ENTER_API_KEY"}

response:
{
"requestType":"devicesList",
"devices": [
{
"type": "lamp",
"name": "Ceiling",
"addr":"401:1"
},

{
"type": "conditioner",
"name": "AC",
"addr":"158:200",
"t-min":"16",
"t-delta":"16"
}

]
}

request:
{"requestType":"getDeviceStatus","addr":"310:1","key":"ENTER_API_KEY"}
response:
{
"requestType" : "deviceStatus",
"status" : {
"addr" : "310:1",
"state" : "middle",
"type" : "jalousie"
}
}

request:
{"requestType":"setDeviceStatus","addr":"310:1","key":"ENTER_API_KEY","status":{"state": "on"}}

response:
{
"requestType":"setDeviceStatus",
"addr":"410:1",
"status":{
"state": "on"
}

}

request:
{"requestType":"getAllDevicesStatus","key":"ENTER_API_KEY"}

response:
{
"requestType":"allDevicesStatus",
"statuses": [
{
"addr":"401:1",
"state": "off",
},

{
"addr":"158:200",
"state": "on",
"temp":"25",
"mode":"cool",
"fan":"low",
"vane-ver":"1",
"vane-hor":"4"
}
]
}

request:
{"requestType":"setDeviceStatusRaw","addr":"310:1","key":"0","status":{"state":"ff00"}}

response:
{
"addr" : "310:1",
"key" : "0",
"requestType" : "setDeviceStatusRaw",
"status" : {
"state" : "ff00"
}
</syntaxhighlight>
</translate>
editor, Interface administrators, Administrators, translation-admin, translator
9,706

edits