bartbutenaers / node-red-contrib-calc

A Node-Red node to perform basic mathematical operations
Apache License 2.0
5 stars 1 forks source link

Decimal places #4

Closed PierreScerri closed 4 years ago

PierreScerri commented 4 years ago

The 'Sum' function randomly throws a result with several decimal places. The node is being supplied with 2 values in an array from a 'Join' node. Each value has 1 decimal place.

Screenshot 2020-06-27 at 11 21 42

bartbutenaers commented 4 years ago

Hi Pierre, Sorry for the delay! Not sure at the moment how to handle this: add a input field on the config screen perhaps, where you can specify the number of decimal places? Or did you have anything else in mind? Thanks for reporting this issue!

PierreScerri commented 4 years ago

My question was why is the sum of 7.9 & -3.3 = 4.60000000005? This messes up the display in Home Assistant and is also incorrect. Your idea of specifying the number of decimal places is interesting.

bartbutenaers commented 4 years ago

I have added a new checkbox to the config screen:

image

Would be nice if you could do some testing before I publish it on NPM. You can install it directly from this Github account like this (in your Node-RED folder):

npm install bartbutenaers/node-red-contrib-calc
PierreScerri commented 4 years ago

Thank you for your efforts. I am running Node-red as an addon in Hassio. Added the package in the config and restarted the addon. The log says that:

[10:09:49] INFO: Starting installation of custom NPM/Node-RED packages...
+ node-red-contrib-calc@1.0.2
added 1 package from 1 contributor and audited 959 packages in 52.578s
29 packages are looking for funding
  run `npm fund` for details
found 1 low severity vulnerability
  run `npm audit fix` to fix them, or `npm audit` for details

I think that it installed fine.

In Node-red, it still shows as 1.0.1. Don't know how to access the new version.

bartbutenaers commented 4 years ago

I assume you haven't installed it inside your Node-RED directory. Now you have somewhere the new version, but Node-RED still uses the old one... You should execute the install command inside the node-RED folder (e.g. cd $HOME/.node-red). Hopefully it works then, otherwise I just need to publish it to npm tonight ...

PierreScerri commented 4 years ago

Well the add-on should install it in its place I would imagine.

This is included in the Node-red addon config:

npm_packages:
  - bartbutenaers/node-red-contrib-calc

Had a look in the node-red folder in my config and the old version is there.

Don't know where else to look.

bartbutenaers commented 4 years ago

Hey Pierre, I have published this feature on NPM in version 1.0.2 Please reopen this issue if the rounding feature doesn't work as expected. Bart

PierreScerri commented 4 years ago

Thank you for efforts.

Unfortunately, as I've said before, I cannot install from the terminal as Hassio does not recognise the npm command. Tried installing from the add-on and it still reports 1.0.1.

So I can't test the new version.

bartbutenaers commented 4 years ago

Seems flows.nodered.org doesn't sync automatically anymore with npm. I have requested a manual refresh, and now it is updated to 1.0.3

PierreScerri commented 4 years ago

Got it. It works.

Thank you.