# Calculation of variables (Logic or better Logic)

**URL:** <https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913>\
**Category:** Questions & Help\
**Tags:** flow\
**Created:** [December 27, 2020, 5:07pm UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913 "2020-12-27T17:07:28Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [July 8, 2023, 6:30am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/24 "2023-07-08T06:30:07Z")

</div>

@Peter_Bittner  
Better logic variables have (flow) tokens.

---

<div class="post-metadata">

**Author:** ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)\
**Post date:** [July 8, 2023, 7:56am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/25 "2023-07-08T07:56:11Z")

</div>

Thanks Arie but I don’t know enough for that to help me. Are you saying I should have used the word tokens instead of tags?  
Would you be able to give me an example of how to set up a better logic variable and then use it in a flow.

---

<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:** [July 8, 2023, 9:24am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/26 "2023-07-08T09:24:21Z")

</div>

In app settings of BLL you can manage your BLL variables

 ![Screenshot_20230708-111904_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/d/0d3af243c5d33eb8d2b8dd254287e5e9be26ecb7.jpeg)

In flowcards, when you want to choose a BLL variable, it’s similar to logics variables:  
you’ll find logics variables under ‘Logic’, and Better logic variables under ‘Better Logic Library’

 ![Screenshot_20230708-110943_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/6/96b569d9b38679f8591a1c508c93e5617b13a84e.jpeg)

But search for the var name is easier I think

 ![Screenshot_20230708-111120_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/c/ac22d57b31e8038400284655e5ba41359bad9ab6.jpeg)

When you use Logics flowcards, you can’t use BLL variables and vice versa.  
Logic card

 ![Screenshot_20230708-113140_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/1/21bdbc50ea6825dac972302e10f48c7483815138.jpeg)

 ![Screenshot_20230708-112804_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/b/2bc02388abe07e010279d447d7f891687e086266.jpeg)

Better Logic card shows my BLL variables

 ![Screenshot_20230708-113518_QuickPic](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/7/774a820cae73292f991e166608d8ab9ac65d0fb4.jpeg)

 ![Screenshot_20230708-112714_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/2/828bf94c81de218790bd641a69b7f1087ee9f42b.jpeg)

---

<div class="post-metadata">

**Author:** ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)\
**Post date:** [July 9, 2023, 5:19am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/27 "2023-07-09T05:19:27Z")

</div>

Thanks very much. So this flow should work?

 ![Screenshot 2023-07-09 at 3.17.38 pm](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/a/0a1f278782ce38b36f3cbee83c6d38e9404b0df5.png)  
And I’m assuming that if you want to see the current value of a BLL variable then the only place to do this is in the BLL App?  
Edit:  
No I see that it won’t. I need brackets. I tried this:  
 ![Screenshot 2023-07-09 at 4.31.15 pm](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/4/d/4d962878445bcc86d8b95c4934b648ae0fadec54.png)  
but it still looks like thats wrong as the variable is being set to 0.

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [July 9, 2023, 2:04pm UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/28 "2023-07-09T14:04:22Z")

</div>

Use the set expression card and remove the W at the end.

---

<div class="post-metadata">

**Author:** ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)\
**Post date:** [July 9, 2023, 6:24pm UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/29 "2023-07-09T18:24:48Z")

</div>

So the double brackets {{}} is correct?

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [July 9, 2023, 6:47pm UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/30 "2023-07-09T18:47:17Z")

</div>

No, you dont need them, they will make it a Homey calculation and the calculated vvalue will be passed to the expression card. Thats not very usefull or what you want.

---

<div class="post-metadata">

**Author:** ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)\
**Post date:** [August 13, 2023, 4:01am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/31 "2023-08-13T04:01:37Z")

</div>

I am trying to set a variable to 5000+“variable\_name” using the Set card but am having no luck wether I use Better Logic Library or Logic. The 5000+ just disappears and it just sets the variable to the “variable\_name”.

I’m obviously doing something wrong.

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [August 13, 2023, 2:34pm UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/32 "2023-08-13T14:34:53Z")

</div>

Show what you are doing?

---

<div class="post-metadata">

**Author:** ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)\
**Post date:** [August 13, 2023, 9:22pm UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/33 "2023-08-13T21:22:57Z")

</div>

I want to set up a flow that will turn on devices (such as my car charger) once my solar panels are producing more power than needed to charge the battery or run the home. The maximum the battery will consume for charging is 5Kw, shown as -ve when charging and +ve when discharging. As electricity costs 34c/Kw from the grid and I only get 11c/Kw when exporting back to the grid then it is best to use that capacity if possible.

So I want to set up a flow so that when the Battery is being charged the maximum (-5000) and the Solar production is greater than 5000 + Home Consumption + “Some gap I can set” then turn on a device. I have included a picture of my variables and the flows I have developed to set the value of the variables. The values from the solar system update about every 4 secs.  
I want to set T\_nettpower to 5000 + Home Consumption + “Some gap I can set”, and then use that variable to turn on the device(s).

