Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Looking for help to convert HC2 VD into HC3 QA


FonsBrand

Recommended Posts

Good afternoon,

I would like to convert an HC2 VD to an HC3 QA but am running into some communication problems with regard to net.http

 

The code is not complete yet, but now I get an error in the http request.

 

-- Mijn Code
function QuickApp:onInit()
    self:debug("onInit")
    ipaddr = self:getVariable("IPAddress")
    tcpport = self:getVariable("TCPPort")

    Var1 = hub.getGlobalVariable("Deur_Voordeur")
    if Var1 == "Open" then
        self:updateView("Label_1", "text", "Voordeur is Open")
        else
        self:updateView("Label_1", "text", "Voordeur is Dicht")
    end    

    Var2 = hub.getGlobalVariable("Deur_Garage")
    if Var2 == "Open" then
        self:updateView("Label_2", "text", "Gagragedeur is Open")
        else
        self:updateView("Label_2", "text", "Gagragedeur is Dicht")
    end   

    Var3 = hub.getGlobalVariable("Deur_Keuken")
    if Var3 == "Open" then
        self:updateView("Label_3", "text", "Keukendeur is Open")
        else
        self:updateView("Label_3", "text", "Keukendeur is Dicht")
    end  
 
    Var4 = hub.getGlobalVariable("Deur_Bijkeuken")
    if Var4 == "Open" then
        self:updateView("Label_4", "text", "Bijkeukendeur is Open")
        else
        self:updateView("Label_4", "text", "Bijkeukendeur is Dicht")
    end 

    Var5 = hub.getGlobalVariable("Raam_HfdSlpKmr")
    if Var5 == "Open" then
        self:updateView("Label_5", "text", "HfdSlpKmr is Open")
        else
        self:updateView("Label_5", "text", "HfdSlpKmr is Dicht")
    end 

    Var6 = hub.getGlobalVariable("Raam_KlnSlpKmr")
    if Var6 == "Open" then
        self:updateView("Label_6", "text", "KlnSlpKmr is Open")
        else
        self:updateView("Label_6", "text", "KlnSlpKmr is Dicht")
    end 

    Var7 = hub.getGlobalVariable("Deur_GrtSlpKmr")
    if Var7 == "Open" then
        self:updateView("Label_7", "text", "GrtSlpKmr is Open")
        else
       self:updateView("Label_7", "text", "GrtSlpKmr is Dicht")
    end 

    Var8 = hub.getGlobalVariable("Raam_CompKmr")
    if Var8 == "Open" then
        self:updateView("Label_8", "text", "CompKmr is Open")
        else
        self:updateView("Label_8", "text", "CompKmr is Dicht")
    end
 
end
--===========================================================================
-- Code for 1 relais --
function QuickApp:btnUpdate()
  
    HTTP = net.Fhttp(self.ipaddr, self.tcpport)
    HTTP:setBasicAuthentication("Uname", "Passwd") 

    function getXML(data,name)  
    return data:match("<"..name..">(.-)</"..name..">")
    end

    response, status, result = HTTP:GET("/status.xml")
 
    fibaro:debug("Result = "..result)
    fibaro:debug("Status = "..status)
    fibaro:debug("response = "..response)

    if ((result == 0) and (status == "200")) then  

         local zone1 = getXML(response, "relay1")
         fibaro:debug  ("relay1 waarde = "..zone1)  
            if (zone1 == "1") then    
               -- relay1 = ("Open")  
               self:updateView("Label_1", "text", "Voordeur is Open")
            elseif (zone1 == "0") then    
                --relay1 = ("Closed")     
                self:updateView("Label_1", "text", "Voordeur is Dicht")
            end

     end

-- end
--==========================================================================


-- function QuickApp:btn1On()
 self:updateView("Label_1", "text", "Voordeur is Open")
 -- hub.setGlobalVariable("Deur_Voordeur", "Open")
end

function QuickApp:btn2On()
 self:updateView("Label_2", "text", "Gagragedeur is open")
end

function QuickApp:btn3On()
 self:updateView("Label_3", "text", "Keukendeur is Open")
end

function QuickApp:btn4On()
self:updateView("Label_4", "text", "Bijkeuken is Open")
end

function QuickApp:btn5On()
self:updateView("Label_5", "text", "HfdSlpKmr is Open")
end

function QuickApp:btn6On()
self:updateView("Label_6", "text", "KlnSlpKmr is Open")
end

function QuickApp:btn7On()
self:updateView("Label_7", "text", "GrtSlpKmr is Open")
end

function QuickApp:btn8On()
 self:updateView("Label_8", "text", "CompKmr is Open")  
end

function QuickApp:btn1Off()
 self:updateView("Label_1", "text", "Voordeur is Dicht")
 hub.setGlobalVariable("Deur_Voordeur", "Dicht")
end

function QuickApp:btn2Off()
  self:updateView("Label_2", "text", "Gagragedeur is Dicht")
end

function QuickApp:btn3Off()
 self:updateView("Label_3", "text", "Keukendeur is Dicht")
end

function QuickApp:btn4Off()
 self:updateView("Label_4", "text", "Bijkeuken is Dicht")
end

function QuickApp:btn5Off()
 self:updateView("Label_5", "text", "HfdSlpKmr is Dicht")
end

function QuickApp:btn6Off()
 self:updateView("Label_6", "text", "KlnSlpKmr is Dicht")
end

function QuickApp:btn7Off()
 self:updateView("Label_7", "text", "GrtSlpKmr is Dicht")
end

function QuickApp:btn8Off()
 self:updateView("Label_8", "text", "CompKmr is Dicht")
end 
 

 

Please login or register to see this image.

/monthly_2022_11/image.png.1d4e2ae76a6a28e0a0bb7926b37cf0bd.png" />image.png.5719c4f20517ad3293e4167b7d13e3ab.png

image.png.7f8b2d4b8b222b4aa576b3c7091b1492.png

 

 

orginele file zie onderstaande link

 

Please login or register to see this attachment.

Edited by FonsBrand
Link to comment
Share on other sites

  • FonsBrand changed the title to Looking for help to convert HC2 VD into HC3 QA

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...