No GUI like AHP but here is small Python demo app with buttons for
On,Off,Bright,Dim. Should work on all Python platforms including Windows
and MacOS but only tested on Ubuntu Linux 10.04.
# Python demo interface to mochad. Pressing GUI buttons sends commands to
# mochad to turn lights on,off,bright,and dim. There must be a better way
# to avoid such repetive code. Should work on other support Python platforms
# such as Windows and MacOS but only tested on Ubuntu Linux 10.04.
#
from Tkinter import *
import socket
# Change this to localhost if this program runs on the same host as mochad. Or
# change to the correct IP.
MOCHADHOST="192.168.1.254"
MOCHADPORT=1099
def netcat(hostname, port, content):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((hostname, port))
s.sendall(content)
s.close()
def mochad(command):
netcat(MOCHADHOST, MOCHADPORT, command)
class App:
def __init__(self, master):
frame = Frame(master)
frame.grid()
Label(frame, text="Bedroom 1").grid(row=0)
self.bed1_on = Button(frame, text="On", command=self.bed1_on_cb)
self.bed1_on.grid(row=0,column=1)
self.bed1_off = Button(frame, text="Off", command=self.bed1_off_cb)
self.bed1_off.grid(row=0,column=2)
self.bed1_bright = Button(frame, text="Bright", command=self.bed1_bright_cb)
self.bed1_bright.grid(row=0,column=3)
self.bed1_dim = Button(frame, text="Dim", command=self.bed1_dim_cb)
self.bed1_dim.grid(row=0,column=4)
Label(frame, text="Bedroom 2").grid(row=1)
self.bed2_on = Button(frame, text="On", command=self.bed2_on_cb)
self.bed2_on.grid(row=1,column=1)
self.bed2_off = Button(frame, text="Off", command=self.bed2_off_cb)
self.bed2_off.grid(row=1,column=2)
self.bed2_bright = Button(frame, text="Bright", command=self.bed2_bright_cb)
self.bed2_bright.grid(row=1,column=3)
self.bed2_dim = Button(frame, text="Dim", command=self.bed2_dim_cb)
self.bed2_dim.grid(row=1,column=4)
# Callback functions invoked when buttons pressed.
# Change "pl" to "rf" if using a CM19A.
def bed1_on_cb(self):
print "bed 1 on"
mochad("pl b3 on\n")
def bed1_off_cb(self):
print "bed 1 off"
mochad("pl b3 off\n")
def bed1_bright_cb(self):
print "bed 1 bright"
mochad("pl b3 bright\n")
def bed1_dim_cb(self):
print "bed 1 dim"
mochad("pl b3 dim\n")
def bed2_on_cb(self):
print "bed 2 on"
mochad("pl b4 on\n")
def bed2_off_cb(self):
print "bed 2 off"
mochad("pl b4 off\n")
def bed2_bright_cb(self):
print "bed 2 bright"
mochad("pl b4 bright\n")
def bed2_dim_cb(self):
print "bed 2 dim"
mochad("pl b4 dim\n")
root = Tk()
app = App(root)
root.mainloop()