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 Help please!


Question

Posted

Hi Guys,

Probably easy to you guys but I'm a bit new to scenes and could do with some help:

1) What does 'Active' Scene checkbox do? Does it mean that the first trigger bit of code runs automatically?

So far I've unchecked the Active box and when I did the test on something simple and pressed 'run' it looks like it bypassed the IF statement and just executed the commands e.g. turn off this turn off that. Could someone explain what does what quickly for me? I looked in the manual and couldn't find it and I've not found a post which explains so far.

2) I wrote this basic LUA just to check if something's on first before wasting time shutting it off but I keep getting an error saying '= expected before tonumber' or something like that. Makes no sense to me so I commented that out and then it's doing it near _luxValue! Arrgh. What's wrong please?

--[[

%% properties

%% globals

--]]

-- Random vars

-- Random vars

local _id1 = 9;

local _luxValue = fibaro:getValue(_id1, "value");

-- Plant Room vars

local _id2 = 13;

local _isLabgearOn = fibaro:getValue(_id2, "value");

local _id3 = 47;

local _isMatrixOn = fibaro:getValue(_id3, "value");

local _id4 = 48;

local _isNetmonOn = fibaro:getValue(_id4, "value");

local _id5 = 50;

local _isPOEOn = fibaro:getValue(_id5, "value");

local _id6 = 49;

local _isNetgearSwOn = fibaro:getValue(_id6, "value");

-- Ground FLoor vars

local _id7 = 53;

local _isKuroOn = fibaro:getValue(_id7, "value");

local _id8 = 54;

local _is875On = fibaro:getValue(_id8, "value");

--local _id9 := 9;

--local _isSubOn := fibaro:getValue(_id9, "value");

-- Basement Lounge vars

local _id10 = 4;

local _isTVOn = fibaro:getValue(_id10, "value");

local _id11 = 11;

local _isAVROn = fibaro:getValue(_id11, "value");

local _id12 = 41;

local _isPowerStripOn = fibaro:getValue(_id12, "value");

local _id13 = 19;

local _isLoungePCOn = fibaro:getValue(_id13, "value");

--end set locals

local startSource = fibaro:getSourceTrigger();

IF (_luxValue) <= "130"

OR startSource["type"] == "other"

THEN

--IF tonumber(_luxValue) <= 130 THEN

-- if its less than this it is night time

IF _isLabgearOn == TRUE THEN

fibaro:call(_id2, "turnOff");

fibaro:sleep(500);

END

IF _isMatrixOn == TRUE THEN

fibaro:call(_id3, "turnOff");

fibaro:sleep(500);

END

IF _isNetmonOn == TRUE THEN

fibaro:call(_id4, "turnOff");

fibaro:sleep(500);

END

IF _isPOEOn == TRUE THEN

fibaro:call(_id5, "turnOff");

fibaro:sleep(500);

END

IF _isNetgearSwOn == TRUE THEN

fibaro:call(_id6, "turnOff");

fibaro:sleep(500);

END

IF _isKuroOn == TRUE THEN

fibaro:call(_id7, "turnOff");

fibaro:sleep(500);

END

IF _is875On == TRUE THEN

fibaro:call(_id8, "turnOff");

fibaro:sleep(500);

END

--IF _isSubOn == TRUE THEN

-- fibaro:call(_id9, "turnOff");

-- fibaro:sleep(500);

--END

IF _isTVOn == TRUE THEN

fibaro:call(_id10, "turnOff");

fibaro:sleep(500);

END

IF _isAVROn == TRUE THEN

fibaro:call(_id11, "turnOff");

fibaro:sleep(500);

END

IF _isPowerStripOn == TRUE THEN

fibaro:call(_id12, "turnOff");

fibaro:sleep(500);

END

IF _isLoungePCOn == TRUE THEN

fibaro:call(_id13, "turnOff");

fibaro:sleep(500);

END

ELSEIF

fibaro:log("Value is: " .. isPowerStripOn ..);

fibaro:log("Value is: " .. isLabgearOn ..);

fibaro.log("Scene will not run as day time")

END

3 answers to this question

Recommended Posts

  • 0
Posted

I don't know anything about Lua really, but normally script would have the 'if' condition all in brackets

So...

Please login or register to see this code.

Should read

Please login or register to see this code.

  • 0
  • Inquirer
  • Posted

    Hi Wobbler,

    Thanks for the reply. I agree, you can use brackets but you don't necessarily have to.

    However I only removed them to see if it made any difference to the error I was getting in the LUA debug window in the scene.....but it didn't...I still get the same error e.g. 'expected = near to _luxvalue' or something like that.

    Doesn't seem like hard code (not to me anyway) so I'm obviously missing something that's particular to LUA (which I am new to) or the HC2 scene code which I don't understand as yet.

    Any help much appreciated

    KR, Dave

    Please login or register to see this image.

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

    • 0
    Posted

    I copied your code into a content aware editor, it didn't recognise upper case IF THEN ELSE END as valid Lua. Not sure if that is actually the case with a Fibaro, however it would explain the statements all executing without processing the conditional logic, if upper case keywords are not valid.

    Also the last fibaro statement has a full stop instead of a colon and no semi-colon to end the line.

    Also commenting out the _luxValue line broke the nested if statement, as you would have had an 'end' statement with no corresponding 'if'.

    Try the code below. I have no more ideas.

    Please login or register to see this code.

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