Page 1 of 1

Lua & Json example

Posted: Sunday 17 December 2017 21:26
by SVdHeyden
Hi all,

I've searching the forum for a while looking for an example of switching on/off a switch via json. The reason behind is that the switch can be controlled by the Domoticz general way as the dat send by Domoticz is the command to set dimmer values while the device is just a switch (FGS-213 from Fibaro)

So I was wondering if I can control the device just by using the json way of working.

So is there someone out there that can explain or give an easy example (would be very nice) how to use json in lua

Many thanks.

Re: Lua & Json example

Posted: Sunday 17 December 2017 22:18
by jvdz
Is it this you are looking for: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s ?
Jos

Re: Lua & Json example

Posted: Tuesday 19 December 2017 22:36
by SVdHeyden
Thanks jvdz

I've seen that page already however it's not clear how to integrate this into LUA. In the location domotics/scripts/lua there is also a file JSON.lua but also here It isn't clear how to manage the json commands.

If I have already one example to control a simple switch it will already help

I've used already json to collect battery status of the devices in the network via the following os execution:

Code: Select all

os.execute("curl 'http://username:pasword@" .. DomoticsIP .. ":" .. DomoticzPort .. "/json.htm?type=devices&order=name' 2>/dev/null| /user/local/bin/jq -r '.result[] | [.Name, .idx, . BatteryLevel, .Manufacturer] | @csv' >" .. DeviceFileName)
now I want to set some values via json.

Thanks