Dashboard Gauge unit conversion

#1

Using the gauge as a temperature display, the input to it is in F.

I have used the angular expression {{ (payload.currently.temperature - 32) * 5/9 | number:0 }} to convert to C (in the Value Format field).

The numeric display on the gauge is correct, however the icon representation is still showing the value as it would be for F. I am assuming I have done something wrong in the expression above?

Thanks.

#2

Change value in unit field
image

or append the unit in value field

image

#3

The Unit Field is as per your first option already. I'll try the second way.

#4

So, it appears the angular expression doesn't like standard brackets, would that be correct?

#5

Problem solved. Always closely examine your input type, just in case it isn't what it appears to be.

Thanks hotNipi

2 Likes
#6

Ok, spoke too soon. Don't believe it is related to my input.

Digging deeper it seems I cannot enclose the payload part of the expression in parenthesis without it throwing a type error.

For example, this {{payload.currently.humidity*(100-5)}} works. But {{(payload.currently.humidity)*(100-5)}} throws an error. Any idea where I'm going wrong?

Thanks

#7

You probably aren't. Probably a limitation of the expression parser trying to cope with both angular and node-red properties.

#8

Ok, thanks. Good to know I'm not going crazy in this particular instance.

#9

For this particular case (temp conversions), I often just use a range node to convert the value before passing it to the UI widget. E.g. to go from F to C, set the input range from 32-212 and the output as 0-100...

2 Likes
#10

Thanks @shrickus for the tip.