LM API

Logic Manager API is used to manage lvars, rules and other logic elements

This document describes API methods for direct and JSON RPC calls. For RESTful API look LM RESTful API.

API basics

Standard API (direct method calling)

LM API functions are called through URL request

http://<ip_address:8817>/lm-api/function

If SSL is allowed in the controller configuration file, you can also use https calls.

Warning

It’s highly not recommended to perform long API calls, calling API functions from JavaScript in a web browser (e.g. giving “w” param to action methods to wait until action finish). Web browser may repeat API call continuously, which may lead to absolutely unexpected behavior.

Standard API responses

Good for backward compatibility with any devices, as all API functions can be called using GET and POST. When POST is used, the parameters can be passed to functions either as multipart/form-data or as JSON.

API key can be sent in request parameters, session (if enabled and user is logged in) or in HTTP X-Auth-Key header.

Standard responses in status/body:

  • 200 OK { “result”: “OK” } API call completed successfully.

Standard error responses in status:

  • 400 Bad Request Invalid request params
  • 403 Forbidden the API key has no access to this function or resource
  • 404 Not Found method or resource/object doesn’t exist
  • 405 Method Not Allowed API function/method not found or HTTP method is not either GET or POST
  • 409 Conflict resource/object already exists or is locked
  • 500 API Error API function execution has been failed. Check input parameters and server logs.

In case API function has been failed, response body will contain JSON data with _error field, which contains error message.

{
    "_error": "unable to add object, already present",
    "result": "ERROR"
}

JSON RPC

Additionally, API supports JSON RPC 2.0 protocol. Note that default JSON RPC result is { “ok”: true } (instead of { “result”: “OK” }). There’s no error result, as JSON RPC sends errors in “error” field.

If JSON RPC request is called without ID and server should not return a result, it will return http response with a code 202 Accepted.

Note

JSON RPC is recommended way to use EVA ICS API, unless direct method calling or RESTful is really required.

JSON RPC API URL:

http://<ip_address:8817>/jrpc

JSON RPC error responses

JSON RPC calls return error codes equal to the codes of EVA API Client:

  • 1 the item or resource is not found
  • 2 access is denied with the set API key
  • 6 Attempt to call undefined API method/function
  • 10 API function failed (all errors not listed here fall within this category)
  • 11 API function is called with invalid params
  • 12 API function attempted to create resource which already exists and can’t be recreated until deleted/removed
  • 13 the resource is busy (in use) and can not be accessed/recreated or deleted at this moment
  • 14 the method is not implemented in/for requested resource

Response field “message” may contain additional information about error.

Contents

General functions

test - test API/key and get system info

Test can be executed with any valid API key of the controller the function is called to.

http

POST /lm-api/test HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/test -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/test --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/test Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/test', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "acl": {
        "key_id": "masterkey",
        "master": true
    },
    "db_update": 1,
    "debug": true,
    "file_management": true,
    "layout": "enterprise",
    "polldelay": 0.01,
    "product_build": 2019031405,
    "product_code": "lm",
    "product_name": "EVA Logic Manager",
    "result": "OK",
    "setup_mode": false,
    "system": "ws1-v1",
    "time": 1553193499.7920787,
    "uptime": 658,
    "version": "3.2.0"
}

Parameters:

  • k any valid API key

Returns:

JSON dict with system info and current API key permissions (for masterkey only { “master”: true } is returned)

login - log in and get authentication token

Obtains authentication token which can be used in API calls instead of API key.

If both k and u args are absent, but API method is called with HTTP request, which contain HTTP header for basic authorization, the function will try to parse it and log in user with credentials provided.

If authentication token is specified, the function will check it and return token information if it is valid.

http

POST /lm-api/login HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "u": "admin", "p": "123" }

curl

curl -i -X POST http://localhost:8817/lm-api/login -H 'Content-Type: application/json' --data-raw '{"p": "123", "u": "admin"}'

wget

wget -S -O- http://localhost:8817/lm-api/login --header='Content-Type: application/json' --post-data='{"p": "123", "u": "admin"}'

httpie

echo '{
  "p": "123",
  "u": "admin"
}' | http POST http://localhost:8817/lm-api/login Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/login', headers={
    'Content-Type': 'application/json',
}, json={
    'p': '123',
    'u': 'admin',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "key": "masterkey",
    "token": "token:1c166529bc3b06dac6e0fbaefee38ebe77c455480e11ff4431de2b10a5508899",
    "user": "admin"
}

Parameters:

  • k valid API key or
  • u user login
  • p user password
  • a authentication token

Returns:

A dict, containing API key ID and authentication token

logout - log out and purge authentication token

Purges authentication token

http

POST /lm-api/logout HTTP/1.1
Host: localhost:8812
Content-Type: application/json

{ "k": "token:c063c19fb54dd6b773b4f236f26ea7e5fbaa96f48b103221ae1107420096aef7" }

curl

curl -i -X POST http://localhost:8812/lm-api/logout -H 'Content-Type: application/json' --data-raw '{"k": "token:c063c19fb54dd6b773b4f236f26ea7e5fbaa96f48b103221ae1107420096aef7"}'

wget

wget -S -O- http://localhost:8812/lm-api/logout --header='Content-Type: application/json' --post-data='{"k": "token:c063c19fb54dd6b773b4f236f26ea7e5fbaa96f48b103221ae1107420096aef7"}'

httpie

echo '{
  "k": "token:c063c19fb54dd6b773b4f236f26ea7e5fbaa96f48b103221ae1107420096aef7"
}' | http POST http://localhost:8812/lm-api/logout Content-Type:application/json

python-requests

requests.post('http://localhost:8812/lm-api/logout', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'token:c063c19fb54dd6b773b4f236f26ea7e5fbaa96f48b103221ae1107420096aef7',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid token

LVar functions

clear - clear lvar state

set status (if expires lvar param > 0) or value (if expires isn’t set) of a logic variable to 0. Useful when lvar is used as a timer to stop it, or as a flag to set it False.

http

POST /lm-api/clear HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/lvar1" }

curl

curl -i -X POST http://localhost:8817/lm-api/clear -H 'Content-Type: application/json' --data-raw '{"i": "tests/lvar1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/clear --header='Content-Type: application/json' --post-data='{"i": "tests/lvar1", "k": "mykey"}'

httpie

echo '{
  "i": "tests/lvar1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/clear Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/clear', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/lvar1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid API key
  • i lvar id

decrement - decrement lvar value

Decrement value of a logic variable. Initial value should be number

http

POST /lm-api/decrement HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/lvar1" }

curl

curl -i -X POST http://localhost:8817/lm-api/decrement -H 'Content-Type: application/json' --data-raw '{"i": "tests/lvar1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/decrement --header='Content-Type: application/json' --post-data='{"i": "tests/lvar1", "k": "mykey"}'

httpie

echo '{
  "i": "tests/lvar1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/decrement Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/decrement', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/lvar1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid API key
  • i lvar id

groups - get item group list

Get the list of item groups. Useful e.g. for custom interfaces.

http

POST /lm-api/groups HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/groups -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/groups --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/groups Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/groups', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    "nogroup",
    "tests",
    "timers"
]

Parameters:

  • k valid API key
  • p item type (must be set to lvar [LV])

increment - increment lvar value

Increment value of a logic variable. Initial value should be number

http

POST /lm-api/increment HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/lvar1" }

curl

curl -i -X POST http://localhost:8817/lm-api/increment -H 'Content-Type: application/json' --data-raw '{"i": "tests/lvar1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/increment --header='Content-Type: application/json' --post-data='{"i": "tests/lvar1", "k": "mykey"}'

httpie

echo '{
  "i": "tests/lvar1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/increment Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/increment', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/lvar1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid API key
  • i lvar id

reset - reset lvar state

Set status and value of a logic variable to 1. Useful when lvar is being used as a timer to reset it, or as a flag to set it True.

http

POST /lm-api/reset HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/lvar1" }

curl

curl -i -X POST http://localhost:8817/lm-api/reset -H 'Content-Type: application/json' --data-raw '{"i": "tests/lvar1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/reset --header='Content-Type: application/json' --post-data='{"i": "tests/lvar1", "k": "mykey"}'

httpie

echo '{
  "i": "tests/lvar1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/reset Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/reset', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/lvar1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid API key
  • i lvar id

set - set lvar state

Set status and value of a logic variable.

http

POST /lm-api/set HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "lvar:tests/lvar1", "s": 1, "v": 29.445 }

curl

