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 Creation in HC2


Question

Posted

I am facing very serious problem. My scenes were running despite the IF condition being false. For example I created a variable called 'MovieStart' with initial value as 1 and used it in a Movie scene with IF condition as MovieStart ==0. Then too the movie scene triggered. This was happening for all scenes. I then saw its LUA code and strangely the LUA code was showing another variable being added by the system in the IF condition with OR parameter, which was making the IF condition always TRUE irrespective of the variable value. If I edit the LUA code and remove this system generated parameter then my scenes ran perfectly. However with converting the graphic mode into LUA, one looses the convenience of graphic mode as once switched to LUA code fro editing the code I cannot switch back to graphic code.

I am attaching the to screen shots of the same scene... one in graphic mode and other one in LUA mode with error being highlighted.

Need urgent resolution

Please login or register to see this attachment.

Please login or register to see this attachment.

8 answers to this question

Recommended Posts

  • 0
Posted

Sorry, don't have the answer but a similar question:

This scene does not run as expected… To me I it seems that the block code, (and this is what t is saved as), is different to the LUA version/transcription. The objective of the scene is to turn change the HJEMME (Home) variable at midnight to 1 if I am at home. (The concept is that a variable value of 0=away, 1=a sleep, and 2=a wake and at home. This in turn controls other scenes and the state of devices, eg lights, sensors/alarms and so on).

Where does the – or “startSource["type"] == "other"… come from and what is the purpose?

--[[

%% properties

%% globals

HJEMME

--]]

local sourceTrigger = fibaro:getSourceTrigger();

if (sourceTrigger["type"] == "autostart") then

while true do

local currentDate = os.date("*t");

local startSource = fibaro:getSourceTrigger();

if (

( ((currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "23:59") and tonumber(fibaro:getGlobalValue("HJEMME")) == tonumber("2") )

)

then

fibaro:setGlobal("HJEMME", "1");

end

fibaro:sleep(60*1000);

end

else

local currentDate = os.date("*t");

local startSource = fibaro:getSourceTrigger();

if (

( (currentDate.wday == 1 or currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6 or currentDate.wday == 7) and tonumber(fibaro:getGlobalValue("HJEMME")) == tonumber("2") )

or

startSource["type"] == "other"

)

then

fibaro:setGlobal("HJEMME", "1");

end

end

Please login or register to see this attachment.

  • 0
Posted

Please login or register to see this code.

mean when i press run/start scene do

  • 0
Posted

Please login or register to see this code.

mean when i press run/start scene do

Hi,

but that must do something else! If i don`t remove the startSource i can`t do the opposite from the Scene manual.

  • 0
Posted

Economyhq, not understood you can you give example what you want to do?

  • 0
Posted

"other" simply means that the code will be executed manually, despite any conditions set. If you do not want to run the code manual then just delete this part:

Please login or register to see this code.

  • 0
Posted
Economyhq, not understood you can you give example what you want to do?

Hello A.Socha,

i´ve had a thread with a Timerproblem and exactly that parameter was the Problem because if you loose Blocks, they put that in with "else". And that was my Problem.

Please login or register to see this link.

Greetings from Germany

Sorry for my english..

  • 0
Posted

correct code when you want use time as a trigger and and you want after press run on scen start it too

Please login or register to see this code.

but if you want have time only as a trigger use

Please login or register to see this code.

  • 0
Guest Lode
Posted

I already explained that

Please login or register to see this image.

/emoticons/default_icon_wink.gif" alt=";-)" />

One more time......

The part after the "else" condition is used if you push the run button of your scene, so this is only used to manually trigger your scene.

Delete that part and you are fine

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