Aller au contenu

Module UPS monitoring à travers Synology, besoin d'aide.


Kana-chan

Messages recommandés

Bonjour,

 

Je vous sollicite pour de l'aide.

 

Je n'arrive pas à porter mon VD HC2 vers un QuickApp HC3.

Voici le code du VD sur HC2 :

-- Interrogate the Synology UPS Server
-- Configuration used  for testing :
--  * a Synology DS1010+ with DSM 5.2-5967 Update 8
--  * a Eaton Ellipse PRO 1200

local debug 		= false;
local globalVarName	= "UpsStatus"; -- values "power-line" or "battery"
local username		= "monuser";
local password		= "secret";
local selfId		= fibaro:getSelfId();
local _deviceIp		= fibaro:get(selfId, 'IPAddress');
local _devicePort	= fibaro:get(selfId, 'TCPPort');
if (_devicePort == nil) then _devicePort = 3493; end
local tcpSocket		= Net.FTcpSocket(_deviceIp, _devicePort);
local cr = string.char(13);
local lf = string.char(10);
local crLf = cr..lf;

-- icônes à adapter
local icones = {
	 ["0%"]			= 1051
	,["50%"]		= 1050
	,["100%"]		= 1049
	,["normal"]		= 1047
	,["on"]			= 1046
	,["off"]		= 1045
	,["secteur"]	= 1048
}

function trace(text, color)
    color = color or "white";
    if debug then 
        fibaro:debug("<font color='"..color.."'>"..text.."</font>");
    end
end -- trace

function changeIcon(newIcon)
	local currentIcon = tonumber(fibaro:getValue(selfId, "currentIcon"));
	trace("currentIcon="..currentIcon..",  newIcon="..newIcon, "cyan");
	if (newIcon ~= currentIcon) then
		fibaro:call(selfId, "setProperty", "currentIcon", newIcon);
		trace("new icon : "..newIcon.."OK", "cyan");
	end
end -- changeIcon

function tracerr(text, color)
    color = color or "red";
    fibaro:debug("<font color='red'>ERROR! </font>".."<font color='"..color.."'>"..text.."</font>");
end -- tracerr

