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

LUA help needed


Question

Posted

Hi Guys,

I am doing something wrong but can not detect what!

Can somebody please correct my scene?

The GV is created

Error message

Thanks in advance

Please login or register to see this image.

/monthly_2019_03/image.png.497709486e748ace74c7a3dba712d0c9.png" alt="image.png.497709486e748ace74c7a3dba712d0c9.png" />

 

--[[
%% autostart
%% properties
%% globals
--]]
local sourceTrigger = fibaro:getSourceTrigger();
if (sourceTrigger["type"] == "autostart") then
 
  local debug = true;

  -- check script instance count in memory
  if (tonumber(fibaro:countScenes()) > 1) then
    if debug then fibaro:debug("Script already running."); end
    fibaro:abort();
  end

  if debug then fibaro:debug("HC2 start script at " .. os.date()); end

  while true do
 
    local ochtendgloren = (os.time()+50*60) == fibaro:getValue(1, "sunriseHour")
    local avondrood = (os.time()-50*60) == fibaro:getValue(1, "sunsetHour")
    local currentTime = os.date("%H:%M");
    local TimeOfDay = fibaro:getGlobal("TijdStip");

    if ( ochtendgloren <= currentTime and currentTime < avondrood and TijdStip ~= "Ochtendgloren" )
    then
      fibaro:setGlobal("TijdStip", "Ochtendgloren");
      if debug then fibaro:debug("Ochtendgloren"); end
      
    elseif ( avondrood <= currentTime and currentTime < ochtendgloren and TijdStip ~= "Avondrood" )
    then
      fibaro:setGlobal("TijdStip", "Avondrood");
      if debug then fibaro:debug("Avondrood"); end
      
     end
    fibaro:sleep(60*1000);
  end
else
  fibaro:debug("Script can only be run via autostart");
end

2 answers to this question

Recommended Posts

  • 0
Posted

Don't know what you try to do, but

local ochtendgloren = (os.time()+50*60) == fibaro:getValue(1, "sunriseHour") -----> is a false or true (bolean error)

also 

if ( ochtendgloren <= currentTime and currentTime < avondrood and TijdStip ~= "Ochtendgloren" )
Tijdstip is a global i think you mean TimeOfDay 

 

If you try to set global Tijdstip between 50 min before sunrise and sunrise, 50 min before sunset and sunset then.

 

--[[
%% autostart
%% properties
%% globals
--]]
local sourceTrigger = fibaro:getSourceTrigger();
if (sourceTrigger["type"] == "autostart") then
 
  local debug = true;

  -- check script instance count in memory
  if (tonumber(fibaro:countScenes()) > 1) then
    if debug then fibaro:debug("Script already running."); end
    fibaro:abort();
  end

  if debug then fibaro:debug("HC2 start script at " .. os.date()); end

  while true do
    local ochtendgloren = os.date("%H:%M", os.time()+50*60)
    local avondrood      = os.date("%H:%M", os.time()+50*60)
    local sunrise         = fibaro:getValue(1, "sunriseHour")
    local sunset         = fibaro:getValue(1, "sunsetHour")
    local currentTime     = os.date("%H:%M");
    local TimeOfDay     = fibaro:getGlobal("TijdStip");

    if ( ochtendgloren >= sunrise and currentTime < sunrise and TijdStip ~= "Ochtendgloren" )
    then
      fibaro:setGlobal("TijdStip", "Ochtendgloren");
      if debug then fibaro:debug("Ochtendgloren"); end
      
    elseif ( avondrood >= sunset and currentTime < sunset and TijdStip ~= "Avondrood" )
    then
      fibaro:setGlobal("TijdStip", "Avondrood");
      if debug then fibaro:debug("Avondrood"); end
      
     end
    fibaro:sleep(60*1000);
  end
else
  fibaro:debug("Script can only be run via autostart");
end
 

  • 0
  • Inquirer
  • Posted

    Hello

    Please login or register to see this link.

    Please login or register to see this link.

    Thank you very much my error is disapered, chapeau! With this I also could correct another scene

    I am combining some global variables together, 2 for time related and one for lux values now instead of 6.

    I need to lower my CPU usage, some have a flat part in the graphic now its running with almost al sharp point at the top, restonly a few others.

    Now I must start on the heating to reduce from 6>>> into 1 (I hope).

    For sure I will bother you again with a small problem.

    Thanks again and have a nice weekend.

     

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