Decimal separator and number of decimals when using single_block

Dashticz, alternative dashboard based on HTML, CSS, jQuery

Moderators: leecollings, htilburgs, robgeerts

Post Reply
jvdk
Posts: 38
Joined: Sunday 11 August 2019 17:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Decimal separator and number of decimals when using single_block

Post 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?
Lokonli
Posts: 2291
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Decimal separator and number of decimals when using single_block

Post 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?
jvdk
Posts: 38
Joined: Sunday 11 August 2019 17:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Decimal separator and number of decimals when using single_block

Post 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.
Lokonli
Posts: 2291
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Decimal separator and number of decimals when using single_block

Post 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) + '%';
}
jvdk
Posts: 38
Joined: Sunday 11 August 2019 17:16
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Decimal separator and number of decimals when using single_block

Post by jvdk »

That works like a charm.
Thanks!
Matthias
Posts: 12
Joined: Wednesday 09 January 2019 23:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Decimal separator and number of decimals when using single_block

Post by Matthias »

Hi,
I have a problem similar with a dummy device.
How can i delete decimal on the dial ?

Image

Thank you
Lokonli
Posts: 2291
Joined: Monday 29 August 2016 22:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Decimal separator and number of decimals when using single_block

Post 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 ?

Image

Thank you
I think it's not possible at the moment. It's on the feature request list.
Matthias
Posts: 12
Joined: Wednesday 09 January 2019 23:32
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Decimal separator and number of decimals when using single_block

Post by Matthias »

Thank you for the information.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest