Bonjour,
Vous devez corriger le code pour chaque bouton et curseur du périphérique virtuel (VD). Alors, TTS devrait fonctionner à nouveau.
sendSoapMessage = function(url, service, action, args, callback, retry)
local socket = createSocket();
if (socket == nil) then
return;
end
retry = retry or 0
-- prepare data
local url = "POST " .. url .. " HTTP/1.1";
fibaro:debug(ip)
local so1="HOST: ".. ip ..":1400"
local soapaction = "SOAPACTION: \"" .. service .. "#" .. action.name .. "\"";
local body = createRequestBody(action.name, action.service, tostring(args or ""));
local envelope = "<?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>" .. body .. "</s:Body></s:Envelope>";
local ctl = "Content-Length: " .. string.len(envelope);
local payload = url .. "\r\n" .. so1 .. "\r\n" .. ctl .. "\r\n" .. soapaction .. "\r\n" .. "\r\n" .. envelope;
-- write data
local bytes, errorcode = socket:write(payload);
if (errorcode == 0) then
local state, errorcode = socket:read();
if (errorcode == 0) then
if (string.len(state or "") > 0) then
-- callback
if (callback ~= nil) then
reponseCallback(callback, state);
end
-- dispose ...
disposeSocket(socket);
return true;
else
fibaro:debug("Error: Invalid response. response length: " .. string.len(state or ""));
end
else
if (retry < 5) then
fibaro:debug("retry #"..retry.." action: " .. action.name);
return sendSoapMessage(url, service, action, args, callback, (retry + 1));
else
fibaro:debug("Error: Code returned "..tostring(errorcode or ""));
end
end
elseif (errorcode == 2) then
fibaro:debug("Error: You must check your IP and PORT settings.");
else
if (retry < 5) then
fibaro:debug("retry #"..retry.." action: " .. action.name);
return sendSoapMessage(url, service, action, args, callback, (retry + 1));
else
fibaro:debug("Error: Code returned "..tostring(errorcode or ""));
end
end
-- dispose ...
disposeSocket(socket);
-- default response
return false;
end