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


  • 0

Question

Posted

Cześć, 

może ktoś zobaczyć co jest nie tak w tym kodzie że nie mogę zmieniać kolorów  i dodać efektów?

l

-- Color controller type should handle actions: turnOn, turnOff, setValue, setColor

-- To update color controller state, update property color with a string in the following format: "r,g,b,w" eg. "200,10,100,255"

-- To update brightness, update property "value" with integer 0-99

function QuickApp:turnOn()

    self:debug("color controller turned on")

    local http = net.HTTPClient()

http:request("http://192.168.0.253/win&T=1")

end

 

function QuickApp:turnOff()

    self:debug("color controller turned off"

        local http = net.HTTPClient()

http:request("http://192.168.0.253/win&T=0")

end

--

-- Value is type of integer (0-99)

 

function QuickApp:setValue(value)

    self:debug("color controller value set to: ", value)

    self:debug("TEST", value * 2.55)

    

    local dim = string.format("http://192.168.0.253/win&A="..value * 2.55)

    local http = net.HTTPClient()

     http:request(dim)

        self:debug(dim)

    self:updateProperty("value", value)  

end

 

function QuickApp:setColor(r,g,b,w)

  local http = net.HTTPClient()

    local color = string.format("%d,%d,%d,%d", r or 0, g or 0, b or 0, w or 0

    local kolor = string.format("http://192.168.0.253/win&R="..r.."&G="..g.."&B="..b)

    self:debug(kolor)

    http:request(kolor)

   -- self:debug("color controller color set to: ", color)

    

 

    self:updateProperty("color", color)    

end

 

function QuickApp:ONr(event)

    local http = net.HTTPClient()

http:request("http://192.168.0.253/win&A=253")

end

function QuickApp:REDr(event)

    local http = net.HTTPClient()

http:request("http://192.168.0.253/win&&R=255&G=0&B=0")

end

function QuickApp:GREENr(event)

    local http = net.HTTPClient()

http:request("http://192.168.0.253/win&&R=0&G=255&B=0")

end

function QuickApp:BLUEr(event)

    local http = net.HTTPClient()

http:request("http://192.168.0.253/win&&R=0&G=0&B=255")

end

function QuickApp:OFFr(event)

    local http = net.HTTPClient()

http:request("http://192.168.0.253/win&A=0")

end

function QuickApp:testr(event)

    local http = net.HTTPClient()

http:request("http://192.168.0.253/win&FX=55")

end

 

function QuickApp:staticr(event)

    local http = net.HTTPClient()

http:request("http://192.168.0.253/win&FX=0")

end

function QuickApp:button5_1()

self.http = net.HTTPClient:request("http://192.168.0.253/win&A=253")

end

function QuickApp:button5_2()

self.http = net.HTTPClient({timeout=3000})

end

 

-- Color is type of table, with format [r,g,b,w]

-- Eg. relaxing forest green, would look like this: [34,139,34,150]

 

-- To update controls you can use method self:updateView(<component ID>, <component property>, <desired value>). Eg:  

-- self:updateView("slider", "value", "55") 

-- self:updateView("button1", "text", "MUTE") 

-- self:updateView("label", "text", "TURNED ON") 

 

-- This is QuickApp inital method. It is called right after your QuickApp starts (after each save or on gateway startup). 

-- Here you can set some default values, setup http connection or get QuickApp variables.

-- To learn more, please visit: 

--    * https://manuals.fibaro.com/home-center-3/

--    * https://manuals.fibaro.com/home-center-3-quick-apps/

 

function QuickApp:onInit()

    self:debug("onInit")

        self:debug("onInit")

    self.sock = net.TCPSocket()

    self.http = net.HTTPClient({timeout=3000})

end

 

 

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

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

Guest
Answer this question...

×   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...