Page 1 of 1

LUA, parse JSON ...

Posted: Saturday 30 March 2019 10:41
by Loops
Domoticz V4.9701

Hello,

I'im trying to parse JSON from a Shelly 1 but my code is wrong and i don't understant why.
I've used example_json.lua and i've read some code in this forum.

The shelly URL is : http://192.168.0.122/relay/0 and give me :
{"ison":true, "has_timer":false}

I've a http poller :
URL = http://192.168.0.122/relay/0
command : shelly.lua
delay : 10

I've the script : /home/loops/domoticz/scripts/lua_parsers/shelly.lua :
with :

Code: Select all

s = request['content'];
print(s)

local etat = domoticz_applyJsonPath(s,'.ison')
print("etat : "..etat)
and in the log i've :

Code: Select all

2019-03-30 10:36:38.379 CLuaHandler: udevices: {"ison":true, "has_timer":false}
2019-03-30 10:36:38.379 Error: CLuaHandler: /home/loops/domoticz/scripts/lua_parsers/shelly.lua:5: attempt to concatenate local 'etat' (a nil value)
I dont understand why the var etat is empty !

Thank you so mutch for your help !

JC