loading
1Comments

Tell us about yourself!

Complete Your Profile
  • Home Automation with Amazon Echo voice control

    ok I have been having a little fun with this. With an Adafruit Huzzah 8266 I have Alexa-enabled my 10 year old Cuisinart coffee pot.How I did it.1) I modified this code to add an MQTT handler. I don't know Python, and have never used an object oriented language before (I cut my teeth on Fortran 77 and assembler on the IBM 360), so it might be a bit ugly. ######################################################################################## MCW Added for MQTT Handlingimport paho.mqtt.client as mqttimport threadingMQTT_HOST = "mqtt.home.private"MQTT_PORT = 1883class mqtt_handler(object): def __init__(self, topic, on_cmd, off_cmd): self.topic = topic self.on_cmd = on_cmd self.off_cmd = off_cmd def on(self): client.publish(self.topic, self.on_cmd) return True def off(...see more »ok I have been having a little fun with this. With an Adafruit Huzzah 8266 I have Alexa-enabled my 10 year old Cuisinart coffee pot.How I did it.1) I modified this code to add an MQTT handler. I don't know Python, and have never used an object oriented language before (I cut my teeth on Fortran 77 and assembler on the IBM 360), so it might be a bit ugly. ######################################################################################## MCW Added for MQTT Handlingimport paho.mqtt.client as mqttimport threadingMQTT_HOST = "mqtt.home.private"MQTT_PORT = 1883class mqtt_handler(object): def __init__(self, topic, on_cmd, off_cmd): self.topic = topic self.on_cmd = on_cmd self.off_cmd = off_cmd def on(self): client.publish(self.topic, self.on_cmd) return True def off(self): client.publish(self.topic, self.off_cmd) return Truedef on_publish(client, userdata, mid): if DEBUG: print("mid: " + str(mid))def on_connect(mosq, obj, rc): if DEBUG: print("rc: " + str(rc))#######################################################################################FAUXMOS = [ ['kitchen lights', mqtt_handler('home/lights/kitchen', 'on', 'off'), 52000], ['bar lights', mqtt_handler('home/lights/bar', 'on', 'off'), 52001], ['dining room lights', mqtt_handler('home/lights/dining', 'on', 'off'), 52002], ['entry lights', mqtt_handler('home/lights/entry', 'on', 'off'), 52003], ['office lights', mqtt_handler('home/lights/office', 'on', 'off'), 52004], ['bedroom lights', mqtt_handler('home/lights/bedroom', 'on', 'off'), 52005], ['living room lights', mqtt_handler('home/lights/living', 'on', 'off'), 52006], ['coffee', mqtt_handler('home/coffee/brew_cmd', 'on', 'off'), 52101], ['east blinds', mqtt_handler('home/blinds/east', 'on', 'off'), 52201], ['south blinds', mqtt_handler('home/blinds/south', 'on', 'off'), 52202]]######################################################################################## MCW Added for MQTT Handlingif __name__ == "__main__": # Startup the MQTT client in a separate thread client = mqtt.Client() client.connect(MQTT_HOST, MQTT_PORT, 60) client.on_connect = on_connect client.on_publish = on_publish ct = threading.Thread(target=client.loop_forever) ct.daemon = True ct.start()#######################################################################################2) I run a Mosquitto MQTT server on my local CentOS system3) I wrote C code for the Huzzah to join my wireless network, connect to the MQTT server, and subscribe to the appropriate topic.Now I can turn my coffee on and off without getting out of bed, so lazy!

    View Instructable »