Aller au contenu

Franco268

Membres confirmés
  • Compteur de contenus

    186
  • Inscription

  • Dernière visite

Réputation sur la communauté

7 Neutral

À propos de Franco268

Profile Information

  • Sexe :
    Homme
  • Ville :
    Grand Est
  • Intéret :
    Automatisme, électronique, domotique
  • Box
    Home Center 2
    Autre
  • Version
    4.560

Visiteurs récents du profil

1 768 visualisations du profil
  1. Franco268

    fichier csv ou tab delimited

    Bonsoir Messieurs, Ce sujet m'intéresse..., J'ai un QA qui fait de l'acquisition météo, et de fil en aiguille, je me dis que cela pourrait être utile d'historiser mes acquisitions (dans le but d'une relecture manuelle par la suite). Pour ce faire, j'ai vu que l'on peut joindre des fichiers aux QA. Mais est il possible d'en créer? Editer?
  2. Franco268

    Positionnement Du Soleil

    Bonjour tout le monde, J'avais également bricolé une fonction par le passé sur ce sujet et depuis j'essai de tout migrer vers HC3. Quelqu'un a t il migré cette fonction?
  3. Franco268

    net.TCPSocket

    Merci, pour le lien. L'imbrication est acquis... mon petit bout de code tourne. Prochaine étape le "join" pour du multi requête
  4. Franco268

    net.TCPSocket

    J'ai tenté d'enchainé toutes mes étapes. Mais je ne comprends pas du tout le résultat. Les 2 premières commandes sont envoyés. Mais pas la troisième. Le truc de fou, c'est qu'en réponse, j'ai dans UN SEUL retour la réponse de la seconde requête ET de la TROISIEME! Celle qui n'a pas été envoyé! J'ai essayé de mettre mon code au plus simple mais je ne comprends pas l'erreur. -- Quick App template for handling the TCP device debug = true selfIp = "192.168.100.2"; -- the IP of this virtual device selfPort = 3493; -- the dedicated port for this virtual device tcpCommandVarGet = "GET VAR"; -- TCP command to get variable tcpCommandUpsName = "UPS"; -- Name of UPS enter = string.char(0x0d, 0x0a); function QuickApp:BtnMaj_onReleased(event) self:debug("BtnMaj_onReleased(event)") self:Send(tcpCommandVarGet.." "..tcpCommandUpsName.." " .."ups.status"..enter) self:Send(tcpCommandVarGet.." "..tcpCommandUpsName.." " .."battery.charge"..enter) self:Send(tcpCommandVarGet.." "..tcpCommandUpsName.." " .."battery.runtime"..enter) end function QuickApp:Send(request) self.sock = net.TCPSocket() -- creation of a TCPSocket instance self.sock:connect(self.ip, self.port, { -- connection to the device with the specified IP and port success = function() -- the function will be triggered if the connection is correct self:debug("connected") self.sock:write(request, { success = function() -- the function that will be triggered when the data is correctly sent self:debug("data sent: " ..request) self.sock:read({ -- reading a data package from the socket success = function(data) data = tostring(data) self:debug("onDataReceived", data) self.sock:close() -- socket closed end, error = function() -- a function that will be called in case of an error when trying to receive data, e.g. disconnecting a socket self:debug("response error") self.sock:close() -- socket closed end }) end, error = function(err) -- the function that will be triggered in the event of an error in data transmission self:debug("error while sending data") end }) end, error = function(err) -- a function that will be triggered in case of an incorrect connection, e.g. timeout self.sock:close() -- closing the socket self:debug("connection error") end, }) end function QuickApp:onInit() self:debug("onInit") self.ip = self:getVariable("ip") self.port = tonumber(self:getVariable("port")) end Résultat: [03.02.2023] [15:15:02] [DEBUG] [QUICKAPP70]: onInit [03.02.2023] [15:15:05] [TRACE] [QUICKAPP70]: UIEvent: {"elementName":"BtnMaj","deviceId":70,"eventType":"onReleased","values":[null]} [03.02.2023] [15:15:05] [DEBUG] [QUICKAPP70]: BtnMaj_onReleased(event) [03.02.2023] [15:15:05] [DEBUG] [QUICKAPP70]: connected [03.02.2023] [15:15:05] [DEBUG] [QUICKAPP70]: connected [03.02.2023] [15:15:05] [DEBUG] [QUICKAPP70]: connected [03.02.2023] [15:15:05] [DEBUG] [QUICKAPP70]: data sent: GET VAR UPS ups.status [03.02.2023] [15:15:05] [DEBUG] [QUICKAPP70]: data sent: GET VAR UPS battery.charge [03.02.2023] [15:15:05] [DEBUG] [QUICKAPP70]: onDataReceived VAR UPS battery.runtime "3000" battery.charge "100" [03.02.2023] [15:15:05] [DEBUG] [QUICKAPP70]: error while sending data [03.02.2023] [15:15:05] [DEBUG] [QUICKAPP70]: onDataReceived
  5. Franco268

    net.TCPSocket

    Hello, Je cherche un peu d'aide pour reprendre un code HC2 et le mettre sur ma HC3. Je souhaite faire 3 requetes pour obtenir le statut de mon UPS. Le probleme est que je n'arrive pas à découper les réponses... La réponse de mes 2 premières demandes se retrouve dans la première réponse et la dernière demande, dans la seconde réponse. J'ai fais des tentatives de sleep, d'imbriquer les "read" dans les "Write", mais rien n'y fait Pouvez vous m'aider? J'ai beaucoup lu sur le forum et utiliser l'exemple Fibaro HC3. Mai je ne comprend pas comment synchroniser les réponses avec les demandes -- Quick App template for handling the TCP device debug = true selfIp = "192.168.100.2"; -- the IP of this virtual device selfPort = 3493; -- the dedicated port for this virtual device tcpCommandVarGet = "GET VAR"; -- TCP command to get variable tcpCommandUpsName = "UPS"; -- Name of UPS timeOut = 5; -- Time-out attempts for setting up a connection timeOutTime = 1; -- Time-out time for setting up a connection, in seconds scrollDelaySec = 2; -- Raport scrolldelay in seconds instanceValueWrite = 1; -- Instancevalue to write (must be an unique number per button in VD) instanceValueComError = 8; -- Instancevalue when communication error is reported instanceValueDecError = 9; -- Instancevalue when decoding received data error is reported instanceValue = 0; isOnline = 0; enter = string.char(0x0d, 0x0a); receivedTable = {}; function QuickApp:BtnMaj_onReleased(event) if debug then self:debug("BtnMaj_onReleased(event)") end --self:send("Some command for on\n") -- sending data to the device. In a normal implementation it will be a code with an appropriate command. self:send(tcpCommandVarGet.." "..tcpCommandUpsName.." " .."ups.status"..enter) self:send(tcpCommandVarGet.." "..tcpCommandUpsName.." " .."battery.charge"..enter) self:send(tcpCommandVarGet.." "..tcpCommandUpsName.." " .."battery.runtime"..enter) end -- the method for sending data to the device -- the method can be called from anywhere function QuickApp:send(strToSend) self.sock:write(strToSend, { success = function() -- the function that will be triggered when the data is correctly sent self:debug("data sent: " ..strToSend) end, error = function(err) -- the function that will be triggered in the event of an error in data transmission self:debug("error while sending data") end }) 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.sock:read({ -- 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 self:debug("response error") self.sock: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.sock:connect(self.ip, self.port, { -- connection to the device with the specified IP and port success = function() -- the function will be triggered if the connection is correct self:debug("connected") self:send("VER"..enter) self:waitForResponseFunction() -- launching a data readout "loop" end, error = function(err) -- a function that will be triggered in case of an incorrect connection, e.g. timeout self.sock:close() -- closing the socket self:debug("connection error") fibaro.setTimeout(5000, function() self:connect() end) -- re-connection attempt (every 5s) end, }) end -- function handling the read data -- normally this is where the data reported by the device will be handled function QuickApp:onDataReceived(data) data = tostring(data) self:debug("onDataReceived", data) if data ~= "" then table.insert(receivedTable, data); if debug then self:debug("Table filled, row number: "..#receivedTable) end; if #receivedTable ~= 0 then --and isOnline == 1 and instanceValue == instanceValueWrite if receivedTable[#receivedTable] ~= nil then textValueStart = tostring(string.find(receivedTable[#receivedTable], '"')); self:debug("textValueStart: ", textValueStart) if textValueStart ~= "nil" then textValueEnd = tostring(string.find(receivedTable[#receivedTable], '"', textValueStart+1)); self:debug("textValueEnd: ", textValueEnd) if textValueEnd ~= "nil" then textValue = string.sub(receivedTable[#receivedTable], textValueStart+1, textValueEnd-1); self:debug("textValue: ", textValue) if string.find(receivedTable[#receivedTable], "ups.status") ~= nil then self:updateView("LblStatus", "text", "Statut: " ..textValue) end if string.find(receivedTable[#receivedTable], "battery.charge") ~= nil then self:updateView("LblBatLevel", "text", "Battery Level: " ..textValue .."%") end if string.find(receivedTable[#receivedTable], "battery.runtime") ~= nil then self:updateView("LblBatTime", "text", "Battery Time: " ..textValue .." sec") end self:updateView("upsReportLabel", "text", "Value "..textValue.." written."); hub.sleep(scrollDelaySec*1000); else instanceValue = instanceValueDecError if debug then hub.debug("Test Tag", "Error decoding value: missing second quotesign...") end; end else instanceValue = instanceValueDecError if debug then hub.debug("Test Tag", "Error decoding value: missing first quotesign...") end; end else instanceValue = instanceValueDecError if debug then hub.debug("Test Tag", "Error decoding value: not really found something...") end; end else instanceValue = instanceValueDecError if debug then hub.debug("Test Tag", "Error decoding value: no text to decode...") end; end if instanceValue == instanceValueDecError then self:updateView("upsReportLabel", "text", "Decoding error: value not written to GV"); hub.sleep(scrollDelaySec*1000); end else self:updateView("LblStatus", "text", "Statut: No response!"); self:updateView("LblBatLevel", "text", "Battery Level: No response!"); self:updateView("LblBatTime", "text", "Battery Time: No response!"); instanceValue = instanceValueComError if debug then self:debug("Error: No data received!") end; --hub.sleep(scrollDelaySec*1000); end end function QuickApp:onInit() self:debug("onInit") self.ip = self:getVariable("ip") self.port = tonumber(self:getVariable("port")) self.sock = net.TCPSocket() -- creation of a TCPSocket instance self:connect() end
  6. Franco268

    Fonction call

    Je creuse toujours dans la même direction... Est il au moins possible de savoir quel capteur est dans une zone? (en lua)
  7. Franco268

    Fonction call

    Ok, c'est ce que j'avais cru comprendre.... Du coup, l'inverse: fibaro:getValue(639, "armed") n'est plus possible non plus? J'ai vu le paramètre "tamper", sais tu me dire ce que c'est ? Je demande ceci car j'ai constaté que quand le contact est ouvert et que l'on "force" l'activation de la zone, le contact ouvert ne s'arme pas
  8. Franco268

    Fonction call

    Super! Un grand merci, j'ai enfin accès à la bible... Mais... je n'ai pas trouvé l'équivalent de: fibaro:call(IdFenetreCuisine, "setArmed", "1")
  9. Franco268

    Fonction call

    Hello, Je suis à ma 3eme tentatives de migrer tous mes codes HC2 vers HC3. Et je bloque c'est des choses nuls pour lesquelles je ne trouve pas de réponse. Je bloque là dessus: Comment savoir si un capteur d'ouverture est armé? Comment armer un carpteur? Plus généralement comment connaitre tous les arguments hub.call d'un device? Pouvez vous m'aider?
  10. Franco268

    Bon anniversaire Maître fondateur

    Très bon anniversaire ! Je partage l’avis de Jojo! C’est le seul forum dans mes favoris
  11. Franco268

    Déclencheur Event QA HC3

    @jang thank you, I will study you post. First reading wasn’t enough to understand lol
  12. Franco268

    Déclencheur Event QA HC3

    Oui je confirme, le besoin est celui exprimé par Jojo. On est d'accord, ce que propose Cardane est de déclenché une fonction QA à partir d'une scène. C'est ça?
  13. Franco268

    Déclencheur Event QA HC3

    @Cardane comme @jojo je suis intéressé. C'est exactement ce que je voudrais faire.
  14. Franco268

    Déclencheur Event QA HC3

    Non je n'utilise pas GEA? Si tu proposes une alternative... cela veut dire qu'il n'existe pas de déclencheur/event basé sur des appareils dans les QA?
  15. Franco268

    tonumber et variable globale

    ok thank you
×