[APP][Pro] Home Assistant - Community App

Well… not sure.

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


The result is still a value without decimals:

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

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?

This should work:

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

New test version 1.5.11:

  • Fixed ‘Value of capability changed’ flow card for compound devices.
1 Like

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

1 Like

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.

1 Like

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

:wink:

1 Like

@Jan_Peeters @Peter_Kawa

I got the information from our NodeJS guru Robert :slight_smile:

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

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

3 Likes

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.

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

Have you tested this yet?

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

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

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:

  • The Homey capability with HA>Homey conversion:

  • The Homey value, rounded to 3 digits:

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

2 Likes

I guess not… :-/

Please check the capability value at 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.

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


t

You are using meter_power, and that’s defined with 2 decimals.

grafik

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.

:exploding_head: :face_holding_back_tears:

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.

Xiaomi Aqara WXKG12LM Smart Wireless Mini Switch with Gyroscope

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?

remote_button_short_press:
name: Single press
action: {}
remote_button_double_press:
name: Double press
action: {}
remote_button_long_press:
name: Hold
action: {}