Open aeff81 opened 2 years ago
This is not only relevant for „guest users“, and also not limited to the .csv-plugin (am using the mqtt-plugin): I have the BS 444, and sometimes the „user detection“ fails (or does not even start), which results in „only weight being sent“ (with everything else being blank). Also in these (multiple) cases they script stops with „division by 0“.
Traceback (most recent call last):
File "/home/pi/BS440-HA-AD/BS440.py", line 332, in <module>
appendBmi(persondata[0]['size'], weightdata)
File "/home/pi/BS440-HA-AD/BS440.py", line 122, in appendBmi
element['bmi'] = round(element['weight'] / (size * size), 1)
ZeroDivisionError: float division by zero
@aeff81, not sure whether I know what I'm doing ;) but I added a PR for this bug (https://github.com/creatvty/BS440-HA-AD/pull/2) which fixed it for me.
@creatvty, please have a look.
@aeff81, is merged and should be fixed. Maybe you can check and close the issue.
There's a potential "division by 0" in BS440csv.py if size = 0 (Guest-User for example). Due to my lack of Python skills, I solved it the ugly way. But I would suggest that somebody, who knows what he's doing, adds a check if (size == 0) { size = 1 } Here's my ugly patch, just to show the location of the Problem: