# Boolean Algebra with logic yes/no variables

**URL:** <https://community.homey.app/t/boolean-algebra-with-logic-yes-no-variables/103782>\
**Category:** Questions & Help\
**Created:** [February 11, 2024, 5:50pm UTC](https://community.homey.app/t/boolean-algebra-with-logic-yes-no-variables/103782 "2024-02-11T17:50:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![widameista](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/widameista/32/23333_2.png) [@widameista](https://community.homey.app/u/widameista)\
**Post date:** [February 11, 2024, 5:50pm UTC](https://community.homey.app/t/boolean-algebra-with-logic-yes-no-variables/103782/1 "2024-02-11T17:50:25Z")

</div>

I have a set of variables for my door/windows sensors which are yes or no.  
How can i calculate something like (sensor1 or sensor2 or sensor3) to have one resulting variable to reflect if any window is open.  
When i try with math expression in better logic i receive errors.  
thanks

---

<div class="post-metadata">

**Author:** ![Hugo](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/hugo/32/11530_2.png) [@Hugo](https://community.homey.app/u/Hugo)\
**Post date:** [February 11, 2024, 7:03pm UTC](https://community.homey.app/t/boolean-algebra-with-logic-yes-no-variables/103782/2 "2024-02-11T19:03:13Z")

</div>

Have you tried zones?  
And what are the variables for?

---

<div class="post-metadata">

**Author:** ![widameista](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/widameista/32/23333_2.png) [@widameista](https://community.homey.app/u/widameista)\
**Post date:** [February 11, 2024, 7:32pm UTC](https://community.homey.app/t/boolean-algebra-with-logic-yes-no-variables/103782/3 "2024-02-11T19:32:21Z")

</div>

The variables are for the Status of all door sensors. Zones is Not an Option

---

<div class="post-metadata">

**Author:** ![widameista](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/widameista/32/23333_2.png) [@widameista](https://community.homey.app/u/widameista)\
**Post date:** [February 12, 2024, 5:35am UTC](https://community.homey.app/t/boolean-algebra-with-logic-yes-no-variables/103782/5 "2024-02-12T05:35:43Z")

</div>

That’s how realized it currently. Thanks.  
I was just wondering if I could do it via math

---

<div class="post-metadata">

**Author:** ![DirkG](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkg/32/118897_2.png) [@DirkG](https://community.homey.app/u/DirkG)\
**Post date:** [February 12, 2024, 11:02am UTC](https://community.homey.app/t/boolean-algebra-with-logic-yes-no-variables/103782/6 "2024-02-12T11:02:48Z")

</div>

Instead of Boolean variables, you can use numerical variables that can also be used for calculations.

Example:  
– 12 windows and doors in total  
– Numerical variable  
– Closed = 0  
– Open = 1

If a status of a door/window change from close to open then calculate 1 to the numerical variable. If a status of a door/window change from open to close then subtract 1 from the numerical variable.

Numerical variable = 0 (all doors/windows are closed)  
Numerical variable = 1 (one door or window is open, 11 are closed)  
Numerical variable = 2 (two doors or windows are open, 10 are closed)  
Numerical variable = 12 (all doors and windows are open, none is closed)