![Screenshot 2023-08-14 at 7.08.56 am](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/3/83321b7c72f8026cef5969486518c55293de158b.png)

 ![Screenshot 2023-08-14 at 7.08.32 am](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/2/f2dd6a9e3d50a58af6b31c40981945d772bdffba.png)

---

<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:** [August 13, 2023, 9:41pm UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/34 "2023-08-13T21:41:14Z")

</div>

When I get you right, you want to add the values of some tags, and a real value into a variable?  
Then you need someting like this

 ![Screenshot_20230813-233945_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/8/e85f430fcdc2345dac8e18b4bfbd988d880482dd.jpeg)

---

<div class="post-metadata">

**Author:** ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)\
**Post date:** [August 14, 2023, 6:54am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/35 "2023-08-14T06:54:21Z")

</div>

Thanks - simple isn’t it.

I like the idea of knowing what you suggested using for the values “netto\_energieverbruik” and “Power.In.Piek”. I was just going to add some overhead like 1Kw so the charger didn’t turn on and off every time there was a change in the home consumption, but you may have a better way.

Here is what I did.

 ![Screenshot 2023-08-14 at 5.01.38 pm](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/d/bdb9deecd7108f5b9c602aa2dc3d242495584a06.png)  
 ![Screenshot 2023-08-14 at 4.58.40 pm](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/0/d003287c2da4cbde4d1699fdb09ee10218c9a2bb.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)\
**Post date:** [April 18, 2024, 4:05am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/36 "2024-04-18T04:05:34Z")

</div>

Hi, lots of discussion using the Round function. In my Homeyscript I use the abs function to make sure the variables are treated as +ve. Can you use the abs function in a logic script? I’ve tried abs and Math.abs but neither work.

![Screenshot 2024-04-18 at 2.11.25 PM](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/a/fa1b03516a8b0aac8c50d78a444dd0dc70ffc239.png)

---

<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:** [April 18, 2024, 1:52pm UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/37 "2024-04-18T13:52:46Z")

</div>

Elaborate on ‘neither work’ please  
This works:  
 ![Screenshot from 2024-04-18 15-56-16](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/1/9/19ac50b73fbd92eae95dae5d95c8c338cd07c83d.png)

---

<div class="post-metadata">

**Author:** ![Peter\_Bittner](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_bittner/32/16698_2.png) [@Peter\_Bittner](https://community.homey.app/u/Peter_Bittner)\
**Post date:** [April 19, 2024, 2:48am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/38 "2024-04-19T02:48:43Z")

</div>

Thanks Peter. I think my problem was that as soon as it ran I checked the variable and saw that it contained the formula, but when I waited a bit it turned into the expected result. Looks like it takes a little while to actually do the calculation and return the string.

Edit: Actually, I think that’s rubbish. I’m not sure what I did wrong, but it’s working now.

---

<div class="post-metadata">

**Author:** ![Felho](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/felho/32/38916_2.png) [@Felho](https://community.homey.app/u/Felho)\
**Post date:** [May 14, 2024, 5:49am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/39 "2024-05-14T05:49:18Z")

</div>

Hi someone know why not showing logic tag data?

 ![CleanShot 2024-05-14 at 07.48.13@2x](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/0/807980de9256445c12143390d02d51b6e999ceea.png)  
how can fix this? Homey pro early 2023 last fw. 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:** [May 14, 2024, 10:49pm UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/40 "2024-05-14T22:49:12Z")

</div>

Try typing `data` in the search bar

---

<div class="post-metadata">

**Author:** ![Felho](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/felho/32/38916_2.png) [@Felho](https://community.homey.app/u/Felho)\
**Post date:** [May 15, 2024, 4:29am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/41 "2024-05-15T04:29:55Z")

</div>

the same no TAG information

 ![CleanShot 2024-05-15 at 06.29.35@2x](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/a/aab2eba89a64dab6701e69bc572866c5fbd186f7.png)

---

<div class="post-metadata">

**Author:** ![robertklep](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/robertklep/32/160628_2.png) [@robertklep](https://community.homey.app/u/robertklep)\
**Post date:** [May 15, 2024, 4:37am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/42 "2024-05-15T04:37:23Z")

</div>

You mean that the values aren’t showing up for the tags?

---

<div class="post-metadata">

**Author:** ![Felho](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/felho/32/38916_2.png) [@Felho](https://community.homey.app/u/Felho)\
**Post date:** [May 15, 2024, 5:08am UTC](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913/43 "2024-05-15T05:08:28Z")

</div>

Yes and I don’t know why

 ![CleanShot 2024-05-15 at 06.33.42@2x](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/7/a/7a668489f927104376d4b2084092cdbdd2a1dcbc.jpeg)

it is full print screen all Devices information

[Previous page](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913.md?page=1)

[Next page](https://community.homey.app/t/calculation-of-variables-logic-or-better-logic/39913.md?page=3)
