Philips Hue Decimals

Hi All,

I’m was tweaking my temperature sensors a bit and it frustrated me that there were 2 decimals with every temperature sensor.
I then started to make a value_template to correct this to 1 decimal. It worked. But a new problem knocked on the door.

I’m using the “Mini Graph Card” which shows me a smooth line of temperature changes over the past 24 hours. The line now is just flat…

I added this template to the configuration.yaml

  - platform: template
    sensors:
      overloop_zolder:
        value_template: "{{ states('sensor.zolder_sensor_temperature')|round }}"
        unit_of_measurement: '°C'

After that i created a custom card with this nice peace of code to show a coloured graph adapting to the temperature. Blue=Cold / Green=Fine / Red=hot

align_icon: left
align_state: left
color_thresholds:
  - color: '#adadeb'
    value: 15
  - color: '#adadeb'
    value: 15.5
  - color: '#adadeb'
    value: 16
  - color: '#adadeb'
    value: 16.5
  - color: '#adadeb'
    value: 17
  - color: '#adadeb'
    value: 17.5
  - color: '#99ff99'
    value: 18
  - color: '#99ff99'
    value: 18.5
  - color: '#99ff99'
    value: 19
  - color: '#99ff99'
    value: 19.5
  - color: '#99ff99'
    value: 20
  - color: '#ff9999'
    value: 20.5
  - color: '#ff9999'
    value: 21
  - color: '#ff9999'
    value: 21.5
  - color: '#ff9999'
    value: 22
  - color: '#ff9999'
    value: 22.5
  - color: '#ff9999'
    value: 23
entities:
  - sensor.overloop_zolder
labels: true
name: Overloop (Zolder)
type: 'custom:mini-graph-card'

I don’t have a clue why my graph is not showing… Restarted Hass a several time but that doesn’t make any changes…

The other cards don’t use a value_template so they are working fine… But are not rounded…

Could it be that when doing that in a value_template you get a string back? Could you convert the value to a float? Maybe something like:
"{{ states('sensor.zolder_sensor_temperature') | round(1) | float }}"

You are right, this

states('sensor.xxxx')

will always return a string according to the docs.

@MDLefevere

Try this to first convert the string to float and then to round the float.
"{{ states('sensor.zolder_sensor_temperature') | float | round }}"

I think you should also be able to just cast it as an integer like this:
"{{ states('sensor.zolder_sensor_temperature') | int }}"

Thanks!.
Converting it to a float fixed the problem.