EarlGrey
(Earl Grey)
1
I am trying to remove a decimal as I want to have rounded percentages. I’m retrieving values for a device between 0.1 and 1.0.
As template_value I’m using:
value_template: "{{ states('sensor.homey_mechanisch_vent') | float * 100 | int }}"
![image](//community-assets.home-assistant.io/original/3X/8/e/8e811041e85a432b242fdf0a5f6e0c953598674b.png)
I tried various functions like
round(0)
, but every time the .0 appears. Is there a way to have this fixed?
does this work
{{ states("sensor.homey_mechanisch_vent")|int }}
1 Like
EarlGrey
(Earl Grey)
4
Of course this page was the first thing I looked at, especially the priority of operators but I couldn’t get it fixed after some attempts.
EarlGrey
(Earl Grey)
5
Thanks, but it does not work this way. ![:slight_smile: :slight_smile:](https://community.home-assistant.io/images/emoji/twitter/slight_smile.png?v=9)
Try it with
value_template: "{{ (states('sensor.homey_mechanisch_vent') | float * 100) | int }}"
Like the docs say, your template calculates a float * (100 | int) and that returns a float.
EDIT: You can play with it in Dev Tools/templates.
5 Likes
EarlGrey
(Earl Grey)
7
That did the trick! Those damn parentheses
And I also did not know you could play around in Dev Tools. I was reloading the config each time. Thanks!