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


Recommended Posts

Posted

Hi, I'm new in using Fibaro. especially in LUA. Is there a dummy guide for a beginner like me to learn about LUA coding? Thanks in advance.

Posted
Hi, I'm new in using Fibaro. especially in LUA. Is there a dummy guide for a beginner like me to learn about LUA coding? Thanks in advance.

Hi

Have a look to the following links :

Please login or register to see this link.

Please login or register to see this link.

Regards

Posted

I'am also looking for an overview of the fibaro calls in Lua. (like fibaro:debug etc). Is there an overview of those functions?

thanks

  • Topic Author
  • Posted

    Thanks for the link! I've started working on a virtual thermostat controller for my Split Type AC. Am on my way to finishing it today..

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    Posted
    Thanks for the link! I've started working on a virtual thermostat controller for my Split Type AC. Am on my way to finishing it today..

    Please login or register to see this image.

    /emoticons/default_icon_mrgreen.gif" alt=":mrgreen:" />

    Would like to know, if it works perfectly. Please share the lua code

  • Topic Author
  • Posted

    Sorry, I'm unable to upload the attachments on how I made the controller now.

    Yep, It's working already. I will upload all the data I made as soon as the maintenance is finished.

    [ Added: 2013-11-10, 18:03 ]

    I didn't use coding for the entire function. I could if I wanted to but I haven't learned some of the codes and the their syntax yet. Also, I wanted to make things simple first so my partner can also understand the process I've done.

    The equipment I'm using is Fibaro HC2 and Global Caché wf2ir

    Basically, what I did first was put all my IR codes in one virtual device "GREE" as seen in "IR codes.jpg".

    from there, I used another Virtual device to call upon each button whenever I change the status of the Thermostat. So, instead of using an array as the source list of my IR codes, i did that.

    This is the code for Power Button.

    ----------------------------------------------------------------------------------------------------

    --[[

    %% autostart

    %% Properties

    %% Globals

    xPower

    xNumber

    xSpeed

    --]]

    local xPow = fibaro:getGlobalValue("xPower")

    if xPow == '1' then

    fibaro:call(16, "pressButton", 1)

    xPow = 0

    fibaro:call(17, "setProperty", "ui.Label1.value", "OFF")

    else

    local xNos = fibaro:getGlobalValue("xNumber")

    local xSpd = fibaro:getGlobalValue("xSpeed")

    local xValue = xNos + xSpd

    fibaro:call(16, "pressButton", xValue)

    xPow = 1

    local xVal2 = ""

    if xSpd == '0' then

    xVal2 = "Fan:Low"

    end

    if xSpd == '1' then

    xVal2 = "Fan:Med"

    end

    if xSpd == '2' then

    xVal2 = "Fan:High"

    end

    if xSpd == '3' then

    xVal2 = "Fan:Auto"

    end

    local xVal1 = 0

    if xNos == '2' then

    xVal1 = 16

    end

    if xNos == '6' then

    xVal1 = 17

    end

    if xNos == '10' then

    xVal1 = 18

    end

    if xNos == '14' then

    xVal1 = 19

    end

    if xNos == '18' then

    xVal1 = 20

    end

    if xNos == '22' then

    xVal1 = 21

    end

    if xNos == '26' then

    xVal1 = 22

    end

    if xNos == '30' then

    xVal1 = 23

    end

    if xNos == '34' then

    xVal1 = 24

    end

    if xNos == '38' then

    xVal1 = 25

    end

    if xNos == '42' then

    xVal1 = 26

    end

    if xNos == '46' then

    xVal1 = 27

    end

    if xNos == '50' then

    xVal1 = 28

    end

    fibaro:call(17, "setProperty", "ui.Label1.value", xVal1.."° C - "..xVal2)

    end

    fibaro:setGlobal("xPower",xPow)

    ----------------------------------------------------------------------------------------------------

    Note: the (0, 1, 2, 3) references are for the fan speed

    0 = low

    1 = medium

    2 = high

    3 = auto

    and the (2, 6, ....., 46, 50) is the temperature settings from 16° to 28° C..

    (Please See 'Data Table.jpg')

    the numbers are the button numbers for the IR Code device. It what I call to send the IR through the transmitter.

    I know I could have used a simpler code in the comparison by using the FOR statement or other looping statement, but I haven't learned it yet.

    Also, I'm using 3 global variables, try to see attachement.

    Decrease Temperature (-)

    ------------------------------------------------------------------------------------------------------

    --[[

    %% autostart

    %% Properties

    %% Globals

    xNumber

    xSpeed

    --]]

    local xNos = fibaro:getGlobalValue("xNumber")

    local xSpd = fibaro:getGlobalValue("xSpeed")

    xNos = xNos - 4 <------------------For Increase Temp, Just change to (+)

    if xNos < 2 then and condition to (> 50) ... xNos = 50

    xNos = 2

    end

    local xValue = xNos + xSpd

    fibaro:call(16, "pressButton", xValue)

    fibaro:setGlobal("xNumber",xNos)

    local xVal2 = ""

    if xSpd == '0' then

    xVal2 = "Fan:Low"

    end

    if xSpd == '1' then

    xVal2 = "Fan:Med"

    end

    if xSpd == '2' then

    xVal2 = "Fan:High"

    end

    if xSpd == '3' then

    xVal2 = "Fan:Auto"

    end

    local xVal1 = 0

    if xNos == 2 then

    xVal1 = 16

    end

    if xNos == 6 then

    xVal1 = 17

    end

    .

    .

    .

    if xNos == 46 then

    xVal1 = 27

    end

    if xNos == 50 then

    xVal1 = 28

    end

    fibaro:call(17, "setProperty", "ui.Label1.value", xVal1.."° C - "..xVal2)

    ------------------------------------------------------------------------------------------------------

    and Finally, Code for the Fan speed

    Settings for Low Fan Speed:

    ------------------------------------------------------------------------------------------------------

    --[[

    %% autostart

    %% Properties

    %% Globals

    xSpeed

    xNumber

    --]]

    local xSpd = 0

    local xNos = fibaro:getGlobalValue("xNumber")

    local xValue = xNos + xSpd

    fibaro:setGlobal("xSpeed",xSpd)

    fibaro:call(16, "pressButton", xValue)

    local xVal2 = "Fan:Low" <--------Just change text to med, high, or auto

    local xVal1 = 0 0=low, 1=med, 2=high, 3=auto

    if xNos == '2' then

    xVal1 = 16

    end

    if xNos == '6' then

    xVal1 = 17

    end

    .

    .

    .

    if xNos == '46' then

    xVal1 = 27

    end

    if xNos == '50' then

    xVal1 = 28

    end

    fibaro:call(17, "setProperty", "ui.Label1.value", xVal1.."° C - "..xVal2)

    ------------------------------------------------------------------------------------------------------

    Whew!. I hope that can help..

    Please login or register to see this link.

    Please login or register to see this link.

    Please login or register to see this link.

    Please login or register to see this link.

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