# \[APP\]\[Pro\] Home Assistant - Community App

**URL:** <https://community.homey.app/t/app-pro-home-assistant-community-app/71477>\
**Category:** Apps\
**Tags:** app, tools, homey-pro, home-assistant\
**Created:** [October 31, 2022, 8:25pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477 "2022-10-31T20:25:26Z")\
**Posts on this page:** 20\
**Page:** 48

<div class="post-metadata">

**Author:** ![Jan\_Peeters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_peeters/32/86660_2.png) [@Jan\_Peeters](https://community.homey.app/u/Jan_Peeters)\
**Post date:** [November 30, 2023, 11:51am UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/949 "2023-11-30T11:51:25Z")

</div>

Well… not sure.

I used the syntax:  
_**(value) =\> { return Math.round(parseFloat(value), 3); }**_  
On both capabilities:

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/b/fb5876a4da65446aaefc939444353196b0e44b66.png)  
The result is still a value without decimals:  
 ![Afbeelding van WhatsApp op 2023-11-30 om 12.50.25_e861d909](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/e/f/ef46b92caa294a5b7cb24672e950ca8b424b6885.jpeg)

… where it should have been with exact three decimals !?

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [November 30, 2023, 12:53pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/950 "2023-11-30T12:53:17Z")

</div>

Then Homeys Math,js version doesn’t support these decimal parameter.  
Are there errors in the log?

Best would be to use the \*1000 /1000 workaround.

---

<div class="post-metadata">

