Just in case.... Lua code (vera, etc) for the new API

Posted on
Wed Mar 29, 2023 10:13 am
shapa offline
Posts: 483
Joined: Sep 08, 2014
Location: Swindon

Just in case.... Lua code (vera, etc) for the new API

I converted my old Lua code (running Vera in my motorcycle shed) to use the new API. Works fine.

local http = require("socket.http")
local ltn12 = require("ltn12")
local path = "http://172.16.1.100:8176/v2/api/command?api-key=xxxxx"
local payload = [[ {"message": "indigo.variable.updateValue", "objectId": 51630695, "parameters": {"value": "False"}} ]]

local response_body = { }
local res, code, response_headers, status = http.request
{
url = path,
method = "POST",
headers =
{
["Content-Type"] = "application/json",
["Content-Length"] = payload:len()
},
source = ltn12.source.string(payload),
sink = ltn12.sink.table(response_body)
}

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests