# Behavior of the gauge node

**URL:** <https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072>\
**Category:** Dashboard\
**Tags:** node-red-dashboard\
**Created:** [23 January 2023 08:59 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072 "2023-01-23T08:59:54Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [23 January 2023 08:59 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/1 "2023-01-23T08:59:54Z")

</div>

The behavior of the gauge node is a bit strange. I am trying to use the gauge node as shown in the next picture.

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/4/44f48ceb82f38eba0985fd4b7ba398e7f9970d53.png)

Everything goes well, until the value is 0. Then the {{unit}} value doesn't work anymore as expected.

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/22d37592d3aa7f4b3b0eba27e5404eba1e6eda67.png)

I have tried several options to get the expected behavior, for instance I tried this,

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/3/c31e485e875d3cd90b4b39c9430c4790c2dfdeb2.png)

Then I make sure that the value never gets exactly zero. Then it works well as desired, but as you can see, I then get a comma, for values greater then 999. This I also don't like to see.

![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/e/5e15b17f1cd477e2412f3263bfd6175ab2736ad2.png)

What is the correct solution for the desired presentation?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 January 2023 09:28 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/2 "2023-01-23T09:28:17Z")

</div>

What version of Node-red and the dashboard do you have? I have 3.0.2 / 3.3.1  
I see `{{units}}` before any message is sent to the gauge, unlike topic, which is blank.  
This seems to be a bug.

But if I send payload 0 the gauge seems to work fine without the number: 0 addition.

 ![Untitled 2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/0/3084a862faf272fbb572aad427187d370d73eae9.jpeg)

The comma formatting comes from the Node-red server's Locale setting. Not sure how easy or desirable it is to change that for Node-red.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [23 January 2023 09:45 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/3 "2023-01-23T09:45:57Z")

</div>

> [@jbudd](#):
>
> What version of Node-red and the dashboard do you have? I have 3.0.2 / 3.3.1

@jbudd I have following versions:  
 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/a/bafe3a12037fc20023d3de214d1d68152661a325.png)

