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 not running


Question

Posted

Hey all,

I'm still having fun.

Have a scene which works fine with I click 'Run'. But it doesn't work if just left alone i.e. to 'run' on it's own.

Triggers seem fine; Lua code is very simple.

I was thinking maybe it's something to do with the polling of scenes?; how is that defined?

--[[

%% autostart

%% properties

11 power

%% globals

--]]

local startSource = fibaro:getSourceTrigger();

local power = tonumber(fibaro:getValue(11, "power"));

fibaro:debug ("power:"..power);

if ( power > 1.0 ) then

-- fibaro:call(6, "sendDefinedEmailNotification", "1");

fibaro:debug ("Email sent"..power);

fibaro:call(6, "sendDefinedEmailNotification" ,"fghfhfg" ,"pump" ); -- doesn't work

fibaro:call(35 , "sendPush" ,"power"); -- does work but only on 'run'

end

Been around 10 minutes now and nothing; so assume scene isn't running???

thanks

2 answers to this question

Recommended Posts

  • 0
Posted

I am no LUA expert but this works for me..

So it has the loop command and sleep for 60*1000

I use this scene to switch lights on in my house when I have the global variable Holiday set to On.

--[[

%% autostart

%% properties

%% globals

HolidayLight

HolidayMode

DayTime

--]]

local num = fibaro:countScenes();

if (num == 1) then

-- fibaro:debug('1 scene is currently running');

else

fibaro:debug('Number of the scenes running: ' .. tonumber(num) .. ". Aborting current scene");

if (fibaro:countScenes()>1) then fibaro:abort() end

end

local sourceTrigger = fibaro:getSourceTrigger();

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

while true do

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

local startSource = fibaro:getSourceTrigger();

if (

( fibaro:getGlobalValue("HolidayLight") == "Off" )

and

( fibaro:getGlobalValue("HolidayMode") == "On" )

and

( fibaro:getGlobalValue("DayTime") == "Off" )

and

( ( 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(os.date("%H%M")) ==

tonumber(string.format("%02d%02d", "19","00")))

)

then

fibaro:call(108, "turnOn");

fibaro:call(109, "turnOn");

fibaro:setGlobal("HolidayLight", "On");

fibaro:call(2, "sendEmail", "Office Lights On", "Holiday Lights are now On");

end

fibaro:sleep(60*1000);

end

end

  • 0
  • Inquirer
  • Posted

    Hi,

    Thanks!; but I'm confused.

    Are you saying my scene only run's once not continually?

    I want it (for example) to execute every minute - how do I do that??

    thanks again

    [ Added: 2014-11-11, 16:44 ]

    Ahhhhhhhh!!!

    You have a do while true loop!

    On verde you set the interval!!! ; it now works! - THANK-YOU!

    Still can't get email notification going though; but the push works

    Please login or register to see this image.

    /emoticons/default_icon_smile.gif" alt=":-)" />

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