curl -i -X POST http://localhost:8817/lm-api/set -H 'Content-Type: application/json' --data-raw '{"i": "lvar:tests/lvar1", "k": "mykey", "s": 1, "v": 29.445}'

wget

wget -S -O- http://localhost:8817/lm-api/set --header='Content-Type: application/json' --post-data='{"i": "lvar:tests/lvar1", "k": "mykey", "s": 1, "v": 29.445}'

httpie

echo '{
  "i": "lvar:tests/lvar1",
  "k": "mykey",
  "s": 1,
  "v": 29.445
}' | http POST http://localhost:8817/lm-api/set Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/set', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'lvar:tests/lvar1',
    'k': 'mykey',
    's': 1,
    'v': 29.445,
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid API key
  • i lvar id

Optionally:

  • s lvar status
  • v lvar value

state - get lvar state

State of lvar or all lvars can be obtained using state command.

http

POST /lm-api/state HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/state -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/state --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/state Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/state', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    {
        "expires": 0,
        "full_id": "nogroup/flag1",
        "group": "nogroup",
        "id": "flag1",
        "oid": "lvar:nogroup/flag1",
        "set_time": 1528751049.3848495,
        "status": 1,
        "type": "lvar",
        "value": "1"
    },
    {
        "expires": 5.0,
        "full_id": "nogroup/timer1",
        "group": "nogroup",
        "id": "timer1",
        "oid": "lvar:nogroup/timer1",
        "set_time": 1552049990.9313273,
        "status": -1,
        "type": "lvar",
        "value": "null"
    },
    {
        "expires": 15.0,
        "full_id": "tests/lvar1",
        "group": "tests",
        "id": "lvar1",
        "oid": "lvar:tests/lvar1",
        "set_time": 1553193500.1979027,
        "status": 1,
        "type": "lvar",
        "value": "null"
    },
    {
        "expires": 30.0,
        "full_id": "tests/lvar2",
        "group": "tests",
        "id": "lvar2",
        "oid": "lvar:tests/lvar2",
        "set_time": 1553193499.8252523,
        "status": 1,
        "type": "lvar",
        "value": "null"
    },
    {
        "expires": 100.0,
        "full_id": "timers/timer1",
        "group": "timers",
        "id": "timer1",
        "oid": "lvar:timers/timer1",
        "set_time": 1552062897.9593153,
        "status": -1,
        "type": "lvar",
        "value": "null"
    }
]

Parameters:

  • k valid API key

Optionally:

  • p item type (none or lvar [LV])
  • i item id
  • g item group
  • full return full state

state_history - get item state history

State history of one item or several items of the specified type can be obtained using state_history command.

http

POST /lm-api/state_history HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "lvar:tests/lvar1" }

curl

curl -i -X POST http://localhost:8817/lm-api/state_history -H 'Content-Type: application/json' --data-raw '{"i": "lvar:tests/lvar1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/state_history --header='Content-Type: application/json' --post-data='{"i": "lvar:tests/lvar1", "k": "mykey"}'

httpie

echo '{
  "i": "lvar:tests/lvar1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/state_history Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/state_history', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'lvar:tests/lvar1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "status": [
        1,
        1,
        1
    ],
    "t": [
        1553193500.1192024,
        1553193500.199146,
        1553193500.2409995
    ],
    "value": [
        1.0,
        null,
        null
    ]
}

Parameters:

  • k valid API key
  • a history notifier id (default: db_1)
  • i item oids or full ids, list or comma separated

Optionally:

  • s start time (timestamp or ISO or e.g. 1D for -1 day)
  • e end time (timestamp or ISO or e.g. 1D for -1 day)
  • l records limit (doesn’t work with “w”)
  • x state prop (“status” or “value”)
  • t time format(“iso” or “raw” for unix timestamp, default is “raw”)
  • w fill frame with the interval (e.g. “1T” - 1 min, “2H” - 2 hours etc.), start time is required, set to 1D if not specified
  • g output format (“list”, “dict” or “chart”, default is “list”)
  • c options for chart (dict or comma separated)

Returns:

history data in specified format or chart image.

For chart, JSON RPC gets reply with “content_type” and “data” fields, where content is image content type. If PNG image format is selected, data is base64-encoded.

Options for chart (all are optional):

If option “w” (fill) is used, number of digits after comma may be specified. E.g. 5T:3 will output values with 3 digits after comma.

Additionally, SI prefix may be specified to convert value to kilos, megas etc, e.g. 5T:k:3 - divide value by 1000 and output 3 digits after comma. Valid prefixes are: k, M, G, T, P, E, Z, Y.

If binary prefix is required, it should be followed by “b”, e.g. 5T:Mb:3 - divide value by 2^20 and output 3 digits after comma.

toggle - toggle lvar state

switch value of a logic variable between 0 and 1. Useful when lvar is being used as a flag to switch it between True/False.

http

POST /lm-api/toggle HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/lvar1" }

curl

curl -i -X POST http://localhost:8817/lm-api/toggle -H 'Content-Type: application/json' --data-raw '{"i": "tests/lvar1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/toggle --header='Content-Type: application/json' --post-data='{"i": "tests/lvar1", "k": "mykey"}'

httpie

echo '{
  "i": "tests/lvar1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/toggle Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/toggle', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/lvar1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid API key
  • i lvar id

LVar management

list - list lvars

http

POST /lm-api/list HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/list -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    {
        "description": "flag 1",
        "expires": 0,
        "full_id": "nogroup/flag1",
        "group": "nogroup",
        "id": "flag1",
        "oid": "lvar:nogroup/flag1",
        "set_time": 1528751049.3848495,
        "type": "lvar"
    },
    {
        "description": "",
        "expires": 5.0,
        "full_id": "nogroup/timer1",
        "group": "nogroup",
        "id": "timer1",
        "oid": "lvar:nogroup/timer1",
        "set_time": 1552049990.9313273,
        "type": "lvar"
    },
    {
        "description": "",
        "expires": 0,
        "full_id": "tests/lvar1",
        "group": "tests",
        "id": "lvar1",
        "oid": "lvar:tests/lvar1",
        "set_time": 1553193500.117168,
        "type": "lvar"
    },
    {
        "description": "",
        "expires": 30.0,
        "full_id": "tests/lvar2",
        "group": "tests",
        "id": "lvar2",
        "oid": "lvar:tests/lvar2",
        "set_time": 1553193499.8252523,
        "type": "lvar"
    },
    {
        "description": "",
        "expires": 100.0,
        "full_id": "timers/timer1",
        "group": "timers",
        "id": "timer1",
        "oid": "lvar:timers/timer1",
        "set_time": 1552062897.9593153,
        "type": "lvar"
    }
]

Parameters:

  • k API key with master permissions

Optionally:

  • g filter by item group

Returns:

the list of all lvars available

create_lvar - create lvar

Create new lvar

http

POST /lm-api/create_lvar HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/lvar1", "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/create_lvar -H 'Content-Type: application/json' --data-raw '{"i": "tests/lvar1", "k": "mykey", "save": true}'

wget

wget -S -O- http://localhost:8817/lm-api/create_lvar --header='Content-Type: application/json' --post-data='{"i": "tests/lvar1", "k": "mykey", "save": true}'

httpie

echo '{
  "i": "tests/lvar1",
  "k": "mykey",
  "save": true
}' | http POST http://localhost:8817/lm-api/create_lvar Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/create_lvar', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/lvar1',
    'k': 'mykey',
    'save': True,
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "expires": 0,
    "full_id": "tests/lvar1",
    "group": "tests",
    "id": "lvar1",
    "oid": "lvar:tests/lvar1",
    "set_time": 1553193499.8059733,
    "status": 1,
    "type": "lvar",
    "value": "null"
}

Parameters:

  • k API key with master permissions
  • i lvar id

Optionally:

  • g lvar group
  • save save lvar configuration immediately

destroy_lvar - delete lvar

http

POST /lm-api/destroy_lvar HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "lvar:tests/lvar1" }

curl

curl -i -X POST http://localhost:8817/lm-api/destroy_lvar -H 'Content-Type: application/json' --data-raw '{"i": "lvar:tests/lvar1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/destroy_lvar --header='Content-Type: application/json' --post-data='{"i": "lvar:tests/lvar1", "k": "mykey"}'

httpie

echo '{
  "i": "lvar:tests/lvar1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/destroy_lvar Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/destroy_lvar', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'lvar:tests/lvar1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i lvar id

get_config - get lvar configuration

http

