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

Virtual device Using globals


Question

Posted

Between mouth fulls of xmas turkey, can someone help me with how this should be done correctly.

I'm trying to compare multiple defined globals to turn a device on or off in VD main loop .

Also can we use not equal  .... if fibaro:getGlobal("PresentState") not equal to "Holiday" if so what key for the little squiggle character before the = sign for not equal?

Thanks Jamie

Please login or register to see this attachment.

 

7 answers to this question

Recommended Posts

  • 0
Posted
Quote

Also can we use not equal  .... if fibaro:getGlobal("PresentState") not equal to "Holiday" if so what key for the little squiggle character before the = sign for not equal?

Please login or register to see this code.

Please login or register to see this link.

 

  • 0
Posted

Are you on a MAC? It's alt-n for tilde "~", but it's a dead key, so you either type = or space after that.

  • 0
  • Inquirer
  • Posted
    5 hours ago, petergebruers said:

    Are you on a MAC? It's alt-n for tilde "~", but it's a dead key, so you either type = or space after that.

    Thanks, what about a windows PC?

    • 0
  • Inquirer
  • Posted (edited)
    8 hours ago, petergebruers said:

    Are you on a MAC? It's alt-n for tilde "~", but it's a dead key, so you either type = or space after that.

    Thanks, what about a windows PC?

     

    Edited by Jamie mccrostie
    • 0
  • Inquirer
  • Posted (edited)
    8 hours ago, petergebruers said:

    Are you on a MAC? It's alt-n for tilde "~", but it's a dead key, so you either type = or space after that.

     

    My question relates to this. I have one defined global with three possible settings holiday, away and home. How do I write a argument where "Away" and "Home" are both true results.  I was thinking not equal was the easiest way to do this

    ie  fibaro:getGlobal("PresentState") not = "Holiday".

    How else can i do this?

    Thanks

    Edited by Jamie mccrostie
    • 0
    Posted
    17 hours ago, Jamie mccrostie said:

    Thanks, what about a windows PC?

    If you do not have a key for that, but you have a numeric keypad, you can type ALT (hold) then in succession 0 1 2 6

     

    17 hours ago, Jamie mccrostie said:

    I have one defined global with three possible settings holiday, away and home.

     

    There's probably a lot to tell about this seemingly simple question.

     

    You can see each comparison as boolean (only returning true or false). So you stack them with "and" and "or" - maybe use "not" or "~=".

     

    One boolean logic rule can make your code easier to read. If you say

     

    not(A and B)

     

    This can be written as

    (not A) or (not B)

     

    However! You are dealing with a global variable. If we assume Presentstate has a fixed number of predefined values, you can write rules either way. If you add a value, things might break.

     

    Assume PresentState can only contain "Home" and "Away". Then (variable == "Away") equates to (variable ~= "Home"). But what happens if you add "Sleeping"? They are no longer equivalent...

    • 0
  • Inquirer
  • Posted
    5 hours ago, petergebruers said:

    If you do not have a key for that, but you have a numeric keypad, you can type ALT (hold) then in succession 0 1 2 6

     

     

    There's probably a lot to tell about this seemingly simple question.

     

    You can see each comparison as boolean (only returning true or false). So you stack them with "and" and "or" - maybe use "not" or "~=".

     

    One boolean logic rule can make your code easier to read. If you say

     

    not(A and B)

     

    This can be written as

    (not A) or (not B)

     

    However! You are dealing with a global variable. If we assume Presentstate has a fixed number of predefined values, you can write rules either way. If you add a value, things might break.

     

    Assume PresentState can only contain "Home" and "Away". Then (variable == "Away") equates to (variable ~= "Home"). But what happens if you add "Sleeping"? They are no longer equivalent...

    Thanks, I chickened out and toggled another global off holiday.

    A seeming simple heating VD has taught me plenty including the value of not switching devices within the VD, Zwave Traffic with looping.

    Heating scene triggered by VD this mornings task.

     

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