**Author:** ![Jan\_Peeters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_peeters/32/86660_2.png) [@Jan\_Peeters](https://community.homey.app/u/Jan_Peeters)\
**Post date:** [November 30, 2023, 1:03pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/951 "2023-11-30T13:03:36Z")

</div>

> [@RonnyW](#):
>
> Then Homeys Math,js version doesn’t support these decimal parameter.  
> Are there errors in the log?
> 
> Best would be to use the \*1000 /1000 workaround.

Owkey, what would the syntax be like?  
**(value) =\> { return Math.round(parseFloat(value) _1000 \* 1000)/1000, 3; }_**

Feels like it isn’t correct. Some symbols/spaces are missing?  
I do believe I tried this yesterday.

Where can information about “Homeys Math.js version” be found?

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [November 30, 2023, 2:01pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/952 "2023-11-30T14:01:03Z")

</div>

> [@Jan\_Peeters](#):
>
> (value) =\> { return Math.round(parseFloat(value) _1000 \* 1000)/1000, 3; }_

This should work:

```auto
(value) => { return Math.round(parseFloat(value) * 1000 ) / 1000; }

```

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [November 30, 2023, 2:20pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/953 "2023-11-30T14:20:12Z")

</div>

New **test version 1.5.11** :

- Fixed ‘Value of capability changed’ flow card for compound devices.

---

<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:** [November 30, 2023, 11:50pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/956 "2023-11-30T23:50:47Z")

</div>

> [@RonnyW](#):
>
> Thanks, I wasn’t sure if it already works on Homey based on the NodeJS version.

My bad, my bad…  
I have sinned, because _Thy Should Not Assume_…  
While I _assumed_ a mathjs calculation would function the same wherever you use it.

But as you and @Jan_Peeters found out, and now me also by testing, it doesn’t work in the converter field…  
But Ronny, it does work @ Homey though  
I think the comma and the figure trailing it, gets misinterpreted, or ignored by the converter function ha-\>homey

> ![Screenshot_20231130-230249_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/9/6/96e8838bea77908097d4b5be2cd5f22a5d8480c6.jpeg)

> ![Screenshot_20231130-230455_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/2/d23362357ee4a4b0420e7c8e252b67475adac8d9.jpeg)

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [December 1, 2023, 6:19am UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/957 "2023-12-01T06:19:13Z")

</div>

I think HomeyScript is using a NodeJS module for calculations that’s perhaps newer than Homeys NodeJS.  
The convertes is only a JavaScript function executed by the app (as it would be directly codes in the app).  
I can ask on Slack what’s the reason behind.

---

<div class="post-metadata">

**Author:** ![Jan\_Peeters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_peeters/32/86660_2.png) [@Jan\_Peeters](https://community.homey.app/u/Jan_Peeters)\
**Post date:** [December 1, 2023, 6:38am UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/958 "2023-12-01T06:38:19Z")

</div>

> [@RonnyW](#):
>
> _Thy Should Not Assume_ …

… He that is without sin among you, let him first cast a stone…

😉

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [December 1, 2023, 10:11am UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/959 "2023-12-01T10:11:34Z")

</div>

@Jan_Peeters @Peter_Kawa

I got the information from our NodeJS guru Robert 🙂

The Homey flows are using Math.js module.  
The Homey core uses NodeJS standard Math functions:

> **[Math - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math?retiredLocale=de)**
>
> The Math namespace object contains static properties and methods for mathematical constants and functions.

So if you use the Math.round(…), it’s the NodeJS version, not Math.js.  
Math.js is not included in the app.

---

<div class="post-metadata">

**Author:** ![Jan\_Peeters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_peeters/32/86660_2.png) [@Jan\_Peeters](https://community.homey.app/u/Jan_Peeters)\
**Post date:** [December 1, 2023, 10:36am UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/960 "2023-12-01T10:36:39Z")

</div>

Thank you Ronny.  
So , if i understand correctly, the NodeJS is only able to round to the closed integer.  
Decimals are not included?

This is indeed close to what I experienced. I was only able to either have any uncontrolable number of decimals or . The second option would have been the integer.

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [December 1, 2023, 10:44am UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/961 "2023-12-01T10:44:43Z")

</div>

Yes, only round to integer.  
So developers are using the \*10x /10x workaround to get the wished decimals.

Have you tested this yet?

```auto
(value) => { return Math.round(parseFloat(value) * 1000 ) / 1000; }

```

---

<div class="post-metadata">

**Author:** ![Jan\_Peeters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_peeters/32/86660_2.png) [@Jan\_Peeters](https://community.homey.app/u/Jan_Peeters)\
**Post date:** [December 1, 2023, 12:58pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/962 "2023-12-01T12:58:34Z")

</div>

> [@RonnyW](#):
>
> 10x /10x

It results in just any number of decimals; i.e. the same number of decimals as is defined in the HA entity.

---

<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 1, 2023, 3:48pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/963 "2023-12-01T15:48:48Z")

</div>

For me it works  
Are you sure you used this converter code (like Ronny posted)?

(value) =\> { return Math.round(parseFloat(value) \* 1000 ) / 1000; }

* * *

Here’s my test, maybe it helps you out:

- The 5-digit HA entity:

> ![Screenshot_20231201-164255_Home Assistant](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/5/b5ee91085ace299f3e1bd5254aaf97704f4bb4ae.jpeg)

- The Homey capability with HA\>Homey conversion:

> ![Screenshot_20231201-155251_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/f/5f59b80726414883648f5d5d64a6e553d4e8b961.jpeg)

- The Homey value, rounded to 3 digits:

> ![Screenshot_20231201-155214_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/9/59650cb59329c854657b8323aa27cfbcb681deeb.jpeg)

- Detail: you can see the HA entity is a 5-digit figure:

> ![Screenshot_20231201-155341_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/e/be5daf8b6a0b664dfd14378fc36e63a9afb4cf59.jpeg)

---

<div class="post-metadata">

**Author:** ![Jan\_Peeters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_peeters/32/86660_2.png) [@Jan\_Peeters](https://community.homey.app/u/Jan_Peeters)\
**Post date:** [December 1, 2023, 8:37pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/964 "2023-12-01T20:37:08Z")

</div>

> [@Peter\_Kawa](#):
>
> (value) =\> { return Math.round(parseFloat(value) \* 1000 ) / 1000; }

I guess not… :-/

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

 ![Afbeelding van WhatsApp op 2023-12-01 om 21.36.27_2e50d27e](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/4/f439e84ad339662b670dd54153f2bffdcc6cb430.jpeg)

 ![Afbeelding van WhatsApp op 2023-12-01 om 21.36.27_53c279ef](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/4/24d8fb6701e0e85c52d2c609c12bac42ed072e69.jpeg)

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [December 1, 2023, 8:43pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/965 "2023-12-01T20:43:25Z")

</div>

Please check the capability value at [https://tools.developer.homey.app/tools/devices](https://tools.developer.homey.app/tools/devices)  
I think Homey (better: the mobile app) is cutting the decimals to fit the data into sensor tile.

---

<div class="post-metadata">

**Author:** ![Jan\_Peeters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_peeters/32/86660_2.png) [@Jan\_Peeters](https://community.homey.app/u/Jan_Peeters)\
**Post date:** [December 1, 2023, 8:50pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/966 "2023-12-01T20:50:11Z")

</div>

An Enigma … 2digits out of 3…  
I’ll live 🙂

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

 ![Afbeelding van WhatsApp op 2023-12-01 om 21.50.30_40097c98](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/0/3/03e691602a2bbc40ea511dc3087762645064adf1.jpeg)  
t

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [December 1, 2023, 9:07pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/967 "2023-12-01T21:07:19Z")

</div>

You are using meter\_power, and that’s defined with 2 decimals.

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

> **[Tutorial: Device Capabilities - Homey Apps SDK v3](https://apps-sdk-v3.developer.homey.app/tutorial-device-capabilities.html)**

If you use standard capabilities, they are predefined with a unit/decimals/title etc.  
If you use measure\_numeric as generic capability, you can use the converter to set your custom number format.

---

<div class="post-metadata">

**Author:** ![Jan\_Peeters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_peeters/32/86660_2.png) [@Jan\_Peeters](https://community.homey.app/u/Jan_Peeters)\
**Post date:** [December 1, 2023, 9:28pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/968 "2023-12-01T21:28:57Z")

</div>

> [@RonnyW](#):
>
> \_numeric as generic capa

🤯 🥹

---

<div class="post-metadata">

**Author:** ![RonnyW](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/ronnyw/32/10879_2.png) [@RonnyW](https://community.homey.app/u/RonnyW)\
**Post date:** [December 1, 2023, 9:40pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/969 "2023-12-01T21:40:08Z")

</div>

measure\_numeric is a custom app capability that was added to import entity values that don’t fit into standard capabilities.

But keep in mind:  
If you want to use capabilities in other apps or energy dashboard, you need standard o es like measure\_power.  
A custom capability is not recognized in such cases.

---

<div class="post-metadata">

**Author:** ![Jan\_Peeters](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jan_peeters/32/86660_2.png) [@Jan\_Peeters](https://community.homey.app/u/Jan_Peeters)\
**Post date:** [December 2, 2023, 3:43pm UTC](https://community.homey.app/t/app-pro-home-assistant-community-app/71477/970 "2023-12-02T15:43:23Z")

</div>

# [Xiaomi Aqara WXKG12LM Smart Wireless Mini Switch with Gyroscope](https://community.home-assistant.io/t/deconz-xiaomi-aqara-wxkg12lm-smart-wireless-mini-switch-with-gyroscope/266231)

Hi, I have the above Mini Switch integrated in HA and from HA → Homey.  
In Homey, the button state is integrated with the capability “action”. I can see the different actions I use in Homey: “single”, “double” and “long”. Now I am having a hard time to configure these different actions. It seems as if this has to be done by means of “capabilities”, but none of the above actions are available in the drop down menu. How can I add them?

 ![Afbeelding van WhatsApp op 2023-12-02 om 16.42.19_52c855d9](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/f/2f54cc08b9a986e474f8d1e1b6b53c479cd96ad5.jpeg)

 ![Afbeelding van WhatsApp op 2023-12-02 om 16.42.19_0d739f67](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/0/f07d878081040ad4dec76688e00d2ced189220c9.jpeg)

remote\_button\_short\_press:  
name: Single press  
action: {}  
remote\_button\_double\_press:  
name: Double press  
action: {}  
remote\_button\_long\_press:  
name: Hold  
action: {}

![image](https://us1.discourse-cdn.com/flex025/uploads/athom/optimized/3X/8/b/8b8e845f8ec423213719bac074b7e29364b3ed24_2_690x50.png)

[Previous page](https://community.homey.app/t/app-pro-home-assistant-community-app/71477.md?page=47)

[Next page](https://community.homey.app/t/app-pro-home-assistant-community-app/71477.md?page=49)
