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?
Decimal separator and number of decimals when using single_block
Moderators: leecollings, htilburgs, robgeerts
-
- 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
How did you define your block?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?
Did you adjust the value parameter?
Any code in custom.js for this block?
-
- 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
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.
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.
-
- 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
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:
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) + '%';
}
-
- 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
That works like a charm.
Thanks!
Thanks!
-
- 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
Thank you for the information.
Who is online
Users browsing this forum: No registered users and 1 guest