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


Question

Posted

Hi guys!
I've recently bought HC2 and started to "play" with it. I've even updated to 3.590 and with some little problems works fine.

I wanted to create a scene in which my motion sensor ID 220 to light up one lamp (ID 56)using one small fibaro dimmer to 100% if light intensity in my motion sensor (ID 222) area is below 500 lux (any value will be just fine) and if another 3 scenes are not active (scene IDs are 20,21,22) and then after 3*60 seconds to light off or if the light intensity on that ID 222 sensor is greater than 500 to close completly (0 % becouse I use dimmer) two lamps (ID 56 and ID 57)

but, if the first condition is true, to close that 2 lamps after 15 mins.

 

I encountered some small problems which make my scene to be imposible to start:

- I used underline to highlight where the scenes condition I think I need to write but I get an error

[ERROR] 15:10:35: line 16: ')' expected (to close '(' at line 12) near 'fibaro'

- If I use -- so the code is not checked (comments) I get another error:

  [ERROR] 14:52:10: line 39: ')' expected (to close '(' at line 38) near '='

I tried to put every condition in its own ( ) also not working and I'm stuck...

ps: Does anyone know how to increase log in time remotly via home.fibaro.com? becouse I need to log in very often...

 

--[[ HERE IS MY CODE
%% properties
not sure if here to declare 220 value and armed (not yet sure what I need to put in here!)
%% globals
--]]

if (fibaro:countScenes() > 1) then -- HERE IS LINE 7
  fibaro:abort();
end


if ( -- HERE IS LINE 12
    tonumber(fibaro:getValue(220,"value")) >0  and
    tonumber(fibaro:getValue(220,"armed")) >0  and
    tonumber(fibaro:getValue(222,"value")) <500  
    --fibaro:countScenes(20) = 0  and -- HERE IS LINE 16
    --fibaro:countScenes(21) = 0  and
    --fibaro:countScenes(22) = 0  

   )
      then
          
            fibaro:call(56, 'setValue', 100);
            fibaro:sleep(180);
            fibaro:call(56, 'setValue', 0);
           
  end

if ( tonumber(fibaro:getValue(222,"value")) >500 ) -- lumina mai mare de ...
  then
  fibaro:call(56, 'setValue', 0);
  fibaro:call(57, 'setValue', 0);
  end

fibaro:debug("senzor HL_LI a fost trigerat");
fibaro:sleep(900); -- asteapta un timp

if ( -- HERE IS LINE 38
    fibaro:countScenes(20) = 0 and
    fibaro:countScenes(21) = 0 and
    fibaro:countScenes(22) = 0
   )
      then
    fibaro:call(56, 'setValue', 0);
    fibaro:call(57, 'setValue', 0);
end
 

 

5 answers to this question

Recommended Posts

  • 0
Posted

use == instead of = in comparison

  • 0
  • Inquirer
  • Posted

    Hi Alex!

    Helped me alot and saved much of my time

    Please login or register to see this image.

    /emoticons/default_smile.png" alt=":)" srcset="https://forum.fibaro.com/uploads/emoticons/[email protected] 2x" width="20" height="20" /> Thanks!

    Just two more question...

    What about

    --[[
    %% properties
    what shall I put here?
    %% globals
    --]]

     

    and

     

    does I need ";" after fibaro:abort(); ?

     

    Many thanks for your fast reply!

    • 0
    Posted

    ; is not required in LUA.

     

    After the line "%%properties" you can write down all IDs that should activate/start this scenario.

    Each ID should be in a separate line followed by the variable that should be watched.

    Mostly this is "value" (the current power usage of the wall plug in version 3.6 and below is using valueSensor I think).

    So a line will look like "123 value" e.g.

     

     

    Btw I recommend you to read at least one short tutorial about LUA, this helps a lot. You can also create a scene using the colourful block animation tool and look at its LUA code afterwards. You will learn a lot by doing this too.

    And crawl this forum for scripts.

    • 0
  • Inquirer
  • Posted

    Hi again Alex!

    Thanks for the feedback. As the preparation for the programing I had read many sites which have examples and I've printed many lists of commands and how to use them but, ofcourse, becouse I had no interface to use due to lack of HC2. Now, after i've started to read and try all examples in the HC2 program interface, I've realized that I still don't know many thing. As the graphical blocks I'm almost certain that I can't use it for my complex scenarios (not very complex but not as simple as required by the graphical programming mode).

     

    I will read every code on this forum and try some to understand LUA.

    Thanks!

    • 0
  • Inquirer
  • Posted

    Is it possible that one deleted scenario to still running?

    I've restarted my HC2 but surprise, the deleted scenario is running and two (saved) scenario created before restart (which worked perfectly), doesn't work anymore!

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