Posted by kewlj1313
What steps will reproduce the problem?
What is the expected output? What do you see instead? Expected: A temperature Instead: Error response Error code: 403 Message: invalid literal for int() with base 10: '=5062'.
What version of the product are you using? On what operating system? r894 on RaspberryPi
Please provide any additional information below.
I located the issue and was able to get it working again. This is caused in the sensor.py file by the following:
def \_\_getCelsius\_\_(self):
data = self.read()
lines = data.split("\n")
if lines[0].endswith("YES"):
temp = lines[1][-5:]
return int(temp) / 1000.0
lines[1][-5:] is expecting 5 characters but when the sensor is below 10 degrees C it returns integers such as 9550.
I was able to fix it by doing the following strip of the = sign:
def \_\_getCelsius\_\_(self):
data = self.read()
lines = data.split("\n")
if lines[0].endswith("YES"):
temp = lines[1][-5:]
temp = temp.strip('=')
return int(temp) / 1000.0
Thank you! Kewlj1313
Posted by kewlj1313
Also thanks very much for your hard work on this! This is an awesome project and I will continue to assist where I can.
Posted by trouch
can you add : 1) precise component ref 2) webiopi driver you used (OneWireTemp or DS*) 3) dump of /sys/bus/w1/devices/{device_id}/w1_slave when this error occurs
Posted by kewlj1313
1) DS18B20 2) in my /etc/webiopi/config I used the following temp0 = DS18B20 28-000004664d5f I'm not sure what else you are looking for here on the driver info. 3) pi@raspberrypi /sys/bus/w1/devices $ cat /sys/bus/w1/devices/28-000004664d5f/w1_slave 3e 00 4b 46 7f ff 02 10 51 : crc=51 YES 3e 00 4b 46 7f ff 02 10 51 t=3875
Again the reason for this error is because the temperature is below 10 degrees C. The code fix I did above fixes the problem.
Thank you, -Jason
Posted by trouch
ok, I did not well understood first time. I will rather use :
i = lines[1].find('=') temp = lines[1][i+1:] return int(temp)
thanks for feedback, I will correct it later today.
Posted by JasonFlittner
Good idea on the fix because that will also handle when there are less than 4 chars etc...
don't forget to divide by 1000.0
return int(temp)/1000.0
Posted by trouch
This issue was closed by revision r898.