More Calculation options
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)
-
reporter -
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.
-
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. 😬
-
reporter https://lodash.com/docs/4.17.15#countBy
Is this something I could/should use? And than check the result by a threshold.
-
repo owner - changed title to More Calculation options
-
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.
-
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!
-
repo owner - changed status to resolved
False if are build in 2.15.2 (released later today in test.)
-
reporter Thanks for having added this Arie.
- Log in to comment
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!