acdown87
(Alec Down)
January 26, 2024, 1:22pm
1
Does anybody know how I can round the number being derived from state down to two decimals?
label: '[[[ return states["sensor.eve_room_237a_temperature"].state + "°C" ]]]'
I’ve tried a variety of things like .round(2)
, .round()
, | round()
but no luck as yet.
Le_champ
(Matteo)
January 26, 2024, 1:34pm
2
Try with
'{{ states.sensor.eve_room_237a_temperature.state | round(2) }}' °C
acdown87
(Alec Down)
January 26, 2024, 1:45pm
3
Sadly, this just prints it as a string.
Moving it to a value_template then results in [Object object]
Le_champ
(Matteo)
January 26, 2024, 1:50pm
4
So try with:
label: '[[[ return states["sensor.eve_room_237a_temperature"].state | float | round(2) + "°C" ]]]'
acdown87
(Alec Down)
January 26, 2024, 1:54pm
5
Yeh, I tried this alreay too it just errors and the card disappears lol. It’s a real brain teaser this one
Le_champ
(Matteo)
January 26, 2024, 2:04pm
6
Can you print here the whole card please?
therokss
(Therokss)
April 30, 2024, 11:19pm
7
novelty? I’m interested too
therokss
(Therokss)
May 1, 2024, 9:24am
8
I finally managed it, I don’t know if you solved it, I’ll write it anyway, maybe it can be useful to someone
label: '[[[ return Math.round((states['sensor.eve_room_237a_temperature'].state)) + "°C" ]]]'