Supergiovane / node-red-contrib-boolean-logic-ultimate

Enhanced boolean logic with persistent values after reboot and more
https://www.youtube.com/watch?v=sYc6L5QQrTw&list=PL9Yh1bjbLAYoRH4IyQB7EL5srHAihiKpy
MIT License
31 stars 4 forks source link

math ultimate Node returns SUM instead of selected method for SUBSTRACT values #43

Closed VanillaFord closed 7 months ago

VanillaFord commented 7 months ago

When selecting the Substract method, the math ultimate node reports using the SUM method instead. In addition, the returned payload is the SUM of all absolute values of the msg.payloads going into the node and not the substract value of all msg.payloads going in.

See screenshot: image

in that example, the values with three different topics are send into the node, which is configured to use substract method. From the debug Nodes:

Supergiovane commented 7 months ago

Hi I’ll take a look tomorrow morning…

Supergiovane commented 7 months ago

Hi

from math calculator: (-1244.50) - (+1133.46) - (-2417.00) = +39.04

You're assuming (right assumption), that the first topic the node receives is -1244.50. Currently, the "subtract" function deals with the numbers like this instead: - (-1244.50) - (+1133.46) - (-2417.00), so the -1244.50 becomes +1244.50.

I could assume that the first topic received, is the number to start subtracting for. Your're right. I'll publish a fixed version asap.

Supergiovane commented 7 months ago

Hi Should be fixed. V. 1.1.4 is out.

VanillaFord commented 7 months ago

Hi @Supergiovane

thanks for your prompt response and support. Unfortunately this bug is not fixed for me: image

The "correct" value from a calculator is +18, here.

I could assume that the first topic received, is the number to start subtracting for.

No, I was not assuming that. The order of appearance - as well as the number of measures/topics - is not assumed for....as NR is event based, any topic could arrive at any time. However, in my example/flow the number is fixed (3). The node should (re-)calc with every incoming msg using any number of available measures/topic at that time. If helpfull, maybe make the number of measures (optionally) fixed so if not all expected/configured topics did arrive at least once, the node would not output a wrong value?

VanillaFord commented 7 months ago

...here is another example: image ...the correct/expected value would be: 2062.4 = (-17.1) - (0) - (-2079.5)

Supergiovane commented 7 months ago

Hi yes, i could do that, but the problem still persist. Given all 3 topics, what number should the calculation start with? With "sum" and "multiply", there's no issues, but with "divide", what number should i take first?

(-1244.50) - (+1133.46) - (-2417.00) is not equals to, for example, (+1133.46) - (-2417.00) - (-1244.50)

VanillaFord commented 7 months ago

Ugh, I see...yes, you are right, the calculation is order sensitive...I totally did miss that. :-( I apologize for not taking this into account. In my Case obove it should be: ((GRID_Power - House_Power) - CPs_Power)

But then, substraction method for this node can only be valid, if ordering of the topics is given, as well as numbering (like having three inputs for 3 measurements in the node and give order 1,2,3) or order of topic names.

That makes it very complex to implement, is it not?

Also: it apears, that in V1.1.5, the node does not change payload (and average) after the first calc, even if fed with new values from each topic (in my flow the input msgs have a cadence of approx 10ms). It does output the same response with every input msg...and does a re-calc after receiving a msg.reset, though. This is true, even when selecting SUM or multiply operation instead of substract Should I create a separate issue for that? It definitely worked with previous version

Supergiovane commented 7 months ago

Hi i'll take a look at the average. About the "subtract", i can put another property in the config window. Here you can write the topic name that should be taken into account, as the first number. You can set it to "GRID_Power", for example. Could this do the trick?

Supergiovane commented 7 months ago

In the meantime, i've fixed the "average".

Supergiovane commented 7 months ago

Please try the 1.1.6. You must now set a msg.topic to start subtracting from.

VanillaFord commented 7 months ago

Could this do the trick?

Yes I think it could, thank you.

In the meantime, i've fixed the "average".

Perfect, please keep in mind, that the payload is also affected.

Thank you very much in advance for your support!

VanillaFord commented 7 months ago

Please try the 1.1.6. You must now set a msg.topic to start subtracting from.

...this version doesn't show up in the pallette manage, yet

Supergiovane commented 7 months ago

Should show up in some minutes... npmjs takes a little log to update.

Supergiovane commented 7 months ago

Could this do the trick?

Yes I think it could, thank you.

Perfect, please keep in mind, that the payload is also affected.

The payload is not sent until the main topic hasn't been received.

VanillaFord commented 7 months ago

Should show up in some minutes... npmjs takes a little log to update.

Yep, now it is showing (v1.1.7) ...and a first test confirms, that it is working now. Thank you very much for your fast response and support!!

Supergiovane commented 7 months ago

You’re wellcome!!