# I like to calculate the dim value of energie socket

**URL:** <https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679>\
**Category:** Automation\
**Created:** [January 2, 2024, 12:17am UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679 "2024-01-02T00:17:21Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![MaNi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mani/32/79105_2.png) [@MaNi](https://community.homey.app/u/MaNi)\
**Post date:** [January 2, 2024, 12:17am UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/1 "2024-01-02T00:17:21Z")

</div>

This seems easy but no. I can trigger a flow when the power changes. Then use a logic funtion to do the calculation for the dim factor and put it in a tag (variabele).  
I use (3600 / current power) \* 100 where 3600 is the max power of the energie socket (16A). The only logic function to calculate something puts it in a text tag. But the dim function needs a integer. Can’t find a function to calulate something and put it in a integer tag. How to do that?

---

<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:** [January 2, 2024, 6:09am UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/2 "2024-01-02T06:09:46Z")

</div>

There is a THEN logic card “Calculate number variable as value”.

---

<div class="post-metadata">

**Author:** ![FKey](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/fkey/32/14793_2.png) [@FKey](https://community.homey.app/u/FKey)\
**Post date:** [January 2, 2024, 7:54am UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/3 "2024-01-02T07:54:54Z")

</div>

> [@MaNi](#):
>
> Can’t find a function to calulate something and put it in a integer tag

The [better logic app](https://homey.app/en-us/app/net.i-dev.betterlogic/Better-Logic-Library/) has much more functionality. It also allows you to round numbers to a specified number of digits.

---

<div class="post-metadata">

**Author:** ![DirkH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkh/32/78952_2.png) [@DirkH](https://community.homey.app/u/DirkH)\
**Post date:** [January 2, 2024, 12:16pm UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/4 "2024-01-02T12:16:55Z")

</div>

Hi @MaNi ,  
the standard logic calulation needs the formular in string format, but the result is a number.

But you need to start and end the formular with double braces **{{** and **}}**.  
Probably @FKey is right and you better use something like _BetterLogic_ or _CustomLogic_

But it should work well with standard logic

---

<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:** [January 2, 2024, 12:58pm UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/5 "2024-01-02T12:58:04Z")

</div>

The regular calculate logic flow card has been able to that for a long time already too, no need for better logics for such things.  
`{{ round(5.423123, 2) }}` gives `5.42` just fine.

EDIT:  
Or for the OP in the regular logic card:  
`{{ round(3600 / current power, 2) }}`

Beware of the dim function being in decimal percentage so 0% - 100% = 0.00 - 1.00

---

<div class="post-metadata">

**Author:** ![Rrrr](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rrrr/32/629_2.png) [@Rrrr](https://community.homey.app/u/Rrrr)\
**Post date:** [January 2, 2024, 1:03pm UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/6 "2024-01-02T13:03:10Z")

</div>

> [@MaNi](#):
>
> (3600 / current power) \* 100

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/5/9558abde1b2158178a2c76bb6e704f07bbc8123a.png)

---

<div class="post-metadata">

**Author:** ![MaNi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mani/32/79105_2.png) [@MaNi](https://community.homey.app/u/MaNi)\
**Post date:** [January 2, 2024, 9:38pm UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/7 "2024-01-02T21:38:25Z")

</div>

Aha, I see that the advanced flow has much more items then the normal. I was making flows on my tablet and there are no advanced flow there.

Wil give it a go with the browser

---

<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:** [January 2, 2024, 9:50pm UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/8 "2024-01-02T21:50:30Z")

</div>

> [@Rmb](#):
>
> There is a THEN logic card “Calculate number variable as value”.

So you did not find the card?

---

<div class="post-metadata">

**Author:** ![MaNi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mani/32/79105_2.png) [@MaNi](https://community.homey.app/u/MaNi)\
**Post date:** [January 2, 2024, 10:27pm UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/9 "2024-01-02T22:27:47Z")

</div>

the problem was something completly else. I used Round instead of round. And it stumbled on the capital R.  
Another day another lession

---

<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:** [January 2, 2024, 11:42pm UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/10 "2024-01-02T23:42:07Z")

</div>

> [@MaNi](#):
>
> Can’t find a function to calulate something and put it in a integer tag. How to do that?

This was your question, wasn’t it?

---

<div class="post-metadata">

**Author:** ![DirkH](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/dirkh/32/78952_2.png) [@DirkH](https://community.homey.app/u/DirkH)\
**Post date:** [January 3, 2024, 11:42am UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/11 "2024-01-03T11:42:32Z")

</div>

> [@MaNi](#):
>
> I used Round instead of round. And it stumbled on the capital R.

So why didn’t you tell us your problem? I checked again. You gave us a formula, but there was no **round()** in that formula. Yes you wrote _integer_, but _integer_ instead of _text_ .  
It is easier to help, when one knows the real issue.

---

<div class="post-metadata">

**Author:** ![MaNi](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/mani/32/79105_2.png) [@MaNi](https://community.homey.app/u/MaNi)\
**Post date:** [January 3, 2024, 1:57pm UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/12 "2024-01-03T13:57:07Z")

</div>

I did not use a round in the initial formula.

I used (3600 / current power) \* 100

That gave me a value higher then 1 so the ring was always 100%

I thought the logic formula I used was not the right one for the job and was looking for something better.

@Caseda gave me the hint that it worked between 0 and 1 and not 0 to 100 as I thought. That explained that the ring was always on.

So I used his formula but used a capital R by Round. It was still not working.

Eventually when I made it all lower case it worked.

So everyone contributed to the solution and you were right, it works with standard logic. The problem was not the formula and later the problem became the capital R.

U now use this and it works like a charm.  
And calling a Variabele ‘number/nummer’ by the Homey team made me _think_ it was a Integer. But is was a float

![Rand dimmen](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/e/9e1baeb7b246b0d34e5d1039155392b96578f22f.jpeg)

---

<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:** [January 3, 2024, 2:21pm UTC](https://community.homey.app/t/i-like-to-calculate-the-dim-value-of-energie-socket/99679/13 "2024-01-03T14:21:41Z")

</div>

Ok, maybe next time you show your cards and flow from the beginning, for better understanding your problem 😁
