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

Help, Block into LUA does not work well - solved


Question

Posted

Hi, I'm rather new to LUA programming, but learning every day.

I have created several scenes that are working well, also with using variables and so on.

However, everytime I want to have a scene starting at a certain time, I cannot do it in LUA as then it simply does not work somehow.

Maybe there is something simple thatI forget, but after quite some time puzzling myself, I thought to post it here.

 

I created a block scene and tested the functionality. It works as expected.

Then I change the scene to LUA without actually modifying anything else and after that the scene is not working anymore. The reason to put it in LUA is to simply add more funtionality afterwards.

 

The LUA script is like below. Can someone help me out here? Thank you very much in advance!

Edwin

 

--[[
%% properties
%% events
%% globals
--]]

local sourceTrigger = fibaro:getSourceTrigger();
function tempFunc()
local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
 ( ((currentDate.wday == 2 or currentDate.wday == 3 or currentDate.wday == 4 or currentDate.wday == 5 or currentDate.wday == 6) and string.format("%02d", currentDate.hour) .. ":" .. string.format("%02d", currentDate.min) == "06:50") )
)
then 
    fibaro:call(108, "setValue", "20"); -- keuken spoelbak
    fibaro:call(108, "turnOn"); -- keuken spoelbak
    fibaro:call(101, "setValue", "15"); -- eetkamer verlichting eettafel
    fibaro:call(101, "turnOn"); -- eetkamer verlichting eettafel
    fibaro:call(93, "turnOn"); -- woonkamer wandlamp trapkast
    fibaro:call(148, "turnOn"); -- woonkamer wandlamp links
    fibaro:call(149, "turnOn"); -- woonkamer wandlamp rechts
    fibaro:call(91, "turnOn"); -- eetkamer wandlamp links
    fibaro:call(92, "turnOn"); -- eetkamer wandlamp rechts
 fibaro:call(127, "setBrightness", "2"); -- keuken kastjes
 fibaro:call(120, "setBrightness", "2"); -- keuken vloer   
    fibaro:debug("verlichting aangeschakeld")    
end

setTimeout(tempFunc, 60*1000)
end
if (sourceTrigger["type"] == "autostart") then
tempFunc()
else

local currentDate = os.date("*t");
local startSource = fibaro:getSourceTrigger();
if (
startSource["type"] == "other"
)
then
    fibaro:call(108, "setValue", "20"); -- keuken spoelbak
    fibaro:call(108, "turnOn"); -- keuken spoelbak
    fibaro:call(101, "setValue", "15"); -- eetkamer verlichting eettafel
    fibaro:call(101, "turnOn"); -- eetkamer verlichting eettafel
    fibaro:call(93, "turnOn"); -- woonkamer wandlamp trapkast
    fibaro:call(148, "turnOn"); -- woonkamer wandlamp links
    fibaro:call(149, "turnOn"); -- woonkamer wandlamp rechts
    fibaro:call(91, "turnOn"); -- eetkamer wandlamp links
    fibaro:call(92, "turnOn"); -- eetkamer wandlamp rechts
 fibaro:call(127, "setBrightness", "2"); -- keuken kastjes
 fibaro:call(120, "setBrightness", "2"); -- keuken vloer   
    fibaro:debug("verlichting aangeschakeld")
end

end

3 answers to this question

Recommended Posts

  • 0
Posted

Hi Edwin,

 

Since this is time based scene you are missing %% autostart in scene header, so it should look like this:

 

--[[

%% autostart
%% properties
%% globals
--]]

 

Also if you don't want that triggered alarm stop this scene then put tick for option "Do not allow alarm to stop scene while alarm is running" on General tab of the scene. When you do that scene will be started when HC is restarted and also should start after pressing Save button and will not be interrupted if alarm is breached.

  • 0
Posted

Hello,

 

You can add the block scene as well so there will be comparison of what you have in blocks and how it looks in LUA.

  • 0
  • Inquirer
  • Posted

    Thanks guys! Adding the autostart has done the trick!

    Appearently converting to LUA does not automatically add this parameter.

     

    I also recognized that this is the solution for some other small LUA scripts I created.

    Lesson learned! Thanks!

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