Page 1 of 1
Decimal separator and number of decimals when using single_block
Posted: Sunday 13 December 2020 19:36
by jvdk
I use the single_block: 'true' setting to combine temperature and humidity values in a single block.
The temperature values in other blocks are shown with a comma (I am Dutch) with one decimal.
In the combined block a temperature of 7,1 °C is shown as 7.1 °C and a temperature of 7,0 °C is shown as 7 °C.
Is there a way to show the value with 1 decimal and a comma as speparator?
Re: Decimal separator and number of decimals when using single_block
Posted: Monday 14 December 2020 22:34
by Lokonli
jvdk wrote: ↑Sunday 13 December 2020 19:36
I use the
single_block: 'true' setting to combine temperature and humidity values in a single block.
The temperature values in other blocks are shown with a comma (I am Dutch) with one decimal.
In the combined block a temperature of
7,1 °C is shown as
7.1 °C and a temperature of
7,0 °C is shown as
7 °C.
Is there a way to show the value with 1 decimal and a comma as speparator?
How did you define your block?
Did you adjust the value parameter?
Any code in custom.js for this block?
Re: Decimal separator and number of decimals when using single_block
Posted: Wednesday 16 December 2020 19:30
by jvdk
To be sure that nothing influences the value, I changed custom.js back to default. I have a number of single blocks. An example of such a block is:
blocks[1035] = {
title: 'Badkamer',
single_block: true,
width: 12,
value: "<Temp> °C <Humidity>%"
}
This results is a block with for example: 20.2 °C 50%, so with a decimal point.
Other blocks with only temperature readings give the value with a comma, for instance: 20,2 °C
If the value in a single block becomes 20 °C, the value is shown without decimals, so: 20 °C.
Re: Decimal separator and number of decimals when using single_block
Posted: Thursday 17 December 2020 0:55
by Lokonli
Currently, if you define the value parameter, then no number formatting is applied.
In a future update I probably will redesign how units and decimals are handled, in a more generic way.
For the time being, I'm afraid you have to use a getStatus function in custom.js.
Something like:
Code: Select all
function getStatus_1035(block) {
block.value = number_format(block.device.Temp,1) + '°C ' + number_format(block.device.Humidity,0) + '%';
}
Re: Decimal separator and number of decimals when using single_block
Posted: Thursday 17 December 2020 16:49
by jvdk
That works like a charm.
Thanks!
Re: Decimal separator and number of decimals when using single_block
Posted: Sunday 10 January 2021 13:59
by Matthias
Hi,
I have a problem similar with a dummy device.
How can i delete decimal on the dial ?
Thank you
Re: Decimal separator and number of decimals when using single_block
Posted: Sunday 10 January 2021 15:14
by Lokonli
Matthias wrote: ↑Sunday 10 January 2021 13:59
Hi,
I have a problem similar with a dummy device.
How can i delete decimal on the dial ?
Thank you
I think it's not possible at the moment. It's on the feature request list.
Re: Decimal separator and number of decimals when using single_block
Posted: Sunday 10 January 2021 16:01
by Matthias
Thank you for the information.