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

k2aab

Question

I have a variable called "AnyOneAtHome" and it has two possible values of YES or NO. 

 

I have a scene called "TurnOnBathroomRad" and the code for this is displayed below.

 

Basically at 06:30 everyday it turns on the Rad if the "AnyOneAtHome" variable == YES.

 

It's been working perfectly until I added a scene (now locations services are working on iOS) to change the state of the "AnyOneAtHome" variable to YES when I come within 100m of home.

 

Now the "TurnOnBathroomRad" see this as a trigger and turns on the Rad whatever the time of day.

 

I thought with the AND both would have to be true and I want the time to be a trigger not the "AnyOneAtHome" variable changing/being set to YES.

 

Confused, any help much appreciated

 

Andrew

 

 

 

--[[
%% autostart
%% properties
%% globals
AnyOneAtHome
--]]

local sourceTrigger = fibaro:getSourceTrigger();
function tempFunc()
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) == "06:30") )
and
 ( fibaro:getGlobalValue("AnyOneAtHome") == "Yes" )
)
then
 fibaro:call(27, "turnOn");
end

end

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

I've had a similar problem in a script where the trigger was the time and not a device or a variable.

boomx has resolved for me the problem with a function that check every minute the time.

About the AND is correct that you write. Both conditions must be true. 

See this post: 

Please login or register to see this link.

You must change the script a little bit but is almost the same.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Thanks for that, based on the other post I reworked some of the code and ended with this:

     

    --[[
    %% autostart
    %% properties
    %% globals
    AnyOneAtHome
    --]]

    local sourceTrigger = fibaro:getSourceTrigger();
    function temp()
    local version = '1.0';
    local triggerHour = '06:30';
    local currentDate = os.date("*t");

    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) == triggerHour and fibaro:getGlobalValue("AnyOneAtHome") == "Yes"))
        then
        fibaro:call(27, "turnOn");
    end
       setTimeout(temp, 60*1000);
    end
     
    if (sourceTrigger["type"] == "autostart") then
     temp();
    end

    Link to comment
    Share on other sites

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