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


Question

Posted

Hi

 

what am i doing wrong in this scene i am trying to:

 

if the outside temp is below 3 then set danfoss to 28 for one hour and then danfoss to 4 in one hour

 

i did make to scene for this:

 

--[[

%% properties
164 targetLevel
3 Temperature
%% globals
--]]
 
setTimeout(function()
local delayedCheck0 = false;
local tempDeviceState0, deviceLastModification0 = fibaro:get(164, "value");
if (( tonumber(fibaro:getValue(164, "targetLevel")) == 4 ) and (os.time() - deviceLastModification0) >= 3600) then
delayedCheck0 = true;
end
 
local startSource = fibaro:getSourceTrigger();
if (
 ( tonumber(fibaro:getValue(3, "Temperature")) < tonumber(3) )
and
 ( delayedCheck0 == true )
or
startSource["type"] == "other"
)
then
      fibaro:call(164, "setTargetLevel", "28");
end
end, 3600000)
 
 
 
and
 
 
 
--[[
%% properties
164 targetLevel
%% globals
--]]
 
setTimeout(function()
local delayedCheck0 = false;
local tempDeviceState0, deviceLastModification0 = fibaro:get(164, "value");
if (( tonumber(fibaro:getValue(164, "targetLevel")) == 28 ) and (os.time() - deviceLastModification0) >= 3600) then
delayedCheck0 = true;
end
 
local startSource = fibaro:getSourceTrigger();
if (
 ( delayedCheck0 == true )
or
startSource["type"] == "other"
)
then
      fibaro:call(164, "setTargetLevel", "4");
end
end, 3600000)
 
regards
Elvar Páll
 
www.webcam-iceland.com

3 answers to this question

Recommended Posts

  • 0
Posted

Something like this:

Please login or register to see this code.

  • 0
  • Inquirer
  • Posted

     

    Something like this:

    Please login or register to see this code.

    Tanks i like this script but it i does only run ones so i added autostart and change fibaro:sleep to 4 sec for testing and added

    fibre:sleep(2) at the bottom .

    what am i missing it only run ones ?

     

    --[[

    %% autostart
    %% properties
    3 Temperature
    %% globals
    --]]
     
    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
     
    local startSource = fibaro:getSourceTrigger();
    if ((tonumber(fibaro:getValue(3, "Temperature")) < 3) or (startSource["type"] == "other"))
    then
      if debug then fibaro:debug("Outside temperature below 3, setting target level to 28"); end
      fibaro:call(164, "setTargetLevel", "28");
      fibaro:sleep(4000);
      if debug then fibaro:debug("Waited one hour, setting target level to 4"); end
      fibaro:call(164, "setTargetLevel", "4");
      fibaro:sleep(2000);
      if debug then fibaro:debug("Waited 1 hour, start again"); end
    end
    • 0
    Posted

    The way I did it was that the trigger is the change of temperature. So if temperature of device ID 3 is changing it is running the script, looking if the temperature is below 3 and then set the settargetlevel. If during this hour the temperature will rise it will run again, but will be aborted due to the first part of the script (only allowd to run 1 in a time).

     

    So to test it, you should make sure the temperature is changing for device ID 3.

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