This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
How to determine if a number variable is even or odd
Demi
Member
Hi there,
I'm trying to build a flow in which Homey can determine if a better logic-variable (number, only integers) is odd or even. I tried it with a beter logic-card (math.js expression is true): math.isInteger (variable) and math.round(variable/2;0) - (variable/2) = 0. However, these expressions doesn't seem to work. Is there another expression I can use? Or is there another option to solve this "problem"?
I'm trying to build a flow in which Homey can determine if a better logic-variable (number, only integers) is odd or even. I tried it with a beter logic-card (math.js expression is true): math.isInteger (variable) and math.round(variable/2;0) - (variable/2) = 0. However, these expressions doesn't seem to work. Is there another expression I can use? Or is there another option to solve this "problem"?
Comments
http://mathjs.org/docs/reference/functions/mod.html
math.mod(2, 2) = 0 in the math.js expression is true-card. But test keeps giving a red cross.
mathjs cards only work without the `Math.`
mod(2,2) == 0