node-red-dashboard icon indicating copy to clipboard operation
node-red-dashboard copied to clipboard

Gauge node unit field issue

Open Henkkas52 opened this issue 2 years ago • 6 comments

There is a problem with the gauge node if you use it the way I do,

afbeelding

In this case everything works well, until you continuously write zero in the value field, then the unit field will not show the units but rather {{unit}}. Any other (non changing) value that is written to {{value}}, will cause the gauge node to work well, accept when you write 0 to {{value}} as I mentioned before. I don't see any way to correct this problem, rather than placing a constant string in this field in stead of {{unit}}.

I mentioned this issue on https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072 but no solution was mentioned.

I think the problem is easily to reproduce, as I gave an example on the node-red forum.

My system is an RPI 3B+ with following software.

afbeelding

Browsers: Microsoft edge, Firefox

Henkkas52 avatar Jan 24 '23 06:01 Henkkas52

hmm maybe not so easy - when I run it I get image what do you do exactly to provoke it ? do you flush / reload / change tabs / click something ?

dceejay avatar Jan 24 '23 13:01 dceejay

@dceejay To keep it simple. If you have 2 gauges, and feed one with the value 0 (zero) and the other with 1234, with a constant interval, let's say 1 sec. The one with zero value will show {{unit}} after a while. You can force this by refresh the browser page, which shows the gauges. The label {{topic}} is always OK though, it will always show the string that's feed to it.

Why do I want to use the gauges this way, with variables for all entries? Because I want to be able to change the units field from, for instance "Watt" to "kW" and back again. Or "m3" to "Liters" and back again.

afbeelding

It is also a bit random somehow. Sometimes stays OK for a while but with combination of restart flows and refresh the browser, it will show this effect.

I succeeded avoiding this problem, by feeding a very small value, when the value should be zero, by giving value field a format, but then I got a comma for values greater then 999, which is also undesirable for me. (see pic that I updated just now)

Henkkas52 avatar Jan 24 '23 14:01 Henkkas52

I can see an issue... that could be a so and so to fix... - but ... it seems to work for me if I use msg.units (not .unit) and {{units}}

dceejay avatar Jan 24 '23 15:01 dceejay

@dceejay. For me it is still the same result with 'msg.units'/{{units}} in stead of 'msg.unit' {{unit}}.

I was just wondering why units-field reacts different then label-field {{topic}}. They are both just text-fields with no special meaning.

Henkkas52 avatar Jan 24 '23 16:01 Henkkas52

they aren't - one is handled outside the gauge widget, whereas the units has to be passed into the gauge library and manipulated there.

dceejay avatar Jan 24 '23 21:01 dceejay

@dceejay OK, understand.

Henkkas52 avatar Jan 25 '23 09:01 Henkkas52