More Calculation options

Issue #61 resolved
tf created an issue

Hey Arie,

Would it be possible to add the following options in the Calculation for Boolean fields?

  • False if any is true
  • False if all is true

With these 2 inversions all possible outcomes are covered from the same setting.

Comments (9)

  1. tf reporter

    Just asking …

    As a follow-up on this issue and the related one in BLL, could the Boolean-calculation option in an AVD be extended with even more options to evaluate number of trues/falls before setting the aggregate Boolean to either true or false?

    So could there be an option here that gives the user the option to choose 5 trues out of 8 Booleans for example.

    I tackle this problem with regular flow-cards at the moment. With 4 different child-Booleans this is getting already quite elaborate. But how I have this setup at the moment, the complexity quickly explodes with each additional child-Boolean introduced.

    Thanks again!

  2. arie repo owner

    “So could there be an option here that gives the user the option to choose 5 trues out of 8 Booleans for example.”

    This can already be done wif you use the Calculation: BLL.

    Then you can check through a BLL/javascript if the $values array contains a certain amount of trues.

  3. tf reporter

    Thanks for responding Arie!

    As an example, let’s say I would like this field to be true if at least 2 of the reflected variables are true. How should the code snippet look like than?

    (I am not at all familiar with coding.)

    I tried both searching the Homey-forum and Google, but do not know really where to start. 😬

  4. arie repo owner

    As example, this will return an array of 3 items: all the trues.

    let $values = [true, true, false, true, false];
    return _.filter($values);
    

    So, what you would need to enter in the calculation field is:

    _.filter($values).length>=2
    

    If you enter this into the BLL Calculation field, the field will evaluate to True/On when there are 2 or more reflected properties true.

  5. tf reporter

    Thanks again.

    As a proof of concept this works perfectly as intended.

    Now I will have to continue my ongoing pursue to stabilise my H23.

    You’re the best!

  6. Log in to comment