POST /lm-api/get_config HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "lvar:tests/lvar1" }

curl

curl -i -X POST http://localhost:8817/lm-api/get_config -H 'Content-Type: application/json' --data-raw '{"i": "lvar:tests/lvar1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/get_config --header='Content-Type: application/json' --post-data='{"i": "lvar:tests/lvar1", "k": "mykey"}'

httpie

echo '{
  "i": "lvar:tests/lvar1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/get_config Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/get_config', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'lvar:tests/lvar1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "expires": 0,
    "full_id": "tests/lvar1",
    "group": "tests",
    "id": "lvar1",
    "oid": "lvar:tests/lvar1",
    "set_time": 1553193500.117168,
    "type": "lvar"
}

Parameters:

  • k API key with master permissions
  • i lvaar id

Returns:

complete lvar configuration.

list_props - list lvar properties

Get all editable parameters of the lvar confiugration.

http

POST /lm-api/list_props HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "lvar:tests/lvar1" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_props -H 'Content-Type: application/json' --data-raw '{"i": "lvar:tests/lvar1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_props --header='Content-Type: application/json' --post-data='{"i": "lvar:tests/lvar1", "k": "mykey"}'

httpie

echo '{
  "i": "lvar:tests/lvar1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_props Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_props', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'lvar:tests/lvar1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "description": "",
    "expires": 0,
    "mqtt_update": null,
    "set_time": 1553193500.117168,
    "update_delay": 0,
    "update_exec": null,
    "update_interval": 0,
    "update_timeout": null
}

Parameters:

  • k API key with master permissions
  • i item id

save_config - save lvar configuration

Saves lvar. configuration on disk (even if it hasn’t been changed)

http

POST /lm-api/save_config HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "lvar:tests/lvar1" }

curl

curl -i -X POST http://localhost:8817/lm-api/save_config -H 'Content-Type: application/json' --data-raw '{"i": "lvar:tests/lvar1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/save_config --header='Content-Type: application/json' --post-data='{"i": "lvar:tests/lvar1", "k": "mykey"}'

httpie

echo '{
  "i": "lvar:tests/lvar1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/save_config Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/save_config', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'lvar:tests/lvar1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i lvar id

set_prop - set lvar property

Set configuration parameters of the lvar.

http

POST /lm-api/set_prop HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "lvar:tests/lvar1", "p": "expires", "v": 15 }

curl

curl -i -X POST http://localhost:8817/lm-api/set_prop -H 'Content-Type: application/json' --data-raw '{"i": "lvar:tests/lvar1", "k": "mykey", "p": "expires", "v": 15}'

wget

wget -S -O- http://localhost:8817/lm-api/set_prop --header='Content-Type: application/json' --post-data='{"i": "lvar:tests/lvar1", "k": "mykey", "p": "expires", "v": 15}'

httpie

echo '{
  "i": "lvar:tests/lvar1",
  "k": "mykey",
  "p": "expires",
  "v": 15
}' | http POST http://localhost:8817/lm-api/set_prop Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/set_prop', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'lvar:tests/lvar1',
    'k': 'mykey',
    'p': 'expires',
    'v': 15,
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i item id
  • p property name (or empty for batch set)

Optionally:

  • v propery value (or dict for batch set)
  • save save configuration after successful call

Decision matrix rules

create_rule - create new rule

Creates new decision rule. Rule id (UUID) is generated automatically unless specified.

http

POST /lm-api/create_rule HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/create_rule -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/create_rule --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/create_rule Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/create_rule', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "break_after_exec": false,
    "chillout_ends_in": 0,
    "chillout_time": 0,
    "condition": "",
    "description": "",
    "enabled": false,
    "for_initial": "skip",
    "for_item_group": null,
    "for_item_id": null,
    "for_item_type": null,
    "for_oid": "#:#/#/status",
    "for_prop": "status",
    "id": "9b317323-00e5-4e11-8573-33cdcada1d12",
    "in_range_max": null,
    "in_range_max_eq": false,
    "in_range_min": null,
    "in_range_min_eq": false,
    "macro": null,
    "macro_args": [],
    "macro_kwargs": {},
    "oid": "dmatrix_rule:dm_rules/9b317323-00e5-4e11-8573-33cdcada1d12",
    "priority": 100,
    "type": "dmatrix_rule"
}

Parameters:

  • k API key with master permissions

Optionally:

  • u rule UUID to set
  • v rule properties (dict)
  • save save rule configuration immediately

destroy_rule - delete rule

Deletes decision rule.

http

POST /lm-api/destroy_rule HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "4c6e8c99-56fe-490c-8442-4936ba777498" }

curl

curl -i -X POST http://localhost:8817/lm-api/destroy_rule -H 'Content-Type: application/json' --data-raw '{"i": "4c6e8c99-56fe-490c-8442-4936ba777498", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/destroy_rule --header='Content-Type: application/json' --post-data='{"i": "4c6e8c99-56fe-490c-8442-4936ba777498", "k": "mykey"}'

httpie

echo '{
  "i": "4c6e8c99-56fe-490c-8442-4936ba777498",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/destroy_rule Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/destroy_rule', headers={
    'Content-Type': 'application/json',
}, json={
    'i': '4c6e8c99-56fe-490c-8442-4936ba777498',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i rule id

get_rule - get rule information

http

POST /lm-api/get_rule HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "4c6e8c99-56fe-490c-8442-4936ba777498" }

curl

curl -i -X POST http://localhost:8817/lm-api/get_rule -H 'Content-Type: application/json' --data-raw '{"i": "4c6e8c99-56fe-490c-8442-4936ba777498", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/get_rule --header='Content-Type: application/json' --post-data='{"i": "4c6e8c99-56fe-490c-8442-4936ba777498", "k": "mykey"}'

httpie

echo '{
  "i": "4c6e8c99-56fe-490c-8442-4936ba777498",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/get_rule Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/get_rule', headers={
    'Content-Type': 'application/json',
}, json={
    'i': '4c6e8c99-56fe-490c-8442-4936ba777498',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "break_after_exec": false,
    "chillout_ends_in": 0,
    "chillout_time": 0,
    "condition": "",
    "description": "",
    "enabled": false,
    "for_initial": "skip",
    "for_item_group": null,
    "for_item_id": null,
    "for_item_type": null,
    "for_oid": "#:#/#/status",
    "for_prop": "status",
    "id": "4c6e8c99-56fe-490c-8442-4936ba777498",
    "in_range_max": null,
    "in_range_max_eq": false,
    "in_range_min": null,
    "in_range_min_eq": false,
    "macro": null,
    "macro_args": [],
    "macro_kwargs": {},
    "oid": "dmatrix_rule:dm_rules/4c6e8c99-56fe-490c-8442-4936ba777498",
    "priority": 100,
    "type": "dmatrix_rule"
}

Parameters:

  • k valid API key
  • i rule id

list_rule_props - list rule properties

Get all editable parameters of the decision rule.

http

POST /lm-api/list_rule_props HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "4c6e8c99-56fe-490c-8442-4936ba777498" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_rule_props -H 'Content-Type: application/json' --data-raw '{"i": "4c6e8c99-56fe-490c-8442-4936ba777498", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_rule_props --header='Content-Type: application/json' --post-data='{"i": "4c6e8c99-56fe-490c-8442-4936ba777498", "k": "mykey"}'

httpie

echo '{
  "i": "4c6e8c99-56fe-490c-8442-4936ba777498",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_rule_props Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_rule_props', headers={
    'Content-Type': 'application/json',
}, json={
    'i': '4c6e8c99-56fe-490c-8442-4936ba777498',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "break_after_exec": false,
    "chillout_time": 0,
    "condition": "",
    "description": "",
    "enabled": false,
    "for_initial": "skip",
    "for_item_group": null,
    "for_item_id": null,
    "for_item_type": null,
    "for_oid": "#:#/#/status",
    "for_prop": "status",
    "in_range_max": null,
    "in_range_max_eq": false,
    "in_range_min": null,
    "in_range_min_eq": false,
    "macro": null,
    "macro_args": [],
    "macro_kwargs": {},
    "priority": 100
}

Parameters:

  • k valid API key
  • i rule id

list_rules - get rules list

Get the list of all available decision rules.

http

