thejeffreystone / hassio_addons

Apache License 2.0
45 stars 26 forks source link

Temperatures showing many digits after the decimal #45

Open exeljb opened 1 year ago

exeljb commented 1 year ago

Sometimes the temperatures displayed in HA will be shown with an obnoxious amount of numbers after the decimal.

Screenshot 2023-02-04 at 8 46 44 PM

Has anyone else seen this behavior?

I know I can create template sensors in HA where I can round these values but it would be nice if the add-on handled this. Maybe adding some |round(1)'s to the script would do the trick?

exeljb commented 1 year ago

Found it! The units setting in the config was set to si instead of customary.

exeljb commented 1 year ago

So I guess this wasn't the problem since the temps have still been showing many digits. This is from the log...

Received key time for Acurite-Tower
Received key channel for Acurite-Tower
Received key battery_ok for Acurite-Tower
Received key temperature_F for Acurite-Tower
Received key humidity for Acurite-Tower
Received key freq for Acurite-Tower
Received key rssi for Acurite-Tower
Received key snr for Acurite-Tower
Received key noise for Acurite-Tower
Received message: rtl_433/events : {"time": "2023-02-25 18:10:25-0600", "protocol": 40, "model": "Acurite-Tower", "id": 460, "channel": "B", "battery_ok": 1, "temperature_F": 73.03999, "humidity": 30, "mic": "CHECKSUM", "mod": "ASK", "freq": 433.98854, "rssi": -0.111153, "snr": 19.26843, "noise": -19.3796}
thejeffreystone commented 1 year ago

I can have the add-on round the temp. I'm testing to see if using the suggested display precision attribute can handle this.

I'm a little worried about using round in the device mapping since that will remove the precision. Not that we need 4 decimals of precision for smart home use cases. It's more of if I do it, it removes it for everyone.

So let me test some things. If I can force HA to respect my authority as Cartman says, then I'll will round it.

exeljb commented 1 year ago

lol yes, Cartman's authoritay! I don't know how much you'd want to change, you make a good point about it removing the digits for everyone. That might be undesirable for some. In my experience, anything past the 2nd digit of the decimal is junk anyways but I don't know if there's sensors out there that would give that accurate of a resolution.

In the time since I wrote this issue, HA was updated to easily set the display precision for each sensor. I have been using that feature and noticed no more multiple digits. This might be the ideal way to handle it since it can be done on a per sensor basis at the desire of each individual user whereas if we stuck to the rounding in the add-on, then all sensors would be bound to it for everybody. Maybe it's best to keep it the way it currently is?