# Math in logic

**URL:** <https://community.homey.app/t/math-in-logic/124601>\
**Category:** Questions & Help\
**Created:** [December 18, 2024, 7:46pm UTC](https://community.homey.app/t/math-in-logic/124601 "2024-12-18T19:46:42Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fredrik3](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fredrik3/32/81530_2.png) [@Fredrik3](https://community.homey.app/u/Fredrik3)\
**Post date:** [December 18, 2024, 7:46pm UTC](https://community.homey.app/t/math-in-logic/124601/1 "2024-12-18T19:46:42Z")

</div>

Trying to calulcate total effekt from my floor heating.

but i only get error, and no value on the variable

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/3/a3b3236459bf1dfd6827a3c46e2106cda485d2ac.png)

What is wrong?  
thanks

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [December 18, 2024, 8:03pm UTC](https://community.homey.app/t/math-in-logic/124601/2 "2024-12-18T20:03:46Z")

</div>

Should work. Please share the error message?

---

<div class="post-metadata">

**Author:** ![Fredrik3](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fredrik3/32/81530_2.png) [@Fredrik3](https://community.homey.app/u/Fredrik3)\
**Post date:** [December 19, 2024, 4:12am UTC](https://community.homey.app/t/math-in-logic/124601/3 "2024-12-19T04:12:55Z")

</div>

Than you for the response.

 ![1000012742](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/d/1d8c1a27edb91f356159ccba3c5bfeea0ca69953.jpeg)  
 ![1000012741](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/0/8025af1d4b5b6de74cce6107fcddaa377a15f053.jpeg)

Right now the calculation will bee 0+0+0+0+0 becouse the heated floor have no effect on them. Guess many thats not possible ?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [December 19, 2024, 6:08am UTC](https://community.homey.app/t/math-in-logic/124601/4 "2024-12-19T06:08:01Z")

</div>

No, now it seems to be `NaN + 0 + 0 + 0 + 0 + 0`  
(NaN = Not a Number)  
The top variable seems to be empty. Make sure the numeric variables have a value, even a zero is valid.  
When one of them hasn’t got a value, the calculation can’t be made.

---

<div class="post-metadata">

**Author:** ![Fredrik3](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fredrik3/32/81530_2.png) [@Fredrik3](https://community.homey.app/u/Fredrik3)\
**Post date:** [December 19, 2024, 6:38am UTC](https://community.homey.app/t/math-in-logic/124601/5 "2024-12-19T06:38:15Z")

</div>

The first one is the output, i try to change it to a number, but everytime the flow runs it just get back to NaN.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [December 19, 2024, 6:40am UTC](https://community.homey.app/t/math-in-logic/124601/6 "2024-12-19T06:40:17Z")

</div>

Oww my bad 😬  
Can you check if all variables actually _ **do** _ have a value when the calc is done?

You could add a notification card with all these variables added to it, to be able to see what’s happening.

Oh, try adding a 1s delay in between the calc and the ‘forbruk’ card.  
Sometimes calculations can take just a bit more time. Maybe the calculation simply isn’t finished yet.

---

<div class="post-metadata">

**Author:** ![Fredrik3](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fredrik3/32/81530_2.png) [@Fredrik3](https://community.homey.app/u/Fredrik3)\
**Post date:** [December 19, 2024, 7:04am UTC](https://community.homey.app/t/math-in-logic/124601/7 "2024-12-19T07:04:41Z")

</div>

Tryed this, but it still makes the output go NaN?

 ![1000012743](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/a/ba551d26db549d58cc1266c09169ac7332d73f77.jpeg)

Well enyways, just downloaded the app better logic, looks like that works great. So thank you for the help

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [December 19, 2024, 9:32am UTC](https://community.homey.app/t/math-in-logic/124601/8 "2024-12-19T09:32:29Z")

</div>

It doesn’t hurt to assign 0 to the variable where and when you created it. That might do the trick.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [December 19, 2024, 10:55pm UTC](https://community.homey.app/t/math-in-logic/124601/9 "2024-12-19T22:55:24Z")

</div>

Hmmmm, good point, but I can’t create numeric vars without an initial value at both web+phone app:

> ![1000039059](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/c/7/c722e57a71e9d5199123a55e291b04419bbe2717.jpeg)

> ![1000039061](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/c/1cf01f4a271d6f142598b96255a28581b76e7a04.jpeg)

But that made me think of this:  
@Fredrik3  
Probably your variable got ‘stuck’ without a value, or something non-numeric somehow.  
To possibly solve it:  
My guess would be to remove that variable and then create a new one.

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [December 19, 2024, 10:59pm UTC](https://community.homey.app/t/math-in-logic/124601/10 "2024-12-19T22:59:53Z")

</div>

> [@Peter\_Kawa](#):
>
> Hmmmm, good point, but I can’t create numeric vars without an initial value at both web+phone app:

Me neighther 😁.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [December 19, 2024, 11:04pm UTC](https://community.homey.app/t/math-in-logic/124601/11 "2024-12-19T23:04:33Z")

</div>

Haha OK. I read your remark as “you’d add at least a 0 as initial value”.

But how should assigning a 0 as initial value give different results than, say, 19?  
Just trying to get your point😊

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [December 19, 2024, 11:17pm UTC](https://community.homey.app/t/math-in-logic/124601/12 "2024-12-19T23:17:42Z")

</div>

I was thinking that adding a number to a non defined variable might result in an error. As a test I suggested to initiate the variable with the value zero, which does not ruin the calculation, of course. But would exclude a possible error cause. At the time of writing I was not aware one cannot create a number variable without a value.

EDIT: I see you point. Any value will be ok, as this value is overwritten by the formula, in this case.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [December 19, 2024, 11:20pm UTC](https://community.homey.app/t/math-in-logic/124601/13 "2024-12-19T23:20:28Z")

</div>

Check!

---

<div class="post-metadata">

**Author:** ![Fredrik3](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fredrik3/32/81530_2.png) [@Fredrik3](https://community.homey.app/u/Fredrik3)\
**Post date:** [December 20, 2024, 11:30am UTC](https://community.homey.app/t/math-in-logic/124601/14 "2024-12-20T11:30:33Z")

</div>

Thanks, made the variable again and that made the trick. Thanks for all help
