LUA, parse JSON ...

Moderator: leecollings

Post Reply
Loops
Posts: 3
Joined: Wednesday 22 October 2014 21:15
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

LUA, parse JSON ...

Post 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
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests