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

Scene Controlled Via Contact Switch


Question

Guest puma
Posted

I am still trying to get the hang of LUA it's not going so great but I am trying to write a basic scene to turn on my garage lights on when either one of my garage doors are opened. However I can't get it to work correctly at this stage it will only work if I manually run the scene once the door is open it doesn't seem to realise that the door has opened. 

 

It would also be nice to some how put a timer on it to say turn off after 5 mins.

 

This is what I have come up with.

 

Thanks

 

--[[
%% properties
237 Value
%% events
%% globals
--]]

local myVariable
myVariable = fibaro:getValue(237, "state")
if (myVariable == 'Open') then
  fibaro:call(542, "turnOn")
end

 

 

3 answers to this question

Recommended Posts

  • 0
Posted (edited)

I did this on my HC3 look!

But I also have sensors for the garage open and close at my gate.

 

Please login or register to see this attachment.

 

And this is translate in LUA

 

Please login or register to see this attachment.

Please login or register to see this attachment.

 

greetings

F.B.

Edited by FBerges
  • 0
Guest puma
  • Inquirer
  • Posted

    Thanks for your help but I don't have a HC3 I am running a HC2.

    • 0
    Guest puma
  • Inquirer
  • Posted

    So I have done a little work and managed to come up with this however it still isn't right.

     

    --[[
    %% properties
    237 state
    %% events
    %% globals
    --]]

    if (tonumber(fibaro:countScenes()) > 1) 
    then 
        fibaro:debug("Script already running.");
        fibaro:abort(); 
    end

    if (fibaro:getValue(237, "state")== "Open")
    then
        fibaro:call(542, "turnOn");
        fibaro:sleep(300000)
        fibaro:call(542, "turnOff")
      
    if (fibaro:getValue(237, "state")== "Close")
    then
        fibaro:call(542, "turOff"); 
    end

     

     

    It does work when I open the door although for some reason it is quite delayed the door will be open for a good 10 seconds before it will turn the lights on.

     

    The timer does work for 5 mins however if I close the door it doesn't turn the lights off it will only go out with the timer.

     

    What have I done incorrectly?

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