# How to set variable to value based on logic

**URL:** <https://community.homey.app/t/how-to-set-variable-to-value-based-on-logic/73039>\
**Category:** Questions & Help\
**Tags:** flow, homey-pro\
**Created:** [December 4, 2022, 10:04am UTC](https://community.homey.app/t/how-to-set-variable-to-value-based-on-logic/73039 "2022-12-04T10:04:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nagrom](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/nagrom/32/34878_2.png) [@Nagrom](https://community.homey.app/u/Nagrom)\
**Post date:** [December 4, 2022, 10:04am UTC](https://community.homey.app/t/how-to-set-variable-to-value-based-on-logic/73039/1 "2022-12-04T10:04:13Z")

</div>

I want to create a flow that sets a moisture limit variable based on the price of electricity.  
It seems the “set” logic card can only set a variable to a fixed number, not to {…calculcation…}.

What I want to do is : create a flow with a logic card that sets the variable källare\_fuktighet\_gräns to {55 + #Current price \* 10 }.

How can I do this?

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [December 4, 2022, 10:15am UTC](https://community.homey.app/t/how-to-set-variable-to-value-based-on-logic/73039/2 "2022-12-04T10:15:21Z")

</div>

The “Calculate … as …” THEN logic flow card feels sad that it exists but is not being used. 😭  
 ![Untitled-1](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/3/d30d46c6148b78054a1aa029f4b0fc30ddc1b510.jpeg)

---

<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:** [December 4, 2022, 10:20am UTC](https://community.homey.app/t/how-to-set-variable-to-value-based-on-logic/73039/3 "2022-12-04T10:20:46Z")

</div>

> [@Caseda](#):
>
> but is not being used

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

😉

Sorry for OT.

---

<div class="post-metadata">

**Author:** ![Nagrom](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/nagrom/32/34878_2.png) [@Nagrom](https://community.homey.app/u/Nagrom)\
**Post date:** [December 4, 2022, 10:39am UTC](https://community.homey.app/t/how-to-set-variable-to-value-based-on-logic/73039/4 "2022-12-04T10:39:48Z")

</div>

Thanks  
I tried the Calculate card but I think I got the curly braces wrong.  
Thanks.

One follow up question:

I have now made a test flow that has these “Then cards”:  
Calculate variable  
Send push notice with the variable value.

However it seems that these two Then cards are not executed in that particular order.  
Is that how Homey works?

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [December 4, 2022, 10:42am UTC](https://community.homey.app/t/how-to-set-variable-to-value-based-on-logic/73039/5 "2022-12-04T10:42:33Z")

</div>

Yes, that is exactly how Homey (normal) flows work, all THEN cards are activated at the same time, and can finish in any random time, so it indeed can happen that the push is already send before the calulation has finished.  
You could “fix” it in any of these 3 ways:

- Advanced flows, where you can put them _after_ each other.
- Add a 1 second delay to the push message card
- Create a second flow where you respond/trigger on the change of the calculated variable
