How to round sensor values in very odd way?

Hi, I need to round temperature values like 17.24 to return values that are devideable with 0.125 and 2 decimals…

Example: 17.0, 17.12, 17.25, 17.37, 17.5, 17.62, 17.75, 17.87, 18.0

Thanks for helping me out!

Try this:

{{ ((states('sensor.foobar')|float(0) * 8)|round(0) /8)|round(2) }}
2 Likes

Works for me, thanks a very lot!!!