POST /lm-api/list_rules HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_rules -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_rules --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_rules Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_rules', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    {
        "break_after_exec": false,
        "chillout_ends_in": 0,
        "chillout_time": 0,
        "condition": "",
        "description": "",
        "enabled": false,
        "for_initial": "skip",
        "for_item_group": null,
        "for_item_id": null,
        "for_item_type": null,
        "for_oid": "#:#/#/status",
        "for_prop": "status",
        "id": "4c6e8c99-56fe-490c-8442-4936ba777498",
        "in_range_max": null,
        "in_range_max_eq": false,
        "in_range_min": null,
        "in_range_min_eq": false,
        "macro": null,
        "macro_args": [],
        "macro_kwargs": {},
        "oid": "dmatrix_rule:dm_rules/4c6e8c99-56fe-490c-8442-4936ba777498",
        "priority": 100,
        "type": "dmatrix_rule"
    },
    {
        "break_after_exec": false,
        "chillout_ends_in": 0,
        "chillout_time": 0,
        "condition": "",
        "description": "",
        "enabled": false,
        "for_initial": "skip",
        "for_item_group": null,
        "for_item_id": null,
        "for_item_type": null,
        "for_oid": "#:#/#/status",
        "for_prop": "status",
        "id": "9b317323-00e5-4e11-8573-33cdcada1d12",
        "in_range_max": null,
        "in_range_max_eq": false,
        "in_range_min": null,
        "in_range_min_eq": false,
        "macro": null,
        "macro_args": [],
        "macro_kwargs": {},
        "oid": "dmatrix_rule:dm_rules/9b317323-00e5-4e11-8573-33cdcada1d12",
        "priority": 100,
        "type": "dmatrix_rule"
    },
    {
        "break_after_exec": false,
        "chillout_ends_in": 0,
        "chillout_time": 0,
        "condition": "",
        "description": "",
        "enabled": false,
        "for_initial": "skip",
        "for_item_group": null,
        "for_item_id": null,
        "for_item_type": null,
        "for_oid": "#:#/#/status",
        "for_prop": "status",
        "id": "cc7de0ba-04a1-4161-ad73-588861b6e1ef",
        "in_range_max": null,
        "in_range_max_eq": false,
        "in_range_min": null,
        "in_range_min_eq": false,
        "macro": null,
        "macro_args": [],
        "macro_kwargs": {},
        "oid": "dmatrix_rule:dm_rules/cc7de0ba-04a1-4161-ad73-588861b6e1ef",
        "priority": 100,
        "type": "dmatrix_rule"
    }
]

Parameters:

  • k valid API key

set_rule_prop - set rule parameters

Set configuration parameters of the decision rule.

Note

Master key is required for batch set.

http

POST /lm-api/set_rule_prop HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "4c6e8c99-56fe-490c-8442-4936ba777498", "p": "for_initial", "v": "any", "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/set_rule_prop -H 'Content-Type: application/json' --data-raw '{"i": "4c6e8c99-56fe-490c-8442-4936ba777498", "k": "mykey", "p": "for_initial", "save": true, "v": "any"}'

wget

wget -S -O- http://localhost:8817/lm-api/set_rule_prop --header='Content-Type: application/json' --post-data='{"i": "4c6e8c99-56fe-490c-8442-4936ba777498", "k": "mykey", "p": "for_initial", "save": true, "v": "any"}'

httpie

echo '{
  "i": "4c6e8c99-56fe-490c-8442-4936ba777498",
  "k": "mykey",
  "p": "for_initial",
  "save": true,
  "v": "any"
}' | http POST http://localhost:8817/lm-api/set_rule_prop Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/set_rule_prop', headers={
    'Content-Type': 'application/json',
}, json={
    'i': '4c6e8c99-56fe-490c-8442-4936ba777498',
    'k': 'mykey',
    'p': 'for_initial',
    'save': True,
    'v': 'any',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid API key
  • i rule id
  • p property name (or empty for batch set)

Optionally:

  • v propery value (or dict for batch set)
  • save save configuration after successful call

Logic control macros

create_macro - create new macro

Creates new macro. Macro code should be put in xc/lm manually.

http

POST /lm-api/create_macro HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_macro" }

curl

curl -i -X POST http://localhost:8817/lm-api/create_macro -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_macro", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/create_macro --header='Content-Type: application/json' --post-data='{"i": "tests/test_macro", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_macro",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/create_macro Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/create_macro', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_macro',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "action_enabled": true,
    "full_id": "tests/test_macro",
    "group": "tests",
    "id": "test_macro",
    "oid": "lmacro:tests/test_macro",
    "type": "lmacro"
}

Parameters:

  • k API key with master permissions
  • i macro id

Optionally:

  • g macro group

destroy_macro - delete macro

Deletes macro.

http

POST /lm-api/destroy_macro HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_macro" }

curl

curl -i -X POST http://localhost:8817/lm-api/destroy_macro -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_macro", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/destroy_macro --header='Content-Type: application/json' --post-data='{"i": "tests/test_macro", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_macro",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/destroy_macro Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/destroy_macro', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_macro',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i macro id

get_macro - get macro information

http

POST /lm-api/get_macro HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_macro" }

curl

curl -i -X POST http://localhost:8817/lm-api/get_macro -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_macro", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/get_macro --header='Content-Type: application/json' --post-data='{"i": "tests/test_macro", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_macro",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/get_macro Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/get_macro', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_macro',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "action_enabled": true,
    "description": "",
    "full_id": "tests/test_macro",
    "group": "tests",
    "id": "test_macro",
    "oid": "lmacro:tests/test_macro",
    "type": "lmacro"
}

Parameters:

  • k valid API key
  • i macro id

groups_macro - get macro groups list

Get the list of macros. Useful e.g. for custom interfaces.

http

POST /lm-api/groups_macro HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/groups_macro -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/groups_macro --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/groups_macro Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/groups_macro', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    "tests"
]

Parameters:

  • k valid API key

list_macro_props - get macro configuration properties

http

POST /lm-api/list_macro_props HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_macro" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_macro_props -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_macro", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_macro_props --header='Content-Type: application/json' --post-data='{"i": "tests/test_macro", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_macro",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_macro_props Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_macro_props', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_macro',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "action_enabled": true,
    "action_exec": null,
    "description": "",
    "pass_errors": false,
    "send_critical": false
}

Parameters:

  • k API key with master permissions
  • i macro id

list_macros - get macro list

Get the list of all available macros.

http

POST /lm-api/list_macros HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_macros -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_macros --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_macros Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_macros', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    {
        "action_enabled": true,
        "description": "",
        "full_id": "tests/test1",
        "group": "tests",
        "id": "test1",
        "oid": "lmacro:tests/test1",
        "type": "lmacro"
    },
    {
        "action_enabled": true,
        "description": "",
        "full_id": "tests/test2",
        "group": "tests",
        "id": "test2",
        "oid": "lmacro:tests/test2",
        "type": "lmacro"
    },
    {
        "action_enabled": true,
        "description": "",
        "full_id": "tests/test_macro",
        "group": "tests",
        "id": "test_macro",
        "oid": "lmacro:tests/test_macro",
        "type": "lmacro"
    },
    {
        "action_enabled": true,
        "description": "",
        "full_id": "tests/test_macro2",
        "group": "tests",
        "id": "test_macro2",
        "oid": "lmacro:tests/test_macro2",
        "type": "lmacro"
    }
]

Parameters:

  • k valid API key

Optionally:

  • g filter by group

result - macro execution result

Get macro execution results either by action uuid or by macro id.

http

POST /lm-api/result HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_macro" }

curl

curl -i -X POST http://localhost:8817/lm-api/result -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_macro", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/result --header='Content-Type: application/json' --post-data='{"i": "tests/test_macro", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_macro",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/result Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/result', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_macro',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    {
        "args": [],
        "err": "",
        "exitcode": 0,
        "finished": true,
        "finished_in": 0.0097811,
        "item_group": "tests",
        "item_id": "test_macro",
        "item_oid": "lmacro:tests/test_macro",
        "item_type": "lmacro",
        "kwargs": {},
        "out": "test passed",
        "priority": 100,
        "status": "completed",
        "time": {
            "completed": 1559868831.1551707,
            "created": 1559868831.1453896,
            "pending": 1559868831.1458647,
            "queued": 1559868831.1469553,
            "running": 1559868831.1479862
        },
        "uuid": "7707c382-eefa-48d2-9b5e-92d114af4e85"
    }
]

Parameters:

  • k valid API key

Optionally:

  • u action uuid or
  • i macro id
  • g filter by unit group
  • s filter by action status: Q for queued, R for running, F for finished

Returns:

list or single serialized action object

run - execute macro

Execute a macro with the specified arguments.

http

