# Calculating Energy Costs - mathjs with variables

**URL:** <https://community.homey.app/t/calculating-energy-costs-mathjs-with-variables/46881>\
**Category:** Questions & Help\
**Created:** [April 30, 2021, 5:51am UTC](https://community.homey.app/t/calculating-energy-costs-mathjs-with-variables/46881 "2021-04-30T05:51:51Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Metatron](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/metatron/32/40136_2.png) [@Metatron](https://community.homey.app/u/Metatron)\
**Post date:** [April 30, 2021, 5:51am UTC](https://community.homey.app/t/calculating-energy-costs-mathjs-with-variables/46881/1 "2021-04-30T05:51:51Z")

</div>

Hello,

I am trying to calculate the costs for one time washing with my washing machine.  
I have no problem to detect start and and, the flows are available.  
Für the start, I can set a logic or better logic numerical variable with the meter reading.  
However for both, logic and better logic, I don’t succeed defining the calculation. I don’t see, how to calculate with a variable. They don’t show up at the tags, also $variable$ and the like does not work.  
I have searched the forum - found nothing.  
Also, how do I use the result in a text message to push or simple log? I only see Boolean variables to chose from?  
Nay help would be appreciated!  
(Please not only screenshots, which don’t show me how to get this!)  
Regards, Tomte

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [April 30, 2021, 10:14am UTC](https://community.homey.app/t/calculating-energy-costs-mathjs-with-variables/46881/2 "2021-04-30T10:14:47Z")

</div>

> [@Getting Started - Logic variables](https://community.homey.app/t/getting-started-logic-variables/20132):
>
> Hi everyone, in this tutorial I will tell you about logic variables and you will learn: how to create a variable the different kind of variables and; their properties and limitations some uses cases of the different types First, let’s take a look at what Athom gave us to work with, shall we? In your app, go to the ‘more’ tab and hit ‘logic’. I already have some variables in my app, so my screen looks like this: You’ll notice I made a blue mark on the printscreen, highligh…

You did non find this?

---

<div class="post-metadata">

**Author:** ![Metatron](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/metatron/32/40136_2.png) [@Metatron](https://community.homey.app/u/Metatron)\
**Post date:** [April 30, 2021, 2:40pm UTC](https://community.homey.app/t/calculating-energy-costs-mathjs-with-variables/46881/3 "2021-04-30T14:40:38Z")

</div>

Hello Jan,

Thank you for your reply. Yes, I did read this posting. I generated the variables on my mobile phone, while programming on my PC. The variables did not appear as tags, which was very confusing to me. Now, today, they show up! This means, there is a significant time lag between generation of the variables, ab update of the tag list?!?  
Let’s see how far I get now!  
Thanks again, Metatron

---

<div class="post-metadata">

**Author:** ![Rocodamelshekima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rocodamelshekima/32/8209_2.png) [@Rocodamelshekima](https://community.homey.app/u/Rocodamelshekima)\
**Post date:** [April 30, 2021, 3:04pm UTC](https://community.homey.app/t/calculating-energy-costs-mathjs-with-variables/46881/4 "2021-04-30T15:04:40Z")

</div>

> [@Metatron](#):
>
> I have searched the forum - found nothing.

Someone made [some really nice posts](https://community.homey.app/t/get-a-notification-when-the-washingmachine-is-ready/9372) about this .

> [@Metatron](#):
>
> (Please not only screenshots, which don’t show me how to get this!)

It’s more then that!

---

<div class="post-metadata">

**Author:** ![Metatron](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/metatron/32/40136_2.png) [@Metatron](https://community.homey.app/u/Metatron)\
**Post date:** [April 30, 2021, 4:32pm UTC](https://community.homey.app/t/calculating-energy-costs-mathjs-with-variables/46881/5 "2021-04-30T16:32:29Z")

</div>

Hello,

thank you, I found this before and followed this. It is working fine.  
Then I wanted to extend it with cost calculation and encounterd the problem described above.

Metatron

---

<div class="post-metadata">

**Author:** ![Rocodamelshekima](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rocodamelshekima/32/8209_2.png) [@Rocodamelshekima](https://community.homey.app/u/Rocodamelshekima)\
**Post date:** [April 30, 2021, 5:45pm UTC](https://community.homey.app/t/calculating-energy-costs-mathjs-with-variables/46881/6 "2021-04-30T17:45:30Z")

</div>

So reading [this post](https://community.homey.app/t/get-a-notification-when-the-washingmachine-is-ready/9372/6) only gives u boolean variables?  
And sending a txt message with a Better Logic variable don’t work for u?  
One of the lines is: “Make an extra variable and make it a number variable. In my case i called it “KwHtarief”.”  
Where do u see boolean variables?

---

<div class="post-metadata">

**Author:** ![Metatron](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/metatron/32/40136_2.png) [@Metatron](https://community.homey.app/u/Metatron)\
**Post date:** [May 1, 2021, 1:30pm UTC](https://community.homey.app/t/calculating-energy-costs-mathjs-with-variables/46881/7 "2021-05-01T13:30:04Z")

</div>

Hello,

thanks again for your reply. So far, I had only managed the notification for the end of the washing machine. After that, I stopped for a couple of days. So, I only had some boolean variables to some day. Then I started to do the cost calculation thing one evening. So these variables were new and did not show up as tags. I was very confused. But all there was, there was a significant time lag, between the definition of the variables, and the appearance as tags. The next day, all variables showed up. This is/was true for both, logic and better logic, but I don’t know why.  
Now, being aware of this, I will be careful and patient.  
All fine, thanks!  
Regards, Metatron

---

<div class="post-metadata">

**Author:** ![JPe4619](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jpe4619/32/9017_2.png) [@JPe4619](https://community.homey.app/u/JPe4619)\
**Post date:** [May 1, 2021, 4:48pm UTC](https://community.homey.app/t/calculating-energy-costs-mathjs-with-variables/46881/8 "2021-05-01T16:48:32Z")

</div>

Probably you have to refresh pages to see the new variables, normally there is no delay.