function split(text, sep)
	local sep, fields = sep or ":", {};
	local pattern = string.format("([^%s]+)", sep);
	text:gsub(pattern, function(c) fields[#fields+1] = c end);
	return fields;
end -- split

function createGlobalIfNotExists(varName, defaultValue)
	local payload = fibaro:getGlobalValue(varName);
	if ((payload == nil) or (payload == "")) then
		trace("Création de la variable " .. varName .. " avec comme valeur par défaut " .. defaultValue, "orange");
		local newVar = {};
		newVar.name = varName;
		newVar.value = defaultValue;
		local HC2 = Net.FHttp("127.0.0.1", 11111);
		HC2:POST("/api/globalVariables", json.encode(newVar));
	end
end

function writeSocket(data)
	trace("writeSocket, data="..data, "lightgreen");
	local bytes, errorCode = tcpSocket:write(data);
	if errorCode == 0 then
		return true;
	else
		tracerr("writeSocket, errorCode="..errorCode);
		return false;
	end
end -- writeSocket

function readSocket()
	local err, length = 0, 1;
	local buffer, data = "", "";
	while (err==0 and length>0) do
		data, err = tcpSocket:read();
		length = string.len(data);
		buffer = buffer..data;
	end
	return buffer, err;
end -- readSocket

function connect()
	trace("connect, connecting to server", "lightgreen");
	if writeSocket("USERNAME " .. username .. crLf) then
		local response, err = readSocket();
		if ((string.len(response) >=2) and (string.sub(response, 1, 2) == "OK")) then
			trace("connect, USERNAME OK", "lightgreen");
			if writeSocket("PASSWORD " .. password .. crLf) then
				response, err = readSocket();
				if ((string.len(response) >=2) and (string.sub(response, 1, 2) == "OK")) then
					trace("connect, PASSWORD OK", "lightgreen");
					return true;
				else
					tracerr("connect, PASSWORD bad response, err="..err..", response="..response or "");
					return false;
				end
			else
				tracerr("connect, PASSWORD writeSocket error");
			end
		else
			tracerr("connect, USERNAME bad response, err="..err..", response="..response or "");
			return false;
		end
	else
		tracerr("connect, USERNAME writeSocket error");
	end
end -- connect

function logout()
	if writeSocket("LOGOUT\n") then
		local response, err = readSocket();
		if err == 0 then
			trace("logout, successfull, response=" .. response, "lightgreen");
		else
			tracerr("logout, readSocket error, err=" .. err);
		end
	else
		tracerr("logout, writeSocket error");
	end
end -- logout

function ask(question)
	if writeSocket(question .. crLf) then
		local response, err = readSocket();
		if (response) then
			return response;
		else
			return nil;
		end
	else
		tracerr("ask, writeSocket error, question=" .. question);
	end
end -- ask

function listToTable(list, sep)
	local arr = split(list, sep);
	-- Go through the table 
	local i, done = 1, false;
	local payload = {};
	while (not done) do -- populate the table 
		if (string.sub(arr[i], 1, 18) == "BEGIN LIST VAR UPS") then
			i = i + 1;
		else
			if (string.sub(arr[i], 1, 16) == "END LIST VAR UPS") then
				done = true;
			else
				local keyEnd = string.find(arr[i], " ");
				local key = string.sub(arr[i], 1, keyEnd-1);
				local value = string.sub(arr[i], keyEnd+1);
				payload[key] = string.gsub(value, '"', '');
				trace("payload["..key.."]="..payload[key], "cyan");
				i = i + 1;
				done = (arr[i] == nil);
			end
		end
	end
	return payload;
end -- listToTable

local icone = icones["normal"];
changeIcon(icone);
tcpSocket:setReadTimeout(200);
if connect() then
	trace("Connected to UPS server (".._deviceIp..":".._devicePort..")", "lightgreen");
	local listVar = ask("LIST VAR UPS");
--	trace("listVar="..listVar, "cyan");
	listVar = string.gsub(listVar, "VAR UPS ", ""); -- each item begins with "VAR UPS ", eliminate them
--	trace("listVar="..listVar, "cyan");
	local varUps = listToTable(listVar, "\n");
	fibaro:call(selfId, "setProperty", "ui.Modele.value",			varUps["ups.model"] or "");
	fibaro:call(selfId, "setProperty", "ui.Charge.value",			(varUps["battery.charge"] or "") .. " %");
	fibaro:call(selfId, "setProperty", "ui.Status.value",			varUps["ups.status"] or "");
	fibaro:call(selfId, "setProperty", "ui.BatteryRuntime.value",	(varUps["battery.runtime"] or "") .. " sec");
	fibaro:call(selfId, "setProperty", "ui.InputVoltage.value",		(varUps["input.voltage"] or "") .. " V");
	fibaro:call(selfId, "setProperty", "ui.RealPower.value",		(varUps["ups.realpower.nominal"] or "") .. " W");
	fibaro:call(selfId, "setProperty", "ui.BatteryVoltage.value",	(varUps["battery.voltage"] or "") .. " V");
	fibaro:call(selfId, "setProperty", "ui.BatteryMFR.value",		(varUps["battery.mfr.date"] or "") .. "");
	fibaro:call(selfId, "setProperty", "ui.BatteryDate.value",		(varUps["battery.date"] or "") .. "");
	
	createGlobalIfNotExists(globalVarName, "power-line");
	if (varUps["ups.status"] and (string.sub(varUps["ups.status"], 1, 4) == "OB D")) then -- values "OL CHRG", "OB DISCHRG", "OL DISCHRG"
		trace("UPS is on battery!", "yellow");
		fibaro:setGlobal(globalVarName, "battery");
		if (varUps["battery.charge"]) then
			if (tonumber(varUps["battery.charge"]) > 80) then
				icone = icones["100%"];
			elseif (tonumber(varUps["battery.charge"]) > 30) then
				icone = icones["50%"];
			else
				icone = icones["0%"];
			end
		end
	elseif (varUps["ups.status"] and (string.sub(varUps["ups.status"], 1, 4) == "OL D")) then
		trace("UPS is on line, pb battery.", "red");
		fibaro:setGlobal(globalVarName, "power-line");
		if (varUps["battery.charge"]) then
			if (tonumber(varUps["battery.charge"]) > 80) then
				icone = icones["100%"];
			elseif (tonumber(varUps["battery.charge"]) > 30) then
				icone = icones["50%"];
			else
				icone = icones["0%"];
			end
		end
	else
		fibaro:setGlobal(globalVarName, "power-line");
		if ((varUps["battery.charge"] and tonumber(varUps["battery.charge"]) < 100) or varUps["ups.status"] and (string.sub(varUps["ups.status"], 1, 4) == "OL C")) then
			trace("UPS is on line and charging.", "lime");
			icone = icones["secteur"];
		else
			trace("UPS is on line.", "lime");
			icone = icones["on"];
		end
	end
	--local aVar = ask("GET VAR UPS ups.temperature");
	--trace("aVar="..aVar, "cyan");
    logout();
else
	trace("unable to connect to UPS server (".._deviceIp..":".._devicePort..")", "red");
	icone = icones["off"];
end
changeIcon(icone);

Je cherche à faire la même chose en QuickApp sur le HC3 mais j'ai des soucis avec le passage de Net.FTcpSocket() en HC2 à net.TCPSocket() en HC3.

N'étant pas à l'aise déjà avec ce nouveau système, je suis perdu.

 

Voici le code actuel en HC3:

function QuickApp:onInit()
  self:debug("QuickApp:onInit")

  -- Interrogate the Synology UPS Server
  -- Configuration used  for testing :
  --  * a Synology DS1010+ with DSM 5.2-5967 Update 8
  --  * a Eaton Ellipse PRO 1200

  self.myDebug         = true;
  self.varName         = "UpsStatus"; -- values "power-line" or "battery"
  self.username        = "monuser";
  self.password        = "secret";
  self._deviceIp       = self:getVariable('IPAddress');
  self._devicePort     = self:getVariable('TCPPort');
  if (self._devicePort == nil) then self._devicePort = "3493"; end
  self._devicePort     = tonumber(self._devicePort);
  self.socketTCP       = net.TCPSocket({timeout = 10000});
  self.response        = {};
  self.err             = "";
  self.cr              = string.char(13);
  self.lf              = string.char(10);
  self.crLf            = self.cr .. self.lf;
  self.sleeping        = 240; -- secondes
  self.myInstance      = { ["lastrun"] = 0, ["every"] = self.sleeping };
  self.isConnected     = false;
  self.compteur        = 0;
  
  self.display = {
    ["BatteryDate"] = "Batterie Date : ",
    ["BatteryMFR"] = "Batterie MFR : ",
    ["BatteryVoltage"] = "Batterie Volt : ",
    ["RealPower"] = "Puissance : ",
    ["InputVoltage"] = "Entrée Volt : ",
    ["BatteryRuntime"] = "Autonomie : ",
    ["Status"] = "Statut : ",
    ["Charge"] = "Charge : ",
    ["Modele"] = " Modèle : "
  }

  -- icônes à adapter
  self.icones = {
    ["0%"]      = 1022,
    ["50%"]     = 1023,
    ["100%"]    = 1021,
    ["normal"]  = 1024,
    ["on"]      = 1026,
    ["off"]     = 1025,
    ["secteur"] = 1020
  };
  self:updateProperty("deviceIcon", 1024);
  --self:connect();
end

function QuickApp:trace(text, color)
  color = color or "white";
  if self.myDebug == true then
    print("Debug: <font color='"..color.."'>"..text.."</font>");
  end
end -- trace

function QuickApp:changeIcon(newIcon)
	self:trace("newIcon=" .. newIcon, "cyan");
	self:updateProperty("deviceIcon", newIcon);
	self:trace("new icon : " .. newIcon .. " OK", "cyan");
end -- changeIcon

function QuickApp:tracerr(text, color)
  color = color or "red";
  print("<font color='red'>ERROR! </font><font color='" .. color .. "'>" .. text .. "</font>");
end -- tracerr

function QuickApp:split(text, sep)
	local sep, fields = sep or ":", {};
	local pattern = string.format("([^%s]+)", sep);
	text:gsub(pattern, function(c) fields[#fields+1] = c end);
	return fields;
end -- split

function QuickApp:writeSocket(data)
	self:trace("writeSocket, data=" .. data, "lightgreen");
    self.socketTCP:write(data, {
        success = function() -- the function that will be triggered when the data is correctly sent
            --print("data sent: "..data);
        end,
        error = function(myErr) -- the function that will be triggered in the event of an error in data transmission
            self.err = myErr;
            print("error while sending data: ", self.err);
        end
    })
end -- writeSocket

-- function handling the read data
-- normally this is where the data reported by the device will be handled
function QuickApp:onDataReceived(data)
    print("onDataReceived: ", data);
    self.response[self.compteur] = data;
    self.compteur = self.compteur + 1;
end

-- method for reading data from the socket
-- since the method itself has been looped, it should not be called from other locations than QuickApp:connect
function QuickApp:waitForResponseFunction()
  self.socketTCP:readUntil("\n", { -- reading a data package from the socket
    success = function(data)
      self:onDataReceived(data); -- handling of received data
      self:waitForResponseFunction(); -- looping of data readout
    end,
    error = function() -- a function that will be called in case of an error when trying to receive data, e.g. disconnecting a socket
      print("Response Error or no response");
      self.socketTCP:close(); -- socket closed
      --fibaro.setTimeout(5000, function() self:connect(); end) -- re-connection attempt (every 5s)
    end
  })
end

-- a method to open a TCP connection.
-- if the connection is successful, the data readout loop will be called QuickApp:waitForResponseFunction()
function QuickApp:connect()
  self.socketTCP:connect(self._deviceIp, self._devicePort, { -- connection to the device with the specified IP and port
    success = function() -- the function will be triggered if the connection is correct
      print("Connected");
      self:waitForResponseFunction(); -- launching a data readout "loop"
      if self:connection() then
        self.isConnected = true;
      end
    end,
    error = function(err) -- a function that will be triggered in case of an incorrect connection, e.g. timeout
      self.socketTCP:close(); -- closing the socket
      print("Connection Error");
      --fibaro.setTimeout(5000, function() self:connect(); end) -- re-connection attempt (every 5s)
    end
  })
end

function QuickApp:connection()
  self:trace("Connect, connecting to server", "lightgreen");
  self:writeSocket("USERNAME " .. self.username .. self.crLf);
  self:writeSocket("PASSWORD " .. self.password .. self.crLf);
  self:ask("LIST VAR UPS");
  return true;
end

function QuickApp:logout()
  self:writeSocket("LOGOUT" .. self.crLf);
  self:trace("logout, successfull", "lightgreen");
  self.socketTCP:close();
  self.compteur = 0;
end -- logout

function QuickApp:ask(question)
  self:writeSocket(question .. self.crLf);
  if (self.response) then
    return self.response;
  else
    return nil;
  end
end -- ask

function QuickApp:listToTable(list, sep)
	local arr = self:split(list, sep);
	-- Go through the table 
	local i, done = 1, false;
	local payload = {};
	while (not done) do -- populate the table 
		if (string.sub(arr[i], 1, 18) == "BEGIN LIST VAR UPS") then
			i = i + 1;
		else
			if (string.sub(arr[i], 1, 16) == "END LIST VAR UPS") then
				done = true;
			else
				local keyEnd = string.find(arr[i], " ");
				local key = string.sub(arr[i], 1, keyEnd-1);
				local value = string.sub(arr[i], keyEnd+1);
				payload[key] = string.gsub(value, '"', '');
				self:trace("payload[" .. key .. "]=" .. payload[key], "cyan");
				i = i + 1;
				done = (arr[i] == nil);
			end
		end
	end
	return payload;
end -- listToTable

function QuickApp:computeResponses()
  local returned_response = "";
  for index = 3, self.compteur-2, 1 do
    returned_response = returned_response .."\n".. self.response[index];
  end
  return returned_response;
end

function QuickApp:refreshAll()
	local icone = self.icones["normal"];
	self:changeIcon(icone);
	--self.socketTCP:setReadTimeout(200);
	if self.isConnected then
		local listVar = self:computeResponses();
	    --self:trace("listVar=" .. listVar, "cyan");
		listVar = string.gsub(listVar, "VAR UPS ", ""); -- each item begins with "VAR UPS ", eliminate them
	    --trace("listVar=" .. listVar, "cyan");
		local varUps = self:listToTable(listVar, "\n");
		self:updateView("Modele", "text", self.display["Modele"]..varUps["ups.model"] or "");
		self:updateView("Charge", "text", self.display["Charge"]..(varUps["battery.charge"] or "") .. " %");
		self:updateView("Status", "text", self.display["Status"]..varUps["ups.status"] or "");
		self:updateView("BatteryRuntime", "text", self.display["BatteryRuntime"]..(varUps["battery.runtime"] or "") .. " sec");
		self:updateView("InputVoltage", "text", self.display["InputVoltage"]..(varUps["input.voltage"] or "") .. " V");
		self:updateView("RealPower", "text", self.display["RealPower"]..(varUps["ups.realpower.nominal"] or "") .. " W");
		self:updateView("BatteryVoltage", "text", self.display["BatteryVoltage"]..(varUps["battery.voltage"] or "") .. " V");
		self:updateView("BatteryMFR", "text", self.display["BatteryMFR"]..(varUps["battery.mfr.date"] or "") .. "");
		self:updateView("BatteryDate", "text", self.display["BatteryDate"]..(varUps["battery.date"] or "") .. "");
		
		self:setVariable(self.varName, "power-line");
		if (varUps["ups.status"] and (string.sub(varUps["ups.status"], 1, 4) == "OB D")) then -- values "OL CHRG", "OB DISCHRG", "OL DISCHRG"
			self.trace("UPS is on battery!", "yellow");
			self:setVariable(self.varName, "battery");
			if (varUps["battery.charge"]) then
				if (tonumber(varUps["battery.charge"]) > 80) then
					icone = self.icones["100%"];
				elseif (tonumber(varUps["battery.charge"]) > 30) then
					icone = self.icones["50%"];
				else
					icone = self.icones["0%"];
				end
			end
		elseif (varUps["ups.status"] and (string.sub(varUps["ups.status"], 1, 4) == "OL D")) then
			self.trace("UPS is on line, pb battery.", "red");
			self:setVariable(self.varName, "power-line");
			if (varUps["battery.charge"]) then
				if (tonumber(varUps["battery.charge"]) > 80) then
					icone = self.icones["100%"];
				elseif (tonumber(varUps["battery.charge"]) > 30) then
					icone = self.icones["50%"];
				else
					icone = self.icones["0%"];
				end
			end
		else
			self:setVariable(self.varName, "power-line");
			if ((varUps["battery.charge"] and tonumber(varUps["battery.charge"]) < 100) or varUps["ups.status"] and (string.sub(varUps["ups.status"], 1, 4) == "OL C")) then
				self:trace("UPS is on line and charging.", "lime");
				icone = self.icones["secteur"];
			else
				self:trace("UPS is on line.", "lime");
				icone = self.icones["on"];
			end
		end
		--local aVar = ask("GET VAR UPS ups.temperature");
		--self.trace("aVar=" .. aVar, "cyan");
		--self:logout();
	else
		self:trace("unable to connect to UPS server (" .. self._deviceIp .. ":" .. self._devicePort .. ")", "red");
		icone = self.icones["off"];
	end
	self:changeIcon(icone);
end

function QuickApp:myRefresh()
  local last = self.myInstance.lastrun;
  local diff = os.difftime(os.time(), last);
  if (diff >= self.myInstance.every) then
    self:connect();
    self:refreshAll();
    self.myInstance.lastrun = os.time();
    --self:debug("Check"); -- for watchdog use
  end
end

Je n'arrive pas faire en sorte d'attendre les réponses suite aux envois de messages:

[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: Connected
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: Debug: Connect, connecting to server
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: Debug: writeSocket, data=USERNAME monuser <= Commande 1
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: Debug: writeSocket, data=PASSWORD secret  <= Commande 2
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: Debug: writeSocket, data=LIST VAR UPS     <= Commande 3
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: onDataReceived: OK                        <= Réponse 1
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: onDataReceived: OK                        <= Réponse 2
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: onDataReceived: BEGIN LIST VAR UPS        <= Réponse 3 (poursuit sur les autres lignes)
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS battery.charge "100"
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS battery.charge.low "10"
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS battery.charge.warning "50"
[2021-03-14] [16:48:42] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS battery.date "2001/09/25"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS battery.mfr.date "2017/03/24"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS battery.runtime "4130"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS battery.runtime.low "120"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS battery.type "PbAc"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS battery.voltage "27.1"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS battery.voltage.nominal "24.0"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS device.mfr "American Power Conversion"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS device.model "Back-UPS RS 900G"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS device.serial "3B1712X12050 "
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS device.type "ups"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS driver.name "usbhid-ups"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS driver.parameter.pollfreq "30"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS driver.parameter.pollinterval "5"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS driver.parameter.port "auto"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS driver.version "DSM6-2-25364-191230"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS driver.version.data "APC HID 0.95"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS driver.version.internal "0.38"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS input.sensitivity "medium"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS input.transfer.high "294"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS input.transfer.low "176"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS input.transfer.reason "input voltage out of range"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS input.voltage "235.0"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS input.voltage.nominal "230"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.beeper.status "disabled"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.delay.shutdown "20"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.firmware "879.L4 .I"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.firmware.aux "L4 "
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.load "16"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.mfr "American Power Conversion"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.mfr.date "2017/03/24"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.model "Back-UPS RS 900G"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.productid "0002"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.realpower.nominal "540"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.serial "3B1712X12050 "
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.status "OL"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.test.result "No test initiated"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.timer.reboot "0"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.timer.shutdown "-1"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: VAR UPS ups.vendorid "051d"
[2021-03-14] [16:48:43] [DEBUG] [QUICKAPP96]: onDataReceived: END LIST VAR UPS

 

C'est assez frustrant alors que sous la HC2 la méthode était plus facile.

 

Saurez-vous me venir en aide ?

 

Je vous remercie par avance.

 

Désolé pour le long message.

 

 

Lien vers le commentaire
Partager sur d’autres sites

Perso je n'ai pas le temps de relire et modifier ton code, mais une piste quand même : sur HC3 les accès réseaux sont asynchrones (comme pour les scènes sur HC2 d'ailleurs).

Tu peux regarder ce tuto pour des requêtes HTTP, le principe est le même pour TCP :

 

 

 

Et en complément, en pratique  tu as mon QuickApp Onduleur Eaton sur le forum, qui utilise des requêtes TCP pour le protocole SNMP, ça pourrait te servir d'exemple :

 

 

Lien vers le commentaire
Partager sur d’autres sites

Bonjour,

 

J'ai déjà regardé ton premier lien. Mais comme je n'ai jamais fait de scènes sur la HC2, je n'utilisais pas cela.

C'est pourquoi je ne comprends pas trop comment cela fonctionne.

Je vais regarder ton exemple avec ton QuickApp en second lien. J'espère que je vais réussir à comprendre !

 

Merci.

 

Lien vers le commentaire
Partager sur d’autres sites

Bonjour Barelle,

 

En fait c'est exactement celui que je cherche à faire. Je ne l'avais pas vu dans la liste ... besoin de changer de paire de lunette surement.

Mais je vais en profiter pour voir comment tu as fait ! :)

 

Voilà ... :D

Lien vers le commentaire
Partager sur d’autres sites

×
×
  • Créer...