Hi Bradley
Yes there are a few ways try this one ( I ran this code and it works so if you have a problem then my guess would be something wrong with the path you specified in the config that loads the script.
The following script assumes you called your 2 DS18B20 sensors Temp0 and Temp1 in the config file (if you called them something else then its probably best to rename the sensors in the config file then it will be easier to debug if the code does not work)
I think the python code speaks for its self, but if there is anything you don't get, ask ! (incidentally I post this python code here because you could have problems with properties if I attach the file, so just copy and paste it into your script.py (if that's a problem for you and your using windows just down load the free program WinSCP) however that wont happen with the attached index.html file.)
#!/usr/bin/python
# Toshi Bass
# Python 3.2 Raspbian (Wheezy)
# Imports
import webiopi
import os
import sys
import subprocess
import time
# Enable debug output
webiopi.setDebug()
from webiopi.utils.logger import info
# Retrieve GPIO lib
GPIO = webiopi.GPIO
from webiopi import deviceInstance
Temp0 = webiopi.deviceInstance("Temp0")
Temp1 = webiopi.deviceInstance("Temp1")
LED1 = 23
heat0 = 24
heat1 = 25
##################################################################
# Called by WebIOPi at script loading
##################################################################
def setup():
webiopi.debug("Script with macros - Setup")
GPIO.setFunction(23, GPIO.OUT)
GPIO.setFunction(24, GPIO.OUT)
GPIO.setFunction(25, GPIO.OUT)
##################################################################
# Setup Globals
##################################################################
##################################################################
# Setup Vars
##################################################################
temp0 = "%.2f" % (Temp0.getCelsius())
temp1 = "%.2f" % (Temp1.getCelsius())
heat_setpoint = 60
##################################################################
# Define Functions
##################################################################
def switch():
global heat_setpoint,temp0,temp1,heat0,heat1
if int(float(temp0)) < heat_setpoint:
GPIO.digitalWrite(heat0, 1)
else:
GPIO.digitalWrite(heat0, 0)
if int(float(temp1)) < heat_setpoint:
GPIO.digitalWrite(heat1, 1)
else:
GPIO.digitalWrite(heat1, 0)
##################################################################
# Looped by WebIOPi
##################################################################
def loop():
# Toggle LED each 4 seconds
value = not GPIO.digitalRead(23)
GPIO.digitalWrite(23, value)
print()
print("_______________watch_dog",int(value))
print()
switch()
webiopi.sleep(4)
##################################################################
# Called by WebIOPi at server shutdown
##################################################################
def destroy():
webiopi.debug("Script with macros - Destroy")
##################################################################
# Macros
##################################################################
@webiopi.macro
def get_temp(arg0,arg1):
global temp0,temp1
print(temp0,temp1)
return("%s %s" % (temp0,temp1))
##################################################################
After you past in the the python code into script.py and move the attached index.html into the same folder, start webiopi in debug mode sudo webiopi -d -c /etc/webiopi/config to be able to see any errors etc stop with ctrl c
Hope it helps
Toshi