Gauge: decimal digits and payload with spaces

Hi, I'm using a gouge node and I know that in Value format:

  1. is possible manage payload with spaces as msg.payload["what you want"].
  2. is possible define decimal digits directly within the value format as {{msg.payload.whatyouwant | number: 2}}

Both work individually, but I would use them togheter. I've tried several combination but it seems not to work

Hi , sorry I'm not quite clear on which doesn't work ?

I believe that @Lupin_III is trying to use
{{msg.payload["what you want"] | number: 2}}
which throws the error "TypeError: Cannot read property '|number:2' of undefined".
This does work ok
{{msg.payload["what you want"]}}
I also can't find the right syntax to make it work with |number

Yes Colin, exactly.
I can't either find a solution. Maybe it's not possible.
If so, how can I replace the spaces with "_" inside the properties? Since they are quite a lot, I would like to avoid to rename them one by one inside a function node
Thanks

Correct it's not really possible. either you can use the angular filters with the value {{value | number:2}} - OR - you can use a msg property. Internally they use different code paths.

Do you mean that {{msg.payload.what_you_want |number: 2}} should not work? It does work, where the value is in that property obviously.

oh right so it's the ["something with spaces"] - hmm ok. will look

Ok - fix found and pushed to master - not on npm yet, until next release.

This works: {{msg.payload.what_you_want |number: 2}} (property with no spaces)
This doesn't work: {{msg.payload["what you want"] |number: 2}} (property with spaces)

If you want to try it before the next release of the dashboard, if you go to your .node-red folder and run
npm install node-red/node-red-dashboard
that will install it direct from git. Then restart node-red to start using it.
When the next version of node-red-dashboard is released I am not sure if updating from Manage Palette will do it, if not then, again from .node-red folder run
npm remove node-red-dashboard
npm install node-red-dashboard
and restart node-red.

Thanks a lot

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