Fetch website content in LUA

Moderator: leecollings

Post Reply
MAGPeters
Posts: 2
Joined: Sunday 12 February 2017 12:18
Target OS: Windows
Domoticz version:
Contact:

Fetch website content in LUA

Post 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.
User avatar
jvdz
Posts: 2189
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Fetch website content in LUA

Post by jvdz »

You don't want to PIPE the output into /swlist, so think you need to remove ">/swlist" from that line.

Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Droll and 1 guest