POST /lm-api/run HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_macro" }

curl

curl -i -X POST http://localhost:8817/lm-api/run -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_macro", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/run --header='Content-Type: application/json' --post-data='{"i": "tests/test_macro", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_macro",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/run Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/run', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_macro',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "args": [],
    "err": "",
    "exitcode": null,
    "finished": false,
    "finished_in": null,
    "item_group": "tests",
    "item_id": "test_macro",
    "item_oid": "lmacro:tests/test_macro",
    "item_type": "lmacro",
    "kwargs": {},
    "out": "",
    "priority": 100,
    "status": "running",
    "time": {
        "created": 1559868831.9307947,
        "pending": 1559868831.9313061,
        "queued": 1559868831.9320123,
        "running": 1559868831.9324815
    },
    "uuid": "c1ac8b97-54c3-40e3-9db0-df859d9585c7"
}

Parameters:

  • k valid API key
  • i macro id

Optionally:

  • a macro arguments, array or space separated
  • kw macro keyword arguments, name=value, comma separated or dict
  • w wait for the completion for the specified number of seconds
  • u action UUID (will be auto generated if none specified)
  • p queue priority (default is 100, lower is better)
  • q global queue timeout, if expires, action is marked as “dead”

set_macro_prop - set macro configuration property

Set configuration parameters of the macro.

http

POST /lm-api/set_macro_prop HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_macro", "p": "pass_errors", "v": true, "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/set_macro_prop -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_macro", "k": "mykey", "p": "pass_errors", "save": true, "v": true}'

wget

wget -S -O- http://localhost:8817/lm-api/set_macro_prop --header='Content-Type: application/json' --post-data='{"i": "tests/test_macro", "k": "mykey", "p": "pass_errors", "save": true, "v": true}'

httpie

echo '{
  "i": "tests/test_macro",
  "k": "mykey",
  "p": "pass_errors",
  "save": true,
  "v": true
}' | http POST http://localhost:8817/lm-api/set_macro_prop Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/set_macro_prop', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_macro',
    'k': 'mykey',
    'p': 'pass_errors',
    'save': True,
    'v': True,
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i item id
  • p property name (or empty for batch set)

Optionally:

  • v propery value (or dict for batch set)
  • save save configuration after successful call

Logic cycles

create_cycle - create new cycle

Creates new cycle.

http

POST /lm-api/create_cycle HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_cycle" }

curl

curl -i -X POST http://localhost:8817/lm-api/create_cycle -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_cycle", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/create_cycle --header='Content-Type: application/json' --post-data='{"i": "tests/test_cycle", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_cycle",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/create_cycle Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/create_cycle', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_cycle',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "full_id": "tests/test_cycle",
    "group": "tests",
    "ict": 100,
    "id": "test_cycle",
    "interval": 1,
    "macro": null,
    "oid": "lcycle:tests/test_cycle",
    "on_error": null,
    "status": 0,
    "type": "lcycle",
    "value": "1.0000"
}

Parameters:

  • k API key with master permissions
  • i cycle id

Optionally:

  • g cycle group

destroy_cycle - delete cycle

Deletes cycle. If cycle is running, it is stopped before deletion.

http

POST /lm-api/destroy_cycle HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_cycle" }

curl

curl -i -X POST http://localhost:8817/lm-api/destroy_cycle -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_cycle", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/destroy_cycle --header='Content-Type: application/json' --post-data='{"i": "tests/test_cycle", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_cycle",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/destroy_cycle Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/destroy_cycle', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_cycle',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i cycle id

get_cycle - get cycle information

http

POST /lm-api/get_cycle HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_cycle" }

curl

curl -i -X POST http://localhost:8817/lm-api/get_cycle -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_cycle", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/get_cycle --header='Content-Type: application/json' --post-data='{"i": "tests/test_cycle", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_cycle",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/get_cycle Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/get_cycle', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_cycle',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "avg": 1,
    "description": "",
    "full_id": "tests/test_cycle",
    "group": "tests",
    "ict": 20,
    "id": "test_cycle",
    "interval": 1,
    "iterations": 0,
    "macro": "tests/test_macro",
    "oid": "lcycle:tests/test_cycle",
    "on_error": null,
    "status": 1,
    "type": "lcycle",
    "value": "1.0000"
}

Parameters:

  • k valid API key
  • i cycle id

Returns:

field “value” contains real average cycle interval

groups_cycle - get cycle groups list

Get the list of cycles. Useful e.g. for custom interfaces.

http

POST /lm-api/groups_cycle HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/groups_cycle -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/groups_cycle --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/groups_cycle Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/groups_cycle', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    "tests"
]

Parameters:

  • k valid API key

list_cycle_props - get cycle configuration properties

http

POST /lm-api/list_cycle_props HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_cycle" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_cycle_props -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_cycle", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_cycle_props --header='Content-Type: application/json' --post-data='{"i": "tests/test_cycle", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_cycle",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_cycle_props Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_cycle_props', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_cycle',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "autostart": false,
    "description": "",
    "ict": 20,
    "interval": 1,
    "macro": "tests/test_macro",
    "on_error": null
}

Parameters:

  • k API key with master permissions
  • i cycle id

list_cycles - get cycle list

Get the list of all available cycles.

http

POST /lm-api/list_cycles HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_cycles -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_cycles --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_cycles Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_cycles', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    {
        "avg": 0.0105,
        "description": "",
        "full_id": "tests/cycle1",
        "group": "tests",
        "ict": 20,
        "id": "cycle1",
        "interval": 0.01,
        "iterations": 275,
        "macro": "tests/test",
        "oid": "lcycle:tests/cycle1",
        "on_error": null,
        "status": 0,
        "type": "lcycle",
        "value": "275,0.0105,"
    },
    {
        "avg": 0.5,
        "description": "test 2Hz cycle",
        "full_id": "tests/test1",
        "group": "tests",
        "ict": 100,
        "id": "test1",
        "interval": 0.5,
        "iterations": 0,
        "macro": "tests/test1",
        "oid": "lcycle:tests/test1",
        "on_error": null,
        "status": 0,
        "type": "lcycle",
        "value": "0,0.5000,"
    }
]

Parameters:

  • k valid API key

Optionally:

  • g filter by group

reset_cycle_stats - reset cycle statistic

http

POST /lm-api/reset_cycle_stats HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_cycle" }

curl

curl -i -X POST http://localhost:8817/lm-api/reset_cycle_stats -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_cycle", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/reset_cycle_stats --header='Content-Type: application/json' --post-data='{"i": "tests/test_cycle", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_cycle",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/reset_cycle_stats Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/reset_cycle_stats', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_cycle',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid API key
  • i cycle id

set_cycle_prop - set cycle property

Set configuration parameters of the cycle.

http

POST /lm-api/set_cycle_prop HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_cycle", "p": "macro", "v": "tests/test_macro", "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/set_cycle_prop -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_cycle", "k": "mykey", "p": "macro", "save": true, "v": "tests/test_macro"}'

wget

wget -S -O- http://localhost:8817/lm-api/set_cycle_prop --header='Content-Type: application/json' --post-data='{"i": "tests/test_cycle", "k": "mykey", "p": "macro", "save": true, "v": "tests/test_macro"}'

httpie

echo '{
  "i": "tests/test_cycle",
  "k": "mykey",
  "p": "macro",
  "save": true,
  "v": "tests/test_macro"
}' | http POST http://localhost:8817/lm-api/set_cycle_prop Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/set_cycle_prop', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_cycle',
    'k': 'mykey',
    'p': 'macro',
    'save': True,
    'v': 'tests/test_macro',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i item id
  • p property name (or empty for batch set)

Optionally:

  • v propery value (or dict for batch set)
  • save save configuration after successful call

start_cycle - start cycle

http

POST /lm-api/start_cycle HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_cycle" }

curl

curl -i -X POST http://localhost:8817/lm-api/start_cycle -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_cycle", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/start_cycle --header='Content-Type: application/json' --post-data='{"i": "tests/test_cycle", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_cycle",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/start_cycle Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/start_cycle', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_cycle',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid API key
  • i cycle id

stop_cycle - stop cycle

http

POST /lm-api/stop_cycle HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "tests/test_cycle" }

curl

curl -i -X POST http://localhost:8817/lm-api/stop_cycle -H 'Content-Type: application/json' --data-raw '{"i": "tests/test_cycle", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/stop_cycle --header='Content-Type: application/json' --post-data='{"i": "tests/test_cycle", "k": "mykey"}'

