domoticz_applyJsonPath not working at all on pi

Moderator: leecollings

Post Reply
thetrueavatar
Posts: 3
Joined: Friday 01 December 2017 21:22
Target OS: -
Domoticz version:
Contact:

domoticz_applyJsonPath not working at all on pi

Post by thetrueavatar »

Hello, I'm trying to use de jsonPath query from domoticz_applyJsonPath but it doesn't work at all. It always return null data even with the provided example and simple jsonpath in the lua_parser directory: example_json.lua.
I have update it to provide a custom json from a file with this:

Code: Select all

-- Example of JSON parser handling data with the following structure
local open = io.open

local function read_file(path)
    local file = open(path, "rb") -- r read mode and b binary mode
    if not file then return nil end
    local content = file:read "*a" -- *a or *all reads the whole file
    file:close()
    return content
end
local s=read_file("/home/pi/domoticz/scripts/lua_parsers/example.json")
-- Update some devices (index are here for this example)
local id = domoticz_applyJsonPath(s,'.id')
local s = domoticz_applyJsonPath(s,'.temperature')
print(id .. temperature)
domoticz_updateDevice(id,'',s)
and json file

Code: Select all

{"id": 13,"name": "outside","temperature": 12.50}
It's very frustrating cause there is almost no documentation about it while it's a real nice feature to use in conjunction with the http(s) poller.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest