This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

JSON items into groups
#1
Hi there,

I'm working with Airzone local API, and I need to write every item into LogicMachine group objects.

This is my script:

Code:
require 'ltn12'
require 'socket.http'
json = require("json")

local request_url = "http://192.168.1.111:3000/api/v1/hvac?systemid=01&zoneid=15"
local response_body = {}

local body, code, hdrs, stat = socket.http.request
  {
    url = request_url;
    sink = ltn12.sink.table(response_body);
  }

log (response_body)
 
And this is the response I get:

Code:
* table:
[1]
  * string: {
    "data":    [{
            "systemID":    1,
            "zoneID":    15,
            "name":    "ZONA 15",
            "thermos_type":    2,
            "thermos_firmware":    "4.53",
            "thermos_radio":    0,
            "on":    1,
            "double_sp":    0,
            "coolsetpoint":    22,
            "coolmaxtemp":    30,
            "coolmintemp":    15,
            "heatsetpoint":    22,
            "heatmaxtemp":    30,
            "heatmintemp":    15,
            "maxTemp":    30,
            "minTemp":    15,
            "setpoint":    22,
            "roomTemp":    22.9,
            "sleep":    0,
            "temp_step":    0.5,
            "mode":    3,
            "speed":    0,
            "coldStage":    2,
            "heatStage":    2,
            "coldStages":    2,
            "heatStages":    2,
            "humidity":    22,
            "units":    0,
            "errors":    [],
            "air_demand":    0,
            "floor_demand":    0,
            "cold_demand":    0,
            "heat_demand":    0,
            "heatangle":    0,
            "coldangle":    0,
            "master_zoneID":    15,
            "eco_adapt":    "off",
            "antifreeze":    0
        }]
}

I'm a newbie at json stuff. Please, can you help me with writing every item (systemID, zoneID, name, etc) into LogicMachine group objects? Thanks in advance!
Reply


Messages In This Thread
JSON items into groups - by alexll - 13.01.2025, 14:19
RE: JSON items into groups - by RomansP - Yesterday, 07:58
RE: JSON items into groups - by alexll - Yesterday, 08:29

Forum Jump: