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

Explanation of variables


xantony
 Share

Question

Hi all, is there anyone who can explain in a simple way what variables are actually into HC2 and how to use it?

I miss something in the logic. i.e. : let's assume i define a defoult variable night_day with two values night / day, and i use it into a scene description, how can i define to the system what is actually "day" and what is actually "night"????

any good example on how to define and use variables??

TIA

Link to comment
Share on other sites

19 answers to this question

Recommended Posts

  • 0

Basically, there are two types of variables :-

1) Variables

- freely entering any values (e.g.: integer data, text)

2) Predefined Variables

- preset values (e.g.: day, night or away, home, etc)

If you want a scene where you need e.g.: your staircase light to be activated by a motion sensor / door contact ONLY when it is night, then you would :-

a) define a predefined variables e.g.: DayNightStatus and enter the values "DAY" and "NIGHT"

b) set a condition using a scene (either LUA or block diagram) to set those variables e.g.: when it is sunset, set value of your predefined variables to NIGHT or vice versa. You can use timer condition e.g.: when it is 6.00pm or using light ambient value, etc, it does not matter what you use as a condition as long as you have one that you think is relevant.

c) you now need another scene that uses the criteria set above e.g.: when the variable DayNightStatus == NIGHT AND motionsen1 == BREACHED THEN light_stairs = ON

In essence, the variables are used as additional parameter.

I use variables to set my bedroom light to ON when there is motion detected in my bedroom ONLY when it is night, during the DAY, that event will not run. I also use it to give notification to my phone where is activity detected by my motion sensor ONLY when I'm not at home (I use my phone GPS location as the condition to set it AWAY and HOME). You can also set a variables e.g.: No_of_Door_Open with a default value of 0 and create a scene where you add / increment +1 to that variable everytime a certain door is open / closed.

There are many examples and scenarios that you can use these functions.

  • Like 1
Link to comment
Share on other sites

  • 0

The way I do it is:

you have variables Daytime with two options: day and night

You need to make two scenes, make it not visible in interfaces (this scenes should run automaticly).

One scene will be - based on time - day of the week. There you tick every day and choose time "at sunrise". Ignor the time next to it. So this make it run the scene every day at sunrise. THEN - choose variables, DAYTIME and make ich change to DAY.

The second scene - the same, run on sunset, change the variables to night.

Of corse, you can change the variables based on time, or based on amount of light on the outside sensor, or whatever. For me this sunset sunrise thing works good.

So the scenes change the variables automaticly. You dont need to care about it anymore.

Then for example, you want to use your motion sensors to turn on the lights, but only at night (no reason to turn on lights on the daytime right? ) So the scene will be:

If the motion sensor see the movement "AND" the variables daytime is set as NIGHT, "THEN" turn the light on.

Sorry if you wanted it as LUA code, but it is not that dificult to do it with blocks, so I hope I helped.