httpie

echo '{
  "i": "tests/test_cycle",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/stop_cycle Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/stop_cycle', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'tests/test_cycle',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k valid API key
  • i cycle id

Optionally:

  • wait wait until cycle is stopped

Macro extensions

get_ext - get loaded extension information

http

POST /lm-api/get_ext HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "test_a" }

curl

curl -i -X POST http://localhost:8817/lm-api/get_ext -H 'Content-Type: application/json' --data-raw '{"i": "test_a", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/get_ext --header='Content-Type: application/json' --post-data='{"i": "test_a", "k": "mykey"}'

httpie

echo '{
  "i": "test_a",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/get_ext Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/get_ext', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'test_a',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "api": 1,
    "author": "Altertech Group, https://www.altertech.com/",
    "cfg": {
        "sdir": "/opt/data/snd"
    },
    "description": "Play audio file",
    "help": "\nPlays audio file inside the specified directory. The file path should be\nrelative to the directory root, witout a starting slash.\n",
    "id": "test_a",
    "license": "Apache License 2.0",
    "mod": "audio",
    "mods_required": [
        "soundfile",
        "sounddevice"
    ],
    "version": "1.0.0"
}

Parameters:

  • k API key with master permissions
  • i extension ID

list_ext - get list of available macro extensions

http

POST /lm-api/list_ext HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_ext -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_ext --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_ext Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_ext', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    {
        "id": "a1",
        "mod": "audio"
    },
    {
        "id": "test_a",
        "mod": "audio"
    },
    {
        "id": "test_a2",
        "mod": "audio"
    }
]

Parameters:

  • k API key with master permissions

Optionally:

  • full get full information

list_ext_mods - get list of available extension modules

http

POST /lm-api/list_ext_mods HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_ext_mods -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_ext_mods --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_ext_mods Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_ext_mods', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    {
        "api": 1,
        "author": "Altertech Group, https://www.altertech.com/",
        "description": "Play audio file",
        "help": "\nPlays audio file inside the specified directory. The file path should be\nrelative to the directory root, witout a starting slash.\n",
        "id": null,
        "license": "Apache License 2.0",
        "mod": "audio",
        "mods_required": [
            "soundfile",
            "sounddevice"
        ],
        "version": "1.0.0"
    },
    {
        "api": 1,
        "author": "Altertech Group, https://www.altertech.com/",
        "description": "Push client for Roboger",
        "help": "\nPush client for Roboger event pager (https://www.roboger.com,\nhttps://github.com/alttch/roboger). Refer to pyrpush module documentation for\nmore info: https://pypi.org/project/pyrpush/\n",
        "id": null,
        "license": "Apache License 2.0",
        "mod": "rpush",
        "mods_required": [
            "pyrpush"
        ],
        "version": "1.0.0"
    },
    {
        "api": 1,
        "author": "Altertech Group, https://www.altertech.com/",
        "description": "Run macro on remote LM PLC",
        "help": "\nAllows to run macros on remote LM PLC\n",
        "id": null,
        "license": "Apache License 2.0",
        "mod": "run_remote",
        "mods_required": [],
        "version": "1.0.0"
    },
    {
        "api": 1,
        "author": "Altertech Group, https://www.altertech.com/",
        "description": "Text-to-speech via ttsbroker",
        "help": "\nText-to-speech engine via ttsbroker Python module. Refer to module\ndocumentation for more info: https://pypi.org/project/ttsbroker/\n",
        "id": null,
        "license": "Apache License 2.0",
        "mod": "tts",
        "mods_required": [
            "ttsbroker"
        ],
        "version": "1.0.0"
    }
]

Parameters:

  • k API key with master permissions

load_ext - load extension module

Loads:doc:macro extension</lm/ext>.

http

POST /lm-api/load_ext HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "test_a", "m": "audio", "c": "sdir=/opt/data/snd", "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/load_ext -H 'Content-Type: application/json' --data-raw '{"c": "sdir=/opt/data/snd", "i": "test_a", "k": "mykey", "m": "audio", "save": true}'

wget

wget -S -O- http://localhost:8817/lm-api/load_ext --header='Content-Type: application/json' --post-data='{"c": "sdir=/opt/data/snd", "i": "test_a", "k": "mykey", "m": "audio", "save": true}'

httpie

echo '{
  "c": "sdir=/opt/data/snd",
  "i": "test_a",
  "k": "mykey",
  "m": "audio",
  "save": true
}' | http POST http://localhost:8817/lm-api/load_ext Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/load_ext', headers={
    'Content-Type': 'application/json',
}, json={
    'c': 'sdir=/opt/data/snd',
    'i': 'test_a',
    'k': 'mykey',
    'm': 'audio',
    'save': True,
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "api": 1,
    "author": "Altertech Group, https://www.altertech.com/",
    "cfg": {
        "sdir": "/opt/data/snd"
    },
    "description": "Play audio file",
    "help": "\nPlays audio file inside the specified directory. The file path should be\nrelative to the directory root, witout a starting slash.\n",
    "id": "test_a",
    "license": "Apache License 2.0",
    "mod": "audio",
    "mods_required": [
        "soundfile",
        "sounddevice"
    ],
    "version": "1.0.0"
}

Parameters:

  • k API key with master permissions
  • i extension ID
  • m extension module

Optionally:

  • c extension configuration
  • save save extension configuration after successful call

modhelp_ext - get extension usage help

http

POST /lm-api/modhelp_ext HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "m": "audio", "c": "functions" }

curl

curl -i -X POST http://localhost:8817/lm-api/modhelp_ext -H 'Content-Type: application/json' --data-raw '{"c": "functions", "k": "mykey", "m": "audio"}'

wget

wget -S -O- http://localhost:8817/lm-api/modhelp_ext --header='Content-Type: application/json' --post-data='{"c": "functions", "k": "mykey", "m": "audio"}'

httpie

echo '{
  "c": "functions",
  "k": "mykey",
  "m": "audio"
}' | http POST http://localhost:8817/lm-api/modhelp_ext Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/modhelp_ext', headers={
    'Content-Type': 'application/json',
}, json={
    'c': 'functions',
    'k': 'mykey',
    'm': 'audio',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "play(soundfile, gain=0, wait=True)": "Play sound file"
}

Parameters:

  • k API key with master permissions
  • m extension name (without .py extension)
  • c help context (cfg or functions)

modinfo_ext - get extension module info

http

POST /lm-api/modinfo_ext HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "m": "audio" }

curl

curl -i -X POST http://localhost:8817/lm-api/modinfo_ext -H 'Content-Type: application/json' --data-raw '{"k": "mykey", "m": "audio"}'

wget

wget -S -O- http://localhost:8817/lm-api/modinfo_ext --header='Content-Type: application/json' --post-data='{"k": "mykey", "m": "audio"}'

httpie

echo '{
  "k": "mykey",
  "m": "audio"
}' | http POST http://localhost:8817/lm-api/modinfo_ext Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/modinfo_ext', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
    'm': 'audio',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "api": 1,
    "author": "Altertech Group, https://www.altertech.com/",
    "description": "Play audio file",
    "help": "\nPlays audio file inside the specified directory. The file path should be\nrelative to the directory root, witout a starting slash.\n",
    "license": "Apache License 2.0",
    "mod": "audio",
    "mods_required": [
        "soundfile",
        "sounddevice"
    ],
    "version": "1.0.0"
}

Parameters:

  • k API key with master permissions
  • m extension module name (without .py extension)

set_ext_prop - set extension configuration property

appends property to extension configuration and reloads module

http

POST /lm-api/set_ext_prop HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "test_a", "p": "d", "v": 2, "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/set_ext_prop -H 'Content-Type: application/json' --data-raw '{"i": "test_a", "k": "mykey", "p": "d", "save": true, "v": 2}'

wget

wget -S -O- http://localhost:8817/lm-api/set_ext_prop --header='Content-Type: application/json' --post-data='{"i": "test_a", "k": "mykey", "p": "d", "save": true, "v": 2}'

httpie

echo '{
  "i": "test_a",
  "k": "mykey",
  "p": "d",
  "save": true,
  "v": 2
}' | http POST http://localhost:8817/lm-api/set_ext_prop Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/set_ext_prop', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'test_a',
    'k': 'mykey',
    'p': 'd',
    'save': True,
    'v': 2,
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i extension id
  • p property name (or empty for batch set)

Optionally:

  • v propery value (or dict for batch set)
  • save save configuration after successful call

unload_ext - unload macro extension

http

