Closed Yllelder closed 5 years ago
I autorespond.
I didn't know you could create your own sensors from templates.
I have created 3 new sensors with templates that round off the values to integers. That's how it looks:
sensor:
- platform: template
sensors:
rounded_temp:
value_template: "{{ states('sensor.dark_sky_temperature') | round(0) }}"
device_class: temperature
max_rounded_temp:
value_template: "{{ states('sensor.dark_sky_daytime_high_temperature_0d') | round(0) }}"
device_class: temperature
min_rounded_temp:
value_template: "{{ states('sensor.dark_sky_overnight_low_temperature_0d') | round(0) }}"
device_class: temperature
The sensors are now available as
sensor.rounded_temp
sensor.max_rounded_temp
sensor.min_rounded_temp
and can now be used like any other sensor, providing the temperature already rounded.
I hope this can help someone ;)
Nice solution @Yllelder , thanks for sharing!
@Yllelder Thanks, but maybe a noob question here. Where do you exactly put this code?
@Yllelder Thanks, but maybe a noob question here. Where do you exactly put this code?
You can use this code in the configuration.yaml
file.
This will create 3 new sensors (sensor.rounded_temp
, sensor.max_rounded_temp
, sensor.min_rounded_temp
) that you can use anywhere in the interface.
The Darksky component shows the temperature values with decimals, and I personally don't need so much precision. It would be more aesthetic if the values were integers.
Is there a template or a way to round the values with decimals?