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

How to control a Fibaro relay module within a VD?


Question

Guest samuelboerhoop
Posted

My ceiling fan works on IR, because of that I used a itach IP2IR module with an IP address and TCP - Port

I added a couple of buttons and programmed them, all working fine.

 

I bought a Fibaro relay module, to switch on / off the complete ceiling fan and instead of using the interface from the module, I would like to use the top button of the Ceiling Fan remote called "Ceiling Fan on / off"  (see Photo-1)

 

What Lua code do I use to switch on / off the fibaro relay module (see Photo-2) within the interface from the Virtual Devcie ?

 

 

Please login or register to see this attachment.

Please login or register to see this attachment.

4 answers to this question

Recommended Posts

  • 0
Posted

Please login or register to see this code.

if

fibaro:getValue(device_ID, "value") == false

then

fibaro:call(device_ID, "turnOn")

else

fibaro:call(device_ID, "turnOff")

end

  • 0
Guest samuelboerhoop
  • Inquirer
  • Posted

    I tried this but not working... as in... copy / paste your code:

     

    --[[
    %% properties
    79 value
    %% globals
    --]]
     
    if
    fibaro:getValue(79, "value") == false
    then
    fibaro:call(79, "turnOn")
    else
    fibaro:call(79, "turnOff")
    end
     
    ---------------------------------------
     
    I tried something else with a scene: lua blocks and then you can see the conversion lua code:
     
     
    --[[
    %% properties
    79 value
    %% globals
    --]]
     
    -- local startSource = fibaro:getSourceTrigger();
    if (
     ( tonumber(fibaro:getValue(79, "value")) > 0  or  tonumber(fibaro:getValue(79, "value")) == 0 )
    or
    startSource["type"] == "other"
    )
    then
    local deviceValue1 = tonumber(fibaro:getValue(79, "value"));
    if (deviceValue1 > 0) then
    fibaro:call(79, "turnOff");
    else
    fibaro:call(79, "turnOn");
    end
    end
     
    ------ the scene is working, fan on fan off, etc...
     
    I copied this code for the button "CEILING FAN ON / OFF", at first it wasn't working as i pressed "debug"
    The debug told me that line 7 was (nil) so I put the line as not active.
     
    After that it was working. Thanks a lot
    :
     
    • 0
    Guest merylion
  • Inquirer
  • Posted

    First of all this line is wrong:

     

    fibaro:getValue(79, "value") == false

     

    returned value type will be STRING not BOOLEAN so it should look like

     

    fibaro:getValue(79, "value") == '0'

    • 0
    Guest samuelboerhoop
  • Inquirer
  • Posted

    I changed the code again to the following simplified code:

     

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

    --[[
    %% properties
    79 value
    %% globals
    --]]

    if
    fibaro:getValue(79, "value") == '0'
    then
    fibaro:call(device_ID, "turnOn")
    else
    fibaro:call(device_ID, "turnOff")
    end

     

    All workis perfectly

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