POST /lm-api/unload_ext HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "test_a" }

curl

curl -i -X POST http://localhost:8817/lm-api/unload_ext -H 'Content-Type: application/json' --data-raw '{"i": "test_a", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/unload_ext --header='Content-Type: application/json' --post-data='{"i": "test_a", "k": "mykey"}'

httpie

echo '{
  "i": "test_a",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/unload_ext Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/unload_ext', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'test_a',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i extension ID

Remote controllers

append_controller - connect remote UC via HTTP

Connects remote UC controller to the local.

http

POST /lm-api/append_controller HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "u": "localhost", "a": "secretkey", "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/append_controller -H 'Content-Type: application/json' --data-raw '{"a": "secretkey", "k": "mykey", "save": true, "u": "localhost"}'

wget

wget -S -O- http://localhost:8817/lm-api/append_controller --header='Content-Type: application/json' --post-data='{"a": "secretkey", "k": "mykey", "save": true, "u": "localhost"}'

httpie

echo '{
  "a": "secretkey",
  "k": "mykey",
  "save": true,
  "u": "localhost"
}' | http POST http://localhost:8817/lm-api/append_controller Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/append_controller', headers={
    'Content-Type': 'application/json',
}, json={
    'a': 'secretkey',
    'k': 'mykey',
    'save': True,
    'u': 'localhost',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "build": "2019031405",
    "connected": true,
    "description": "",
    "enabled": true,
    "full_id": "uc/ws1-v1",
    "group": "uc",
    "id": "ws1-v1",
    "managed": false,
    "mqtt_update": null,
    "oid": "remote_uc:uc/ws1-v1",
    "proto": "http",
    "static": true,
    "type": "remote_uc",
    "version": "3.2.0"
}

Parameters:

  • k API key with master permissions
  • u UC API uri (proto://host:port, port not required if default)
  • a remote controller API key ($key to use local key)

Optionally:

  • m ref:MQTT notifier<mqtt_> to exchange item states in real time (default: eva_1)
  • s verify remote SSL certificate or pass invalid
  • t timeout (seconds) for the remote controller API calls
  • save save connected controller configuration on the disk immediately after creation

disable_controller - disable connected controller

http

POST /lm-api/disable_controller HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "uc/ws1-v1", "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/disable_controller -H 'Content-Type: application/json' --data-raw '{"i": "uc/ws1-v1", "k": "mykey", "save": true}'

wget

wget -S -O- http://localhost:8817/lm-api/disable_controller --header='Content-Type: application/json' --post-data='{"i": "uc/ws1-v1", "k": "mykey", "save": true}'

httpie

echo '{
  "i": "uc/ws1-v1",
  "k": "mykey",
  "save": true
}' | http POST http://localhost:8817/lm-api/disable_controller Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/disable_controller', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'uc/ws1-v1',
    'k': 'mykey',
    'save': True,
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i controller id

Optionally:

  • save save configuration after successful call

enable_controller - enable connected controller

http

POST /lm-api/enable_controller HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "uc/ws1-v1", "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/enable_controller -H 'Content-Type: application/json' --data-raw '{"i": "uc/ws1-v1", "k": "mykey", "save": true}'

wget

wget -S -O- http://localhost:8817/lm-api/enable_controller --header='Content-Type: application/json' --post-data='{"i": "uc/ws1-v1", "k": "mykey", "save": true}'

httpie

echo '{
  "i": "uc/ws1-v1",
  "k": "mykey",
  "save": true
}' | http POST http://localhost:8817/lm-api/enable_controller Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/enable_controller', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'uc/ws1-v1',
    'k': 'mykey',
    'save': True,
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i controller id

Optionally:

  • save save configuration after successful call

get_controller - get connected controller information

http

POST /lm-api/get_controller HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "uc/ws1-v1" }

curl

curl -i -X POST http://localhost:8817/lm-api/get_controller -H 'Content-Type: application/json' --data-raw '{"i": "uc/ws1-v1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/get_controller --header='Content-Type: application/json' --post-data='{"i": "uc/ws1-v1", "k": "mykey"}'

httpie

echo '{
  "i": "uc/ws1-v1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/get_controller Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/get_controller', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'uc/ws1-v1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "build": "2019031405",
    "connected": true,
    "description": "",
    "enabled": true,
    "full_id": "uc/ws1-v1",
    "group": "uc",
    "id": "ws1-v1",
    "managed": false,
    "mqtt_update": null,
    "oid": "remote_uc:uc/ws1-v1",
    "proto": "http",
    "static": true,
    "type": "remote_uc",
    "version": "3.2.0"
}

Parameters:

  • k API key with master permissions
  • i controller id

list_controller_props - get controller connection parameters

http

POST /lm-api/list_controller_props HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "uc/ws1-v1" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_controller_props -H 'Content-Type: application/json' --data-raw '{"i": "uc/ws1-v1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_controller_props --header='Content-Type: application/json' --post-data='{"i": "uc/ws1-v1", "k": "mykey"}'

httpie

echo '{
  "i": "uc/ws1-v1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_controller_props Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_controller_props', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'uc/ws1-v1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "description": "",
    "enabled": true,
    "key": "secretkey",
    "mqtt_update": null,
    "reload_interval": 300,
    "retries": 2,
    "ssl_verify": true,
    "static": true,
    "timeout": 5.0,
    "uri": "http://localhost:8812"
}

Parameters:

  • k API key with master permissions
  • i controller id

list_controllers - get controllers list

Get the list of all connected UC controllers.

http

POST /lm-api/list_controllers HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_controllers -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_controllers --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_controllers Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_controllers', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[]

Parameters:

  • k API key with master permissions

list_remote - get a list of items from connected UCs

Get a list of the items loaded from the connected UC controllers. Useful to debug the controller connections.

http

POST /lm-api/list_remote HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "uc/ws1-v1" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_remote -H 'Content-Type: application/json' --data-raw '{"i": "uc/ws1-v1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_remote --header='Content-Type: application/json' --post-data='{"i": "uc/ws1-v1", "k": "mykey"}'

httpie

echo '{
  "i": "uc/ws1-v1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_remote Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_remote', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'uc/ws1-v1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    {
        "controller_id": "uc/ws1-v1",
        "description": "",
        "full_id": "env/temp_test",
        "group": "env",
        "id": "temp_test",
        "loc_x": null,
        "loc_y": null,
        "loc_z": null,
        "location": "",
        "oid": "sensor:env/temp_test",
        "status": 0,
        "type": "sensor",
        "value": "null"
    },
    {
        "action_enabled": true,
        "controller_id": "uc/ws1-v1",
        "description": "",
        "full_id": "nogroup/test2",
        "group": "nogroup",
        "id": "test2",
        "loc_x": null,
        "loc_y": null,
        "loc_z": null,
        "location": "",
        "nstatus": -1,
        "nvalue": "null",
        "oid": "unit:nogroup/test2",
        "status": -1,
        "status_labels": [
            {
                "label": "OFF",
                "status": 0
            },
            {
                "label": "ON",
                "status": 1
            }
        ],
        "type": "unit",
        "value": "null"
    }
]

Parameters:

  • k API key with master permissions

Optionally:

  • i controller id
  • g filter by item group
  • p filter by item type

reload_controller - reload controller

Reloads items from connected UC

http

POST /lm-api/reload_controller HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "uc/ws1-v1" }

curl

curl -i -X POST http://localhost:8817/lm-api/reload_controller -H 'Content-Type: application/json' --data-raw '{"i": "uc/ws1-v1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/reload_controller --header='Content-Type: application/json' --post-data='{"i": "uc/ws1-v1", "k": "mykey"}'

httpie

echo '{
  "i": "uc/ws1-v1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/reload_controller Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/reload_controller', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'uc/ws1-v1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i controller id

remove_controller - disconnect controller

http

POST /lm-api/remove_controller HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "uc/ws1-v1" }

curl

curl -i -X POST http://localhost:8817/lm-api/remove_controller -H 'Content-Type: application/json' --data-raw '{"i": "uc/ws1-v1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/remove_controller --header='Content-Type: application/json' --post-data='{"i": "uc/ws1-v1", "k": "mykey"}'

httpie

echo '{
  "i": "uc/ws1-v1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/remove_controller Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/remove_controller', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'uc/ws1-v1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i controller id

set_controller_prop - set controller connection parameters

http

