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

Understanding Variables


Question

Posted

Again, looking for a bit of basic help.

 

I have a variable “sunrise”
2 values, sunrise and sunset

 

2 time based scenes –
one to set variable value to sunrise
and the other to set variable value to sunset

 

1 Alarm scene – Breached and Safe
This runs when alarm is armed or unarmed

 

1 scene, only a test at the moment hence the 5 sec turn off option, which will be run when the alarm is safe/unarmed
i.e. when we come home

Want this scene to switch a light/plug, 8, on – but only if it is after sunset and before sunrise.
Made the scene using graphic blocks – as below

 

Please login or register to see this image.

/monthly_2018_01/image.png.489e5bb292dc931b9aaabd5db41a24ac.png" width="371" alt="image.png.489e5bb292dc931b9aaabd5db41a24ac.png" />

It does not seem to work - light comes on whatever the time is.

LUA code for this

--[[
%% properties
%% weather
%% events
%% globals
sunrise
--]]

local startSource = fibaro:getSourceTrigger();
if (
 ( fibaro:getGlobalValue("sunrise") == "sunset" )
or
startSource["type"] == "other"
)
then
    fibaro:call(8, "turnOn");
    setTimeout(function()
        fibaro:call(8, "turnOff");
    end, 5000)
end

 

If I delete

or
startSource["type"] == "other"

from the above code the scene works as I would expect.

I have had the same problem, same piece of code, with other Variable based scenes.

I am aware that this is pretty basic stuff but, for a newcomer, pretty confusing.

 

Thanks, in advance, for any help.

 

7 answers to this question

Recommended Posts

  • 0
Posted

this scene will always run when you hit save hence why if startSource is set to other aswell so you correctly remove that statement.

your trigger is set to the change in variable 'sunrise'

so when the variable changes to sunset then condition is true and scene will run.

at sunrise the variable 'sunrise' will change to sunrise and the condition will be false so scene will not run.

the change in variable is the only trigger you have set so far

in order for it to run only when you have disarmed the alarm then need to add in the 'alarm' variable as part of the trigger conditions and then uncheck the box for the 'sunrise' variable

  • 0
  • Inquirer
  • Posted

    Thanks for your reply.

    If i leave it as it is, with the startSource["type"] == "other" taken out will it run as soon as variable changes?

    What effect, in general, does unchecking a trigger box have?

    So much to understand - thanks again.

    • 0
    Posted

    startSource type other means if you press 'start' then it will run and not when the trigger condition changes.

    so removing that means the scene will run and only if the condition is true then it will run.

     

    all scenes need to be triggered to run, whether time based, ie at a specified time, or device based eg motion detected.

    in your scenario you are triggering a scene based on a variable changing, so if you have more than 1 device in your IF statement ie the top part of the scene before the THEN part you can actually choose which elements you want to trigger the scene by way of checking or unchecking the box.

    see pic below:

    i have 2 triggers and any change in either will run the scene.

    however i can uncheck the 'alarm' variable and only changes to front door will trigger the scene.

    hope that makes sense

     

     

    Please login or register to see this attachment.

    • 0
  • Inquirer
  • Posted

    I do thank you for your informative reply.

    The logic with HC2 is, in some areas, so different to my previous X10 controllers.

    (I am in the process of migrating from X10).

    In your scene above, how would you stop the light coming on if the Front Door was breached and armed but the alarm variable was actually “on”.

     

    I have a scene in the morning which raises my shutters.

    I only want my shutters raised if 3 variable conditions are met.

     

    Alarm variable is off/breached - I have an alarm on/off variable

    Sunrise variable is on - sunrise variable on at sunrise/off at sunset

    Later than 7am variable is on - this variable is on at 7am/off at sunset

     

    we don’t want shutter up unless alarm is off/breached,

    but it has to be daytime - after sunrise before sunset

    and it has to be after 7am.

     

    At this time of year sunrise is, say, 8am.

    so if we get up at 6.30am we do not want the shutter up until 8am

     

    so I have a scene - call it “shutter up”

    Alarm variable == off/breached

    Sunrise variable == on

    Later than 7am variable == on

     

    then

    shutter = open

     

    i run this scene every 10mins between 7am and 8.30am

     

    At 7am

    the alarm variable condition would be off

    The Later than 7am variable would be on

    but the sunrise variable would be off

    therefore shutter would not go up

     

    In this example at 8am all the 3 variables would meet my required conditions and the shutter would open.

     

    In my old X10 controllers the above would work but with HC2 it does not.

     

    Can imagine it’s something to do with running scenes as manual or automatic and ticking or unticking triggers.

     

    Hope this makes sense.

     

    Thanks again

     

     

    • 0
    Posted

    can you place the LUA scene

    • 0
  • Inquirer
  • Posted

    Hi, Kage

    Sorry, I do not understand your request.

    • 0
  • Inquirer
  • Posted

    Update

    So everything seemed to work this morning having taken

    startSource["type"] == "other"

    out of the LUA code.

    also, didn't run seem to need to run my "7 to 8.30" scene.

    Hope it all works tomorrow.

    Thanks for all the pointers - in the end it seems to be an easy solution - as they say "It's easy when you know how"

     

    if it helps this is what I used - it seems to work - however if anyone can see any flaws please let me know:-

    Variable “sunrise”
    2 values, sunrise and sunset

     

    2 time based scenes –
    one to set variable value to sunrise
    and the other to set variable value to sunset

     

    Variable "alarmsafe"

    2 values, breached and safe

     

    1 Alarm scene – breached and safe
    This runs when alarm is armed or unarmed

     

    Variable "sevenam"

    2 values 7AM and Dusk

     

    2 time based scenes

    one to set value "7AM" at 7am

    one to set value "Dusk" at sunset

     

    Varible "shutopenclose"

    2 values open and close

     

    Variable changed at end of this code to open and when the shutter is closed the code will change it to closed

     

    then this LUA scene

    to effect

    shutter up when alarm breached,

    but it has to be daytime - after sunrise before sunset

    and it has to be after 7am.

    --[[
    %% autostart
    %% properties
    %% weather
    %% events
    %% globals
    sunrise
    sevenam
    alarmsafe
    --]]

    local startSource = fibaro:getSourceTrigger();
    if (
     ( fibaro:getGlobalValue("sunrise") == "sunrise" )
    and
     ( fibaro:getGlobalValue("sevenam") == "7am" )
    and
     ( fibaro:getGlobalValue("alarmsafe") == "breached" )

    )
    then
        fibaro:call(19, "open");
        fibaro:setGlobal("shutopenclose", "open");
    end

     

     

    Cheers

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