sss-modernkris / webiopi

Automatically exported from code.google.com/p/webiopi
0 stars 0 forks source link

DS18B20 - Exception thrown in python and webpage #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Symptom: After some time, an exception is thrown via python in both script and 
http (I presume)
1. When monitoring DS18B20 temperature, 
    A. In webpage, temperature stops updating - a refresh of page restarts
    B. In python script, exception is thrown:
-------------------------------
Set Temp: 45
Cellar Temp: 46
Cellar temp: Too Warm

Set Temp: 45
Cellar Temp: 46
Cellar temp: Too Warm
Traceback (most recent call last):
  File "/mnt/data/cellar/cellar.py", line 33, in <module>
    cellar_temp = "%.0f" % (Cellar.getFahrenheit())
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.6.0-py3.2-linux-armv6l.egg/webiopi/devices/sensor/__init__.py", line 118, in getFahrenheit
    return self.__getFahrenheit__()
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.6.0-py3.2-linux-armv6l.egg/webiopi/devices/sensor/onewiretemp.py", line 34, in __getFahrenheit__
    return self.Celsius2Fahrenheit()
  File "/usr/local/lib/python3.2/dist-packages/WebIOPi-0.6.0-py3.2-linux-armv6l.egg/webiopi/devices/sensor/__init__.py", line 93, in Celsius2Fahrenheit
    return value * 1.8 + 32
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
-------------------------------

WebIOPi version used?
=> 0.6.0
Python version used?
=> 3

Distro used? (WebIOPi has only been tested on Raspbian Wheezy)
=> Raspbian Wheezy

Raspberry Pi board revision? (1 or 2)
=> 2

For Javascript side bugs, Browser?
=> N/A

Please provide any additional information below.

Python Script:
--------------------------------
############################
#
#  Beer Cellar
#  5-Nov, 2013
#  cellar.py
#
############################

# Imports
import webiopi
import time
import sys
import os

GPIO = webiopi.GPIO
sys.path.append("/mnt/data/cellar/")
from webiopi.devices.sensor import DS18B20

# Setup GPIOs
GPIO.setFunction(23, GPIO.OUT)
GPIO.output(23, GPIO.LOW)
GPIO.output(7, GPIO.LOW)

# Enable debug output
# webiopi.setDebug()
Cellar = DS18B20 (slave="28-0000043a6d18")
loop = 1

while loop == 1:
    GPIO.output(7, GPIO.HIGH)
    cellar_temp = "%.0f" % (Cellar.getFahrenheit())

#   os.system('clear')
    fo = open("/mnt/data/cellar/set_temp.txt", "r")
    set_temp = fo.read(2);
    fo.close()

    print ('\n' + "Set Temp: " + set_temp)
    print ("Cellar Temp: " + cellar_temp)

    if cellar_temp > set_temp:
        print ("Cellar temp: Too Warm")
        GPIO.output(23, GPIO.HIGH)

    else:
        print ("Cellar temp: Too Cold")
        GPIO.output(23, GPIO.LOW)

    time.sleep (5)
    GPIO.output(7, GPIO.LOW)
    time.sleep (5)
    GPIO.output(7, GPIO.HIGH)

    time.sleep (5)
    GPIO.output(7, GPIO.LOW)
    time.sleep (5)
    GPIO.output(7, GPIO.HIGH)

    time.sleep (5)
    GPIO.output(7, GPIO.LOW)
    time.sleep (5)
    GPIO.output(7, GPIO.HIGH)

@webiopi.macro
def Temp(arg0):
    return ("%s" % (cellar_temp))
--------------------------------------

Original issue reported on code.google.com by davidpau...@gmail.com on 4 Dec 2013 at 3:19

GoogleCodeExporter commented 9 years ago
see issue 68

Original comment by tro...@trouch.com on 10 Dec 2013 at 2:34