Hi, I'm trying to understand how to do this in LUA.
The object is to connect to wemo to get the current device state then I'll use this to update the vd status and image.
I don't have the header included in the post. After hours of googling I havn't progressed far.
headers =
{
["Content-Type"] = 'text/xml; charset="utf-8"',
["SOAPACTION"] = '"urn:Belkin:service:basicevent:1#GetBinaryState"',
}
--[[
%% properties
%% globals
--]]
local thisdevice = fibaro:getSelfId()
local ip = fibaro:getValue(thisdevice, 'IPAddress')
local port = fibaro:getValue(thisdevice, 'TCPPort')
local httpSession = Net.FHttp(ip, port);
httpSession = Net.FHttp(ip,port);
-- xml to json - wemo get device state
-- xml = "<?xml version='1.0' encoding='utf-8'?><s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/' s:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'><s:Body><u:GetBinaryState xmlns:u='urn:Belkin:service:basicevent:1'></u:GetBinaryState></s:Body></s:Envelope>";
local jsonString= '{ "s:Envelope": { "-xmlns:s": "http://schemas.xmlsoap.org/soap/envelope/", "-s:encodingStyle": "http://schemas.xmlsoap.org/soap/encoding/", "s:Body": { "u:GetBinaryState": { "-xmlns:u": "urn:Belkin:service:basicevent:1" }}}}';
response, status, errorCode = httpSession:POST("/upnp/control/basicevent1",jsonString);
--fibaro:debug(response);
--local a = string.match(response, "^.+<binaryState>(.+)</binaryState>.+$");
fibaro:debug("Response = "..response)
fibaro:debug("Status = "..status)
fibaro:debug("ErrorCode = "..errorCode)