POST /lm-api/set_controller_prop HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "uc/ws1-v1", "p": "reload_interval", "v": 60, "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/set_controller_prop -H 'Content-Type: application/json' --data-raw '{"i": "uc/ws1-v1", "k": "mykey", "p": "reload_interval", "save": true, "v": 60}'

wget

wget -S -O- http://localhost:8817/lm-api/set_controller_prop --header='Content-Type: application/json' --post-data='{"i": "uc/ws1-v1", "k": "mykey", "p": "reload_interval", "save": true, "v": 60}'

httpie

echo '{
  "i": "uc/ws1-v1",
  "k": "mykey",
  "p": "reload_interval",
  "save": true,
  "v": 60
}' | http POST http://localhost:8817/lm-api/set_controller_prop Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/set_controller_prop', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'uc/ws1-v1',
    'k': 'mykey',
    'p': 'reload_interval',
    'save': True,
    'v': 60,
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i controller id
  • p property name (or empty for batch set)

Optionally:

  • v propery value (or dict for batch set)
  • save save configuration after successful call

test_controller - test connection to remote controller

http

POST /lm-api/test_controller HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "uc/ws1-v1" }

curl

curl -i -X POST http://localhost:8817/lm-api/test_controller -H 'Content-Type: application/json' --data-raw '{"i": "uc/ws1-v1", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/test_controller --header='Content-Type: application/json' --post-data='{"i": "uc/ws1-v1", "k": "mykey"}'

httpie

echo '{
  "i": "uc/ws1-v1",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/test_controller Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/test_controller', headers={
    'Content-Type': 'application/json',
}, json={
    'i': 'uc/ws1-v1',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i controller id

Scheduled jobs

create_job - create new job

Creates new scheduled job. Job id (UUID) is generated automatically unless specified.

http

POST /lm-api/create_job HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/create_job -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/create_job --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/create_job Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/create_job', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "description": "",
    "enabled": false,
    "every": "",
    "id": "93061b49-3e20-458f-95da-4976eb608358",
    "last": null,
    "macro": null,
    "macro_args": [],
    "macro_kwargs": {},
    "oid": "job:jobs/93061b49-3e20-458f-95da-4976eb608358",
    "type": "job"
}

Parameters:

  • k API key with master permissions

Optionally:

  • u job UUID to set
  • v job properties (dict)
  • save save unit configuration immediately

destroy_job - delete job

Deletes scheduled job.

http

POST /lm-api/destroy_job HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "9c6e8c99-56fe-490c-8442-4936ba777499" }

curl

curl -i -X POST http://localhost:8817/lm-api/destroy_job -H 'Content-Type: application/json' --data-raw '{"i": "9c6e8c99-56fe-490c-8442-4936ba777499", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/destroy_job --header='Content-Type: application/json' --post-data='{"i": "9c6e8c99-56fe-490c-8442-4936ba777499", "k": "mykey"}'

httpie

echo '{
  "i": "9c6e8c99-56fe-490c-8442-4936ba777499",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/destroy_job Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/destroy_job', headers={
    'Content-Type': 'application/json',
}, json={
    'i': '9c6e8c99-56fe-490c-8442-4936ba777499',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i job id

get_job - get job information

http

POST /lm-api/get_job HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "9c6e8c99-56fe-490c-8442-4936ba777499" }

curl

curl -i -X POST http://localhost:8817/lm-api/get_job -H 'Content-Type: application/json' --data-raw '{"i": "9c6e8c99-56fe-490c-8442-4936ba777499", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/get_job --header='Content-Type: application/json' --post-data='{"i": "9c6e8c99-56fe-490c-8442-4936ba777499", "k": "mykey"}'

httpie

echo '{
  "i": "9c6e8c99-56fe-490c-8442-4936ba777499",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/get_job Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/get_job', headers={
    'Content-Type': 'application/json',
}, json={
    'i': '9c6e8c99-56fe-490c-8442-4936ba777499',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "description": "",
    "enabled": true,
    "every": "",
    "id": "9c6e8c99-56fe-490c-8442-4936ba777499",
    "last": null,
    "macro": "tests/test1",
    "macro_args": [
        "test"
    ],
    "macro_kwargs": {},
    "oid": "job:jobs/9c6e8c99-56fe-490c-8442-4936ba777499",
    "type": "job"
}

Parameters:

  • k API key with master permissions
  • i job id

list_job_props - list job properties

Get all editable parameters of the scheduled job.

http

POST /lm-api/list_job_props HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "9c6e8c99-56fe-490c-8442-4936ba777499" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_job_props -H 'Content-Type: application/json' --data-raw '{"i": "9c6e8c99-56fe-490c-8442-4936ba777499", "k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_job_props --header='Content-Type: application/json' --post-data='{"i": "9c6e8c99-56fe-490c-8442-4936ba777499", "k": "mykey"}'

httpie

echo '{
  "i": "9c6e8c99-56fe-490c-8442-4936ba777499",
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_job_props Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_job_props', headers={
    'Content-Type': 'application/json',
}, json={
    'i': '9c6e8c99-56fe-490c-8442-4936ba777499',
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "description": "",
    "enabled": true,
    "every": "",
    "macro": "tests/test1",
    "macro_args": [
        "test"
    ],
    "macro_kwargs": {}
}

Parameters:

  • k API key with master permissions
  • i job id

list_jobs - get jobs list

Get the list of all available scheduled jobs.

http

POST /lm-api/list_jobs HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey" }

curl

curl -i -X POST http://localhost:8817/lm-api/list_jobs -H 'Content-Type: application/json' --data-raw '{"k": "mykey"}'

wget

wget -S -O- http://localhost:8817/lm-api/list_jobs --header='Content-Type: application/json' --post-data='{"k": "mykey"}'

httpie

echo '{
  "k": "mykey"
}' | http POST http://localhost:8817/lm-api/list_jobs Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/list_jobs', headers={
    'Content-Type': 'application/json',
}, json={
    'k': 'mykey',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

[
    {
        "description": "",
        "enabled": false,
        "every": "",
        "id": "9d8a338f-cdc4-46ac-8610-ba3b1597c73e",
        "last": null,
        "macro": null,
        "macro_args": [],
        "macro_kwargs": {},
        "oid": "job:jobs/9d8a338f-cdc4-46ac-8610-ba3b1597c73e",
        "type": "job"
    },
    {
        "description": "",
        "enabled": false,
        "every": "",
        "id": "7545a768-ce67-44ad-9544-2a54ad6c7e83",
        "last": null,
        "macro": null,
        "macro_args": [],
        "macro_kwargs": {},
        "oid": "job:jobs/7545a768-ce67-44ad-9544-2a54ad6c7e83",
        "type": "job"
    }
]

Parameters:

  • k API key with master permissions

set_job_prop - set job parameters

Set configuration parameters of the scheduled job.

http

POST /lm-api/set_job_prop HTTP/1.1
Host: localhost:8817
Content-Type: application/json

{ "k": "mykey", "i": "9c6e8c99-56fe-490c-8442-4936ba777499", "p": "macro_args", "v": "test", "save": true }

curl

curl -i -X POST http://localhost:8817/lm-api/set_job_prop -H 'Content-Type: application/json' --data-raw '{"i": "9c6e8c99-56fe-490c-8442-4936ba777499", "k": "mykey", "p": "macro_args", "save": true, "v": "test"}'

wget

wget -S -O- http://localhost:8817/lm-api/set_job_prop --header='Content-Type: application/json' --post-data='{"i": "9c6e8c99-56fe-490c-8442-4936ba777499", "k": "mykey", "p": "macro_args", "save": true, "v": "test"}'

httpie

echo '{
  "i": "9c6e8c99-56fe-490c-8442-4936ba777499",
  "k": "mykey",
  "p": "macro_args",
  "save": true,
  "v": "test"
}' | http POST http://localhost:8817/lm-api/set_job_prop Content-Type:application/json

python-requests

requests.post('http://localhost:8817/lm-api/set_job_prop', headers={
    'Content-Type': 'application/json',
}, json={
    'i': '9c6e8c99-56fe-490c-8442-4936ba777499',
    'k': 'mykey',
    'p': 'macro_args',
    'save': True,
    'v': 'test',
})

response

HTTP/1.1 200 OK
Allow: GET, HEAD, POST
Cache-Control: no-cache, no-store, must-revalidate
Content-Type: application/json
Expires: 0
Pragma: no-cache

{
    "result": "OK"
}

Parameters:

  • k API key with master permissions
  • i job id
  • p property name (or empty for batch set)

Optionally:

  • v propery value (or dict for batch set)
  • save save configuration after successful call