rtl_433-hass-addons icon indicating copy to clipboard operation
rtl_433-hass-addons copied to clipboard

rtl433 battery status is not properly handled

Open Gonioul opened this issue 2 years ago • 10 comments

Batteries shows as 100% without icon Wheareas other integrations shows battery icon

Gonioul avatar Apr 20 '22 23:04 Gonioul

image

Gonioul avatar Apr 20 '22 23:04 Gonioul

Looks like it should be an integer to be properly handled

Gonioul avatar Apr 24 '22 19:04 Gonioul

Thanks for the report. Are you thinking the problem is with the value_template line at https://github.com/merbanan/rtl_433/blob/master/examples/rtl_433_mqtt_hass.py#L162-L173 ?

deviantintegral avatar Apr 25 '22 15:04 deviantintegral

I have no idea... But converting the level to an integer seems logical if it's a 0-100 range.

Gonioul avatar Apr 26 '22 18:04 Gonioul

Another difference, the same sensor with rfxcom (top) and rtl_433 (below) with low battery. It didn't rename the rtl_433 entities for now, so it's the default name. rtl_433 log says "Battery : 0" for low battery instead of "Battery : 1"

image

image

Gonioul avatar May 03 '22 17:05 Gonioul

For the 100,0% issue, maybe the text is simply too wide, because the icon shows for low battery, would explain the "…"

Gonioul avatar May 03 '22 18:05 Gonioul

EnCh - Entity Checker for AppDaemon doesn't seem to recognize the low battery level with rtl_433, works with rfxtrx, dunno why, no trace in logs. Maybe the float value again.

Gonioul avatar May 03 '22 18:05 Gonioul

Changing value template to this worked for me: "value_template": "{% set temp_val = float(value) * 100 | float(default=0) %}{{ temp_val | float(default=0) | round(0) }}"

jaseelye avatar May 05 '22 12:05 jaseelye

I think it would be good if we could confirm if Home Assistant is expecting ints or floats for battery percentages. I haven't found docs or code yet confirming one way or another.

deviantintegral avatar May 09 '22 18:05 deviantintegral

This is what I use and it works great. "value_template": "{% if is_number(value) %}{% set temp_val = float(value) * 100 | float(default=0) %}{{ temp_val | float(default=0) | round(0) }}{% endif %}"

jaseelye avatar May 24 '22 22:05 jaseelye

Since this is from the upstream code, and I don't have any devices that expose this battery info to test, I'm closing this out. Please feel free to open a new issue if a PR is filed upstream we should patch in to improve this. Thanks!

deviantintegral avatar Feb 17 '24 00:02 deviantintegral