Open eresgit opened 4 years ago
I think replacing line 172 with this works: return FanState(round(math.log2(v[0] if v[0] > 0 else 1)*10, 2), v[1]/4, v[2], v[3], trigger)
You're completely correct that math.log2 does not handle 0. Only the open interval (i.e. not exactly zero). I fixed this in a commit referenced above (thus master should be properly working regarding this). I did however move out the if-case, as it seemed more logical to just report zero directly. However, it is essentially the same code. Thanks for reporting!
/pycalima/Calima.py", line 172, in getState return FanState(round(math.log2(v[0])*10, 2), v[1]/4, v[2], v[3], trigger) ValueError: math domain error
Looks like a problem when v[0] = 0