Maybe a weard question for a nice to have.
Some of my temperature sensors have a .5°C accuracy but report to any digit after the decimal separator.
Like 14.2, 14.6, 14.8, etc.
Can a ESPHome-sensor send a value rounded to 0.0 or 0.5 to HA, whichever is closer, instead of rounding to the unit? So that HA receives the rounded value only.
Like 14.2 is sent as 14.0, 14.4 is sent as 14.5, 14.6 is sent as 14.5, 14.8 is sent as 15.0.
As mentioned: it could be nice to have (!) thát displayed on an OLED screen. And maybe a challenge for someone much smarter in ESPHome than me.
Could be interesting for other sensors to be rounded to 5 and 10 or 50 and 100 too. Weighing scales often have that kind of accuracy.
Anyone?
Apply a lambda filter to your sensor:
filters:
- lambda: return (round(x/0.5)) * 0.5;
Or of course you could apply the same formula when you print it to the display.
2 Likes
Oh dear… is the formula as simple as that?
For a rookie there is no way to know how to even start with this. Will have to look into the potential of Lambda.
I personally prefer that the value sent to HA is already rounded. But there is much to say for doing the rounding on the display in order to keep original values, even if they are out of accuracy limits.
Thanks a million… and it works!
1 Like