Page 1 of 1

Fetch website content in LUA

Posted: Sunday 12 February 2017 12:26
by MAGPeters
Hi All,

New to Domoticz. I am running Domoticz on Windows 10 (currenly later to migrate to Pi). I want to receive data from a HomeWizard homeautomation system. This should be easy by writing in LUA

local f = assert(io.popen("curl -s http://192.xx.xx.xx/,passwd>/swlist" , 'r')), response (in variable f) should be:

{"status": "ok", "version": "3.372", "request": {"route": "/swlist" },
-- "response": [{"id":0,"name":"Lamp 1 Zithoek","type":"switch","status":"on","favorite":"no"},
-- {"id":1,"name":"Lamp 2 Eethoek","type":"switch","status":"on","favorite":"no"},
-- {"id":2,"name":"Balkon zolder","type":"switch","status":"on","favorite":"no"},
-- {"id":3,"name":"Tuin","type":"switch","status":"on","favorite":"no"},
-- {"id":4,"name":"PV ventilator","type":"switch","status":"off","favorite":"no"},
-- {"id":5,"name":"4 keuken links","type":"switch","status":"on","favorite":"no"},
-- {"id":6,"name":"5 Keuken rechts","type":"switch","status":"on","favorite":"no"},
-- {"id":7,"name":"Studeerkamer","type":"switch","status":"on","favorite":"no"},
-- {"id":8,"name":"Badkamer","type":"switch","status":"off","favorite":"no"}]}

When I try this in a webbrowser this works. However in Lua I don't get anaything. Which mistake do I make??

Regards,

Michel.

Re: Fetch website content in LUA

Posted: Sunday 12 February 2017 12:28
by jvdz
You don't want to PIPE the output into /swlist, so think you need to remove ">/swlist" from that line.

Jos