Aller au contenu

G.RozNCo

Membres confirmés
  • Compteur de contenus

    25
  • Inscription

  • Dernière visite

  • Jours gagnés

    1

G.RozNCo a gagné pour la dernière fois le 21 mai 2021

G.RozNCo a eu le contenu le plus aimé !

À propos de G.RozNCo

  • Date de naissance 20/10/1980

Profile Information

  • Sexe :
    Homme
  • Ville :
    Tenteling
  • Intéret :
    Dans le désorde:
    Bricolage
    Cuisine
    Informatique
    Peche
    Equitation
    Chimie
    Jardinage
    Electronique
    Usinage
    Airsoft
  • Box
    Home Center 2
    Home Center 3
    Jeedom
  • Version
    4

Visiteurs récents du profil

1 008 visualisations du profil

G.RozNCo's Achievements

Newbie

Newbie (1/14)

  • Conversation Starter Rare
  • Week One Done Rare
  • One Month Later Rare
  • One Year In Rare

Recent Badges

2

Réputation sur la communauté

  1. Bonjour à tous, J'essais de faire une QA minuteur modulable, et je coince aux modification pendant un cycle. Le but etant d'activer un module pendant une durée définie (entre 5 et 30min) toutes les 5-60minutes, avec la possibilité de modifer le cycle et la durée mais également de forcer l'allumage ou l'extinction. La QA se lance proprement , mais reste bloqué dans la routine "cycle", et je n'arrives ni a la modifier ni a la forcée (ON ou OFF). Je me doutes que mes timers sont les probèmes ... La fonction "SetTimeout" est peut etre plus adaptée, mais du coup la pause entre les commande n'es pas prise en compte. Avez vous des idées? Merci d'avance. function QuickApp:B_ON(event) self:updateView("Label_Info", "text", "ON... "..os.date('%H:%M')) self:setVariable("Mode","ON") self:onInit() end function QuickApp:B_Off(event) self:updateView("Label_Info", "text", "OFF... "..os.date('%H:%M')) self:setVariable("Mode","OFF") self:onInit() end function QuickApp:B_Cycle() self:debug("Cycle: " , self:getVariable("Cycle"), " on/off | " , self:getVariable("Duree"), "min") self:updateView("Label_Info", "text", os.date('%H:%M').." Cycle: ON/OFF "..self:getVariable("Cycle").."% | "..self:getVariable("Duree").. "min") self:setVariable("Mode","AUTO") self:onInit() end function QuickApp:onInit() self:debug("Init",self:getVariable("Mode")) if self:getVariable("Mode") == "ON" then hub.call(tonumber(self:getVariable("Modul_id")),"turnOn") elseif self:getVariable("Mode") == "OFF" then hub.call(tonumber(self:getVariable("Modul_id")),"turnOff") elseif self:getVariable("Mode") =="AUTO" then local Ratio_ON= ( self:getVariable("Cycle") * self:getVariable("Duree")/100 ) local Ratio_OFF= ( self:getVariable("Duree") ) - Ratio_ON Timer=Ratio_ON *60 hub.call(tonumber(self:getVariable("Modul_id")),"turnOn") while Timer > 0 and self:getVariable("Mode") =="AUTO" do hub.sleep(1000) Timer=Timer-1 end Timer=Ratio_OFF *60 hub.call(tonumber(self:getVariable("Modul_id")),"turnOff") while Timer > 0 and self:getVariable("Mode") =="AUTO" do hub.sleep(1000) Timer=Timer-1 end self:onInit() else self:setVariable("Mode","OFF") end end
  2. G.RozNCo

    Quick Apps

    TOP! Merci pour ton aides!
  3. G.RozNCo

    Quick Apps

    Bonjour, Est ce que quelqu'un aurait une explication concernant le déroulé des fonctions, ou plutot leur timming? Dans ce code lorsque je lance la fonction "Bouton_Read()" je m'attends a avoir [data sent] puis ma reponse "MB_Reponse = self:read()" et enfin [send DONE X] et [read DONE X]. Mais j'obtiens un déroulé complètement different et pas de return exploitable. Seule la fonction "onDataReceived(data)" recoit une réponse. Une idée ou mon erreur se situe? [28.05.2024] [09:18:28] [DEBUG] [QUICKAPP135]: send DONE X [28.05.2024] [09:18:28] [DEBUG] [QUICKAPP135]: read DONE X [28.05.2024] [09:18:28] [DEBUG] [QUICKAPP135]: Data: / MB_Reponse: / GetVar MB_Reponse: 0701040441973333[28.05.2024] [09:18:28] [DEBUG] [QUICKAPP135]: data sent -- Variables local data local MB_Reponse local MB_Float32, MB_Signe, MB_Exposant, MB_Mantisse -- function QuickApp:Float32toReal(MB_Float32) -- Conversion Float32 en Real MB_Signe = math.pow(-1, math.fmod( MB_Float32, 2 )) MB_Exposant = math.pow( 2, math.modf( MB_Float32 / 8388608 ) - 127 ) MB_Mantisse = 8388608 + math.fmod( MB_Float32, 8388608 ) return (( MB_Signe * MB_Mantisse * MB_Exposant ) / 8388608) end --function Float32toReal function QuickApp:Bouton_Read() self:send(string.char(0x01,0x00,0x00,0x00,0x00,0x06,0x01,0x04,0x00,0x48,0x00,0x02)) MB_Reponse = self:read() QuickApp:debug("Data: ", data, "/ MB_Reponse: ",MB_Reponse, "/ GetVar MB_Reponse: ", self:getVariable("MB_Reponse")) end function QuickApp:onDataReceived(data) self:setVariable("MB_Reponse",data) end function QuickApp:onInit() local ModBus self:trace("onInit") self.ip = self:getVariable("MultiCell_IP") self.port = tonumber(self:getVariable("MultiCell_Port")) self.ModBus = net.TCPSocket() -- creation of a TCPSocket instance self:connect() end function QuickApp:connect() -- a method to open a TCP connection. self.ModBus: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:trace("Connected ") -- if the connection is successful, the data readout loop will be called --self:read() -- launching a data readout end, error = function(err) -- a function that will be triggered in case of an incorrect connection, e.g. timeout self:disconnect() --self.sock:close() -- closing the socket self:debug("connection error",err) fibaro.setTimeout(5000, function() self:connect() end) -- re-connection attempt (every 5s) end, }) end function QuickApp:disconnect() -- a method to close the TCP connection. self.ModBus:close() -- closing the socket self:trace("disconnected") end function QuickApp:send(strToSend) -- sending command self.ModBus:write(strToSend, { success = function() -- the function that will be triggered when the data is correctly sent self:debug("data sent") 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 }) self:debug("send DONE X") end function QuickApp:read() self.ModBus:read({ -- reading a data package from the socket success = function(data) --self:setVariable("MB_Reponse",data) self:onDataReceived(data) -- handling of received data --self:debug("read DONE") return data 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:error("response error" , error) self:disconnect() --self.sock:close() -- socket closed fibaro.setTimeout(5000, function() self:connect() end) -- re-connection attempt (every 5s) end }) self:debug("read DONE X") end function QuickApp:HexDumpString(str,spacer) return ( string.gsub(str,"(.)", function (c) return string.format("%02X%s",string.byte(c), spacer or ""); --convertion décimal en hexa end)) end
  4. G.RozNCo

    Quick Apps

    Merci pour la réponse. Je vais regarder cela en détail ce soir, parce que là je suis perdu. Mais c'est sûrement dû à une étroitesse d'esprit.
  5. G.RozNCo

    Quick Apps

    Il y a clairement de nombreux sujet concernant les variables local et global. Je penses avoir mal compris le "NON Local"... Les variables sont local ou global, c'est cela?
  6. G.RozNCo

    Quick Apps

    Merci pour ta reponse... peut tu me dire comment déclarer une variable non locale?
  7. G.RozNCo

    Quick Apps

    Bonjour à tous... Je suis passé il y a peu d'une HC2 à une HC3, et je rames avec les QA... Est ce qu'une âme charitable pourrais m'éclairer 1 points: Comment utiliser une variable (son contenu évidement) d'une fonction à l'autre au sein d'une QA?
  8. Bonjour, Est ce que qq1 a lié un Rika avec une HC3?
  9. G.RozNCo

    Images Clé Usb

    Bonjour, Ma HC2 viens de s'éteindre... le disque système est introuvable... :(( pourriez vous a nouveau partager l'image de la clé recovery de la HC2 ou l'image de la clé interne? Milles merci!
  10. G.RozNCo

    Caméra TAPO C100

    La tapo m'intrigue... Est elle fonctionnelle avec un HC2
  11. G.RozNCo

    HC2 LUA

    Et voici ... MB_Float32 = tonumber("4199999A",16) MB_Signe = math.fmod(MB_Float32, 2) MB_Exposant = math.modf(MB_Float32 / 8388608) - 127 MB_Mantisse = ( 8388608 + math.fmod(MB_Float32,8388608) ) MB_int = math.pow(-1,MB_Signe) * (MB_Mantisse * math.pow(2,MB_Exposant) ) / 8388608 fibaro:debug(MB_Signe .. " " .. MB_Exposant .. " " .. MB_Mantisse)
  12. G.RozNCo

    HC2 LUA

    Le problème c'est que la conversion se fait en Binaire, en Decimale je pêche...
  13. G.RozNCo

    HC2 LUA

    Snif... Comment puis-je convertir une valeur Real Float32 (Format IEEE754) en INT décimal?
  14. G.RozNCo

    HC2 LUA

    Bonjour, Est il possible de faire évoluer la HC2 en lui installant une version plus actuelle de LUA, prenant en charge les Fonction bit32?
  15. Merci pour toutes vos contributions. La lecture et l'écriture de variables fonctionne...
×
×
  • Créer...