Link to comment
Share on other sites

  • 0
  • Inquirer
  • thanks all for your reply, now predefined variables are clear, how about "variables" ( not the predefined ones). how do you use them?

    Link to comment
    Share on other sites

    • 0

    Variables are similar to predefined. The only difference is that it does not have a preset value. You can enter any value you wish e.g.: integer, text, ip address.

    A good example is when you integrate a Phillips Hue Bulb into your system. You can create a variable called "huebridge" with a value of the IP address of your hue bridge. You can then call it from your LUA code.

    Another simple example is to use it for storing integer value e.g.: how many times has the front door been open today. Create a variable called "frontdoor_opencount" with a default value of 0. Then create a scene where IF frontdoor == OPEN then frontdoor_opencount +1

    Everytime, that door is open, the value gets incremented. You can then use that variable for creating notification to you via email, etc.

    Hope that helps.

    Link to comment
    Share on other sites

    • 0

    2 problems:

    a) variables: I can't get it to work. here is how my scenes look but the variables never have the right values. what am I doing wrong here?

    b) I'm trying to turn on my heating at 6am in the morning. It never does. see scene below too

    thx

    (i'm using Home Center Lite HCL)

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    Thanks, I will try that (again - did it before but that tick mark doesn't stick...)

    [ Added: 2014-12-12, 18:32 ]

    I just checked: both had "Start when HC starts" checked. That's not it

    [ Added: 2014-12-13, 10:39 ]

    i'm currently running some tests. seems like it works now but not sure why.

    i'll post more once i have more insight

    Link to comment
    Share on other sites

    • 0

    I cant get this to work. what am i doing wrong here?

    [ Added: 2014-12-14, 13:47 ]

    I cant get this to work. what am i doing wrong here?

    Do both scenes have to be assigned to the same room? or can the variable be unassigned?

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    me either.

    once again tonight my alarm was auto triggered because the day/night variable was off.

    scared the * out of my wife and kids. definitely not how it's supposed to be.

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" />

    why can't anybody tell me how this is done correctly?

    Link to comment
    Share on other sites

    • 0
    me either.

    once again tonight my alarm was auto triggered because the day/night variable was off.

    scared the * out of my wife and kids. definitely not how it's supposed to be.

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" />

    why can't anybody tell me how this is done correctly?

    Yeah well the problem seems to be with the "manuals". Cause they kind of dont tell everything. They leave out some really basic stuff that for many of the people in here and the people making it think is "obvious". But its not. And the manual around this variables is so vague.

    I normally don't say this about myself, and i both look at myself and hear from people that i know a bit about pc's and stuff, but here in this i feel like a blonde girl not knowing how to use the handle to open a damn door. So please explain it like im an idiot.

    For now i understand this:

    Please login or register to see this link.

    But again it leaves out the part where i should make a scene to say what that variable is suppose to do/be whatever.

    Please can someone explain this. Cause it would be really nice to have and to be able to make my scenes better.

    Does variables work accross rooms? Like can the variable scene be unnasigned. but work with a scene in kitchen by example?

    Link to comment
    Share on other sites

    • 0
    me either.

    once again tonight my alarm was auto triggered because the day/night variable was off.

    scared the * out of my wife and kids. definitely not how it's supposed to be.

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" />

    why can't anybody tell me how this is done correctly?

    Joerg,

    I think one can not add much to the good explanation alijanah gave you earlier. What is that you were trying to achieve exactly ?

    Furthermore variables are not assigned to anything and so they are usable in any scene in whatever room.

    So, for instance, in my home I have a variable called "Status" it has four possible values : "home", meaning that I'm home, "asleep", meaning that I'm home but sleeping, "away short", meaning that I'm not at home but that I will return to come and sleep at home that same day, and "away long", meaning I'm not home for several days like on holidays.

    Now:

    1) Normally the variable "Status" is set to "home", either manually (create a scene that ends with variable "Status" = "home") or when movement sensors around the house detect movement.

    2) When there has not been any movement anywhere in the house for 45 minutes a scene changes the value of the variable "Status" to "away short".

    3) When I leave the house for several days I need to set the variable "Status" manually to "away long"

    4) When I go to bed and switch off my bedside lamp the value of the variable "Status" is automatically set by an other scene to "Sleeping".

    5) Every value of the variable "Status" has its consequences. If it is "home" and the time is after sunset lights will go on automatically in the rooms were movement is detected, multimedia equipment is put in 'standby-mode', heating is enabled if necessary..

    If the value of "Status" is "Sleeping", the opposite is true: all lights in the house are turned off, heating is turned off, current is cut from all equipment so that they don't consume even low 'stand-by'-energy etc..

    If the value of "Status is "away short", it's almost the same as in "Sleeping" except that alarm is switched on on some key movement detectors.

    If the value of "Status" is "away long" almost every piece of equipment in the house is turned off except for very low temperature (freezing protection) heating and the alarm on all sensors in the house.

    Hope this gives you some ideas

    Link to comment
    Share on other sites

    • 0
    me either.

    once again tonight my alarm was auto triggered because the day/night variable was off.

    scared the * out of my wife and kids. definitely not how it's supposed to be.

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" />

    why can't anybody tell me how this is done correctly?

    Joerg,

    I think one can not add much to the good explanation alijanah gave you earlier. What is that you were trying to achieve exactly ?

    Furthermore variables are not assigned to anything and so they are usable in any scene in whatever room.

    So, for instance, in my home I have a variable called "Status" it has four possible values : "home", meaning that I'm home, "asleep", meaning that I'm home but sleeping, "away short", meaning that I'm not at home but that I will return to come and sleep at home that same day, and "away long", meaning I'm not home for several days like on holidays.

    Now:

    1) Normally the variable "Status" is set to "home", either manually (create a scene that ends with variable "Status" = "home") or when movement sensors around the house detect movement.

    2) When there has not been any movement anywhere in the house for 45 minutes a scene changes the value of the variable "Status" to "away short".

    3) When I leave the house for several days I need to set the variable "Status" manually to "away long"

    4) When I go to bed and switch off my bedside lamp the value of the variable "Status" is automatically set by an other scene to "Sleeping".

    5) Every value of the variable "Status" has its consequences. If it is "home" and the time is after sunset lights will go on automatically in the rooms were movement is detected, multimedia equipment is put in 'standby-mode', heating is enabled if necessary..

    If the value of "Status" is "Sleeping", the opposite is true: all lights in the house are turned off, heating is turned off, current is cut from all equipment so that they don't consume even low 'stand-by'-energy etc..

    If the value of "Status is "away short", it's almost the same as in "Sleeping" except that alarm is switched on on some key movement detectors.

    If the value of "Status" is "away long" almost every piece of equipment in the house is turned off except for very low temperature (freezing protection) heating and the alarm on all sensors in the house.

    Hope this gives you some ideas

    I think maybe the system is bugged. Cause when iv made scenes with variable it wont work. but now it works just fine. Don't ask me why. cause i just made a new scene that looks like the one before. And that one did not work. So why this one works i dont know.

    Thats the reason i or we where asking probably. Cause we follow the manual, did all it said but it wasnt working. therefor we where asking if we where doing something wrong.

    But thank you for trying.

    Link to comment
    Share on other sites

    • 0

    Here's a good practise to follow when creating a scene.

    1) When you click on Create New Scene from HC2/HCL interface, you will be presented with a box with options to enter on the General Tab:-

    - Name, Room, Type, ID, Show Scene In interface, etc

    - You will also see the 4 checkboxes Active Scene, Start when Home Centre Starts, Protect By Pin, Do not allow alarm to stop scene

    I SUGGEST YOU DON'T ALTER ANY OF THE ABOVE PARAMETERS FIRST. LEAVE IT WITH DEFAULT VALUE FOR THE TIME BEING.

    2) Go directly to the Advanced Tab and select your preferred method of programming (LUA or Block Diagram).

    3) Enter your programming codes or block diagrams.

    ONCE DONE. Click "Save" button on the bottom of your code FIRST.

    THEN CLICK SAVE ICON ON RIGHT SIDE OF INTERFACE (THE DISK ICON)

    Once you do that, you will be presented back to the General Tab with all the checkbox options "CORRECTLY SELECTED" by your controller (HC2/HCL). Any time based scripts / programs will have "Start when Home Centre 2 Starts" or vice versa.

    You can then rename your scene and choose to show your scene in the interface. LEAVE ALL THE OTHER SETTINGS ALONE. LET HC2/HCL SET THOSE FOR YOU.

    I find by doing this, your scene will correctly works as per specified (provided your programming is correct).

    Hope that helps.

    Link to comment
    Share on other sites

    • 0
    Here's a good practise to follow when creating a scene.

    1) When you click on Create New Scene from HC2/HCL interface, you will be presented with a box with options to enter on the General Tab:-

    - Name, Room, Type, ID, Show Scene In interface, etc

    - You will also see the 4 checkboxes Active Scene, Start when Home Centre Starts, Protect By Pin, Do not allow alarm to stop scene

    I SUGGEST YOU DON'T ALTER ANY OF THE ABOVE PARAMETERS FIRST. LEAVE IT WITH DEFAULT VALUE FOR THE TIME BEING.

    2) Go directly to the Advanced Tab and select your preferred method of programming (LUA or Block Diagram).

    3) Enter your programming codes or block diagrams.

    ONCE DONE. Click "Save" button on the bottom of your code FIRST.

    THEN CLICK SAVE ICON ON RIGHT SIDE OF INTERFACE (THE DISK ICON)

    Once you do that, you will be presented back to the General Tab with all the checkbox options "CORRECTLY SELECTED" by your controller (HC2/HCL). Any time based scripts / programs will have "Start when Home Centre 2 Starts" or vice versa.

    You can then rename your scene and choose to show your scene in the interface. LEAVE ALL THE OTHER SETTINGS ALONE. LET HC2/HCL SET THOSE FOR YOU.

    I find by doing this, your scene will correctly works as per specified (provided your programming is correct).

    Hope that helps.

    Thank you. is there any reason for doing it this way. cause i try to change the first general tab first then go to the advance. Is there a known bug or something since you recommend this way?

    I think i will start from scratch and do everything again like you said, and see if it works properly,.

    [ Added: 2014-12-16, 18:23 ]

    Im starting to get really annoyed of this.

    Now i deleted all, went back to basic to really understand what each step does.

    I made 2 variables.

    one has 2 "sunny" and "cloudy"

    then i made scene for these 2, one that says if under 200lux then cloudy. Then another where i have if over 200lux it is sunny.

    If i use this variable in 2 scenes. one "on" and one "off" scene. where i set this variable to use that variable it works fine. If i use my phone and light on the sensor to provoke the lux, the lights go on and off according to lux. Just like i want it right. Meaning iv done the right thing right?

    But then. If i take the same "on" and "off" scene and say that it should also "and" the other variable it just stops working when provoking light on sensor.

    The other one i have 4 "morning", "afternoon", "evening" and "night". Where iv made 4 scenes for that aswell. telling like at sunrise sunset etc etc.

    But once its added to the "on" "off" scenes the scene does not apply when i provoke lux to the sensor. Why? Iv tried changing to "exact time" in variable scene to see if time of day is wrong or something.

    Here is code for it also.

    Please login or register to see this code.

    Please login or register to see this attachment.

    Link to comment
    Share on other sites

    • 0

    Regarding the first issue with the scene interface, I have previous experiences where I've changed the General tab parameters first before anything and some of my scene don't work. Then I found out that, certain scenes that are time based needs certain parameters to be on ("Start When HC2 Starts"), thus I left it alone, do my scene programming and let HC2 sets all the correct parameters for me. I guess when you click Save, HC2 looks at the scene program and sets the General Tab accordingly.

    On your issue with multiple conditions, I can see no "obvious errors". If you are intending for the scene to work based on the TWO CONDITIONS == TRUE, then using AND is CORRECT.

    Why don't you try putting the Time of Day condition as first condition and Sunny Cloudy as second (below). I know it's stupid but sometimes you NEVER KNOW.

    I'll let Fibaro answer you on that.

    Link to comment
    Share on other sites

    • 0
    Regarding the first issue with the scene interface, I have previous experiences where I've changed the General tab parameters first before anything and some of my scene don't work. Then I found out that, certain scenes that are time based needs certain parameters to be on ("Start When HC2 Starts"), thus I left it alone, do my scene programming and let HC2 sets all the correct parameters for me. I guess when you click Save, HC2 looks at the scene program and sets the General Tab accordingly.

    On your issue with multiple conditions, I can see no "obvious errors". If you are intending for the scene to work based on the TWO CONDITIONS == TRUE, then using AND is CORRECT.

    Why don't you try putting the Time of Day condition as first condition and Sunny Cloudy as second (below). I know it's stupid but sometimes you NEVER KNOW.

    I'll let Fibaro answer you on that.

    I tried putting time first and then cloudy, but still that bitch aint working.

    Also yeah those two are kind of "true" as to "cloudy" and "sunny" is 2 options in 1 variable. iv tried having only 2 options on time, since maybe 5 different times in one day might be a problem, but that aint the case either.

    I think its a bug or something, im starting to doubt the whole fibaro thing here. Seems like the only way to get this to really work is to know coding and doing all in LUA, everything else seems bugged. I'm using so much time to really put myself into this and understand it. How hard is it suppose to be, especially with this box setup it should be basically bullett proof.

    [ Added: 2014-12-18, 14:29 ]

    Seriously nobody know whats wrong here? Is it a bug or what? Iv reported as bug, reportet by mailing fibaro. No answers at all. This is really frustrating!

    Link to comment
    Share on other sites

    • 0

    I completely forgot about this thread. But I figured it out...

     

    Problem is the alarm. If your alarm was triggered, and you haven't checked the infamous "Do not allow alarm to stop scene while alarm is running", then this scene is stopped. If this scene is a variable being set at some time or with some event, this is not done anymore and the variable is starting to be wrong. 

     

    Once I checked the box next to "Do not allow..." everything worked fine and no variable ever stopped working. 

     

    I think, Fibaro could do a better job in explaining these kind of things...

    Please login or register to see this image.

    /emoticons/default_icon_curve.gif" alt=":-/" />

    Link to comment
    Share on other sites

    • 0

    There is no monthly calendar to make scenes in HC so I need help.

     

    I need that one is different between summer and winter, so that the motor of the swimming pool works but hours in summer that in winter. it is this possible one?

    Link to comment
    Share on other sites

    • 0

    I use this to stop the bin reminder in December and a similar one in March to start it again.

    hope this helps

    Brian

    Please login or register to see this attachment.

    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.

     Share

    ×
    ×
    • Create New...