> [@jbudd](#):
>
> I see `{{units}}` before any message is sent to the gauge, unlike topic, which is blank.

As far as I can tell, the topic is working fine. I can understand, when no message is send, that {{unit}}, will appear.

> [@jbudd](#):
>
> But if I send payload 0 the gauge seems to work fine without the number: 0 addition.

With me sending zero, after I while ??? {{unit}} will appear.

> [@jbudd](#):
>
> The comma formatting comes from the Node-red server's Locale setting. Not sure how easy or desirable it is to change that for Node-red.

This is not the case, when you don't set the number addition after value.  
 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/e/8e7863d55202a7ed61a7549f6a38212c626899f5.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 January 2023 09:57 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/4 "2023-01-23T09:57:32Z")

</div>

> [@henkkas](#):
>
> With me sending zero, after I while ??? {{unit}} will appear.

We seem to have the same versions but the units display works differently.  
Does your data come from Influx? Is it the same if you simply use an inject node?

> [@henkkas](#):
>
> > [@jbudd](#):
> >
> > The comma formatting comes from the Node-red server's Locale setting. Not sure how easy or desirable it is to change that for Node-red.
> 
> This is not the case, when you don't set the number addition after value.

True. The formatting according to locale only happens if you use eg `| number: 0`  
From the gauge help text:

> The `msg.payload` is searched for a numeric _value_ and is formatted in accordance with the defined **Value Format** , which can then be formatted using [Angular filters](https://docs.angularjs.org/api/ng/filter).
> 
> For example : `{{value | number:1}}%` will round the value to one decimal place and append a % sign.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [23 January 2023 10:47 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/5 "2023-01-23T10:47:28Z")

</div>

Hereby an example flow,

```auto
[{"id":"695aa1b525b64598","type":"ui_gauge","z":"7c6ad896ba8a384a","name":"No format","group":"57423d36f7b8b4a1","order":2,"width":4,"height":4,"gtype":"gage","title":"{{topic}}","label":"{{unit}}","format":"{{value}}","min":0,"max":"2000","colors":["#00b33c","#00b33c","#00b33c"],"seg1":"","seg2":"","diff":false,"className":"","x":400,"y":680,"wires":[]},{"id":"b81a0eb36ae1a20e","type":"function","z":"7c6ad896ba8a384a","name":"zero","func":"let val = parseInt(0.01234);\nmsg = {topic: \"no format\", payload: val, unit: \"Watt\"};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":680,"wires":[["695aa1b525b64598"]]},{"id":"f252698beb443440","type":"inject","z":"7c6ad896ba8a384a","name":"1 sec","props":[],"repeat":"1","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":720,"wires":[["b81a0eb36ae1a20e","6c7ae78586f7b3d8","e570b23fc930d9a2"]]},{"id":"6c7ae78586f7b3d8","type":"function","z":"7c6ad896ba8a384a","name":"zero","func":"let val = 0;\nmsg = { topic: \"+ format\", payload: val, unit: \"Watt\"};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":760,"wires":[["73ddc6a4cf3252ec"]]},{"id":"73ddc6a4cf3252ec","type":"ui_gauge","z":"7c6ad896ba8a384a","name":"+ format","group":"57423d36f7b8b4a1","order":11,"width":4,"height":4,"gtype":"gage","title":"{{topic}}","label":"{{unit}}","format":"{{value | number: 0}}","min":0,"max":"2000","colors":["#00b33c","#00b33c","#00b33c"],"seg1":"","seg2":"","diff":false,"className":"","x":400,"y":760,"wires":[]},{"id":"e570b23fc930d9a2","type":"function","z":"7c6ad896ba8a384a","name":"1234","func":"let val = 1234;\nmsg = { topic: \"+ format\", payload: val, unit: \"Watt\"};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":230,"y":800,"wires":[["0fc5d257d4bc41fd"]]},{"id":"bf69885e49afe793","type":"inject","z":"7c6ad896ba8a384a","name":"test","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":600,"wires":[["8d85b5bf24ffc667"]]},{"id":"8d85b5bf24ffc667","type":"function","z":"7c6ad896ba8a384a","name":"1234","func":"let val = 1234;\nmsg = {topic: \"no format\", payload: val, unit: \"Watt\"};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":290,"y":600,"wires":[["695aa1b525b64598"]]},{"id":"0fc5d257d4bc41fd","type":"ui_gauge","z":"7c6ad896ba8a384a","name":"+ format","group":"57423d36f7b8b4a1","order":10,"width":4,"height":4,"gtype":"gage","title":"{{topic}}","label":"{{unit}}","format":"{{value | number: 0}}","min":0,"max":"2000","colors":["#00b33c","#00b33c","#00b33c"],"seg1":"","seg2":"","diff":false,"className":"","x":400,"y":800,"wires":[]},{"id":"57423d36f7b8b4a1","type":"ui_group","name":"test","tab":"ad12ad91.ab672","order":1,"disp":true,"width":"8","collapse":false,"className":""},{"id":"ad12ad91.ab672","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

If you restart your flows, you can clearly see the behavior.

The gauge with no format, will show `{{units}}`, as you inject one time `1234` it will then show `Watt` (for a while ????).. The gauge with format and value 0, with keep on showing {{unit}}.

The topic will keep on showing always, no problem.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 January 2023 11:00 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/6 "2023-01-23T11:00:21Z")

</div>

> [@henkkas](#):
>
> If you restart your flows, you can clearly see the behavior.

As I said before:

> But if I send payload 0 the gauge seems to work fine

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/8/c8a387da66065e200e315ae6e256028c780b3aa0.jpeg)

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [23 January 2023 11:15 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/7 "2023-01-23T11:15:14Z")

</div>

@jbudd Have you tried `restart flows` or refresh the page in your web browser?

If I keep on testing, it seems more or less random, one time it seems ok, next time I see `{{unit}}`  
 ![afbeelding](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5a60d848a01261d2b1ad74553cfb47696b9c238e.png)

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 January 2023 11:45 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/8 "2023-01-23T11:45:12Z")

</div>

I agree, when I refresh the browser page, it shows `{{unit}}`  
Sending

```auto
{
"payload":0,
"topic":"no format",
"unit":"Watt"
}

```

does not set the units to "Watt".

I can't explain this behaviour.  
A simple flow to reproduce (reload browser is essential after deploy)

```auto
[{"id":"695aa1b525b64598","type":"ui_gauge","z":"18302aaec057c898","name":"No format","group":"57423d36f7b8b4a1","order":2,"width":4,"height":4,"gtype":"gage","title":"{{topic}}","label":"{{unit}}","format":"{{value}}","min":0,"max":"2000","colors":["#00b33c","#00b33c","#00b33c"],"seg1":"","seg2":"","diff":false,"className":"","x":620,"y":160,"wires":[]},{"id":"b81a0eb36ae1a20e","type":"function","z":"18302aaec057c898","name":"zero","func":"let val = parseInt(0.01234);\n\nmsg.topic = \"no format\"\nmsg.payload = val\nmsg.unit = \"Watt\"\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":350,"y":200,"wires":[["695aa1b525b64598","4ff77ba00d0b4cf0","8de0e0ad0e807578","8b9965a2473bcd91"]]},{"id":"83a338edf7ecfeb6","type":"ui_button","z":"18302aaec057c898","name":"","group":"57423d36f7b8b4a1","order":2,"width":"3","height":"1","passthru":false,"label":"Send 0","tooltip":"","color":"","bgcolor":"","className":"","icon":"","payload":"","payloadType":"str","topic":"topic","topicType":"msg","x":200,"y":200,"wires":[["b81a0eb36ae1a20e"]]},{"id":"4ff77ba00d0b4cf0","type":"ui_text","z":"18302aaec057c898","group":"57423d36f7b8b4a1","order":0,"width":"3","height":"1","name":"","label":"Topic","format":"{{topic}}","layout":"row-spread","className":"","x":610,"y":200,"wires":[]},{"id":"8de0e0ad0e807578","type":"ui_text","z":"18302aaec057c898","group":"57423d36f7b8b4a1","order":0,"width":"3","height":"1","name":"","label":"Payload","format":"{{payload}}","layout":"row-spread","className":"","x":620,"y":240,"wires":[]},{"id":"8b9965a2473bcd91","type":"ui_text","z":"18302aaec057c898","group":"57423d36f7b8b4a1","order":0,"width":"3","height":"1","name":"","label":"Unit","format":"{{unit}}","layout":"row-spread","className":"","x":610,"y":280,"wires":[]},{"id":"57423d36f7b8b4a1","type":"ui_group","name":"test","tab":"ad12ad91.ab672","order":1,"disp":true,"width":"8","collapse":false,"className":""},{"id":"ad12ad91.ab672","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [23 January 2023 11:50 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/9 "2023-01-23T11:50:30Z")

</div>

@jbudd I am trying to make a universal control to all the gauge nodes, where not only the these parameters but also min max. are send to the node.

By the way, what did I do wrong when sending my flow on this page, it took a lot of space, while yours only takes 1 line space?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 January 2023 12:07 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/10 "2023-01-23T12:07:35Z")

</div>

When you copy the code, go to the JSON tab and click "Compact" rather than "Formatted".  
Should be the default IMHO.

---

<div class="post-metadata">

**Author:** ![henkkas](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/henkkas/32/39844_2.png) [@henkkas](https://discourse.nodered.org/u/henkkas)\
**Post date:** [23 January 2023 12:51 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/11 "2023-01-23T12:51:54Z")

</div>

@jbudd Ok, yes, I see that now. 🙂

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [23 January 2023 13:00 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/12 "2023-01-23T13:00:07Z")

</div>

Here how it seems work when sending msg.payload, msg.topic and msg.unit AND have defined the node like this:  
 ![Screenshot 2023-01-23 at 6.54.25 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/4/e/4e679a09860d8371cf7dd0963096e22bb30fefc5.png)  
or this:  
 ![Screenshot 2023-01-23 at 6.54.44 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/7/672a8f0edfe59b1f5e0992675547ecdd18bec5f0.png)  
Note {{value}} and {{payload}} are interchangeable in this situation

1. if the Value changes, the Label AND the unit will change
2. if the Value DOES NOT change but the label does, the LABEL will change BUT the unit will not
3. if the Value AND the Label change, the units will change.

---

<div class="post-metadata">

**Author:** ![hotNipi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hotnipi/32/383_2.png) [@hotNipi](https://discourse.nodered.org/u/hotNipi)\
**Post date:** [23 January 2023 13:59 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/13 "2023-01-23T13:59:35Z")

</div>

> [@henkkas](#):
>
> {{unit}}

Know that you also can have fallback (default value) when using angular filters. So you can make flows a bit simpler by not covering all the corners what it takes to successfully initialize all the components and keep things in sync with server side.

`{{unit || "Watt"}}`

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [24 January 2023 23:22 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/14 "2023-01-24T23:22:41Z")

</div>

> [@jbudd](#):
>
> "Compact" rather than "Formatted".  
> Should be the default IMHO.

Waaaaay ahead of you 🙂

> <https://github.com/node-red/node-red/pull/3974>
>
> closes #3849
> 
> \## Types of changes
> 
> \- \[\] Bugfix (non-breaking change which f…ixes an issue)
> \- \[x\] New feature (non-breaking change which adds functionality)
> 
> \## Proposed changes
> 
> Saving flow is a specific format is not necessarily how a user wants to export a flow, especially when pasting to a forum/slack thread.
> 
> This PR remembers the user choice and reselects that mode in the export dialog.
> 
> \## Checklist
> 
> \- \[x\] I have read the \[contribution guidelines\](https://github.com/node-red/node-red/blob/master/CONTRIBUTING.md)
> \- \[x\] For non-bugfix PRs, I have discussed this change on the forum/slack team.
> \- \[x\] I have run \`grunt\` to verify the unit tests pass
> \- \[\] I have added suitable unit tests to cover the new/changed functionality

Ok, so not default but next version will remember your choice. 👍

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 January 2023 07:18 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/15 "2023-01-25T07:18:38Z")

</div>

Excellent, thanks for that.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [24 February 2023 07:18 UTC](https://discourse.nodered.org/t/behavior-of-the-gauge-node/74072/16 "2023-02-24T07:18:42Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
