Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Marek Kuziel: Python in Home Automation

Marek Kuziel: Python in Home Automation

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
Marek Kuziel:
Python in Home Automation
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
@ Kiwi PyCon 2013 - Sunday, 08 Sep 2013 - Track 1
http://nz.pycon.org/

**Audience level**

Intermediate

**Description**

Using Python to build a Home Automation system by connecting various bits of (open) hardware with protocols such as MQTT, or XMPP. Creating web-based interfaces for HA systems.

**Abstract**

Protocols: brief introduction to MQTT and XMPP protocols. Introduction to related Python tools/libraries.

Hardware: using hardware such Arduino, or Beaglebone as components for a DIY home automation systems.

Low-level: serial communication, MQTT communication, XMPP communication using Python.

High-level: web-based interface(s) for a Home Automation system made in Python.

Connecting the dots: general overview of how Python can be used in Home Automation.

**YouTube**

http://www.youtube.com/watch?v=hXnDyHidDqo

New Zealand Python User Group

September 08, 2013
Tweet

More Decks by New Zealand Python User Group

Other Decks in Programming

Transcript

  1. TL;DR Everything you need is already out there Do NOT

    try to reinvent the wheel If it feels wrong, it is wrong
  2. How It Works? Sensor – Button, Light, Sound, Smoke, Temp

    Controller – ATMega, ARM / C, Python Actuator – Relay, Servo Motor
  3. 5 Senses of Home Sight – Cam, Ultra-Sonic, Night, Motion

    Hearing – Sound Sensors Smell – Smoke Sensors Touch – Buttons, Tablet, Mobile, Web UI Temperature – Heating, Blinds, A/C
  4. /me sobers up Idea is NOT new Proof of concept

    ≠ production ready Production ready implementation already exists
  5. MQTT “MQTT is a machine-to-machine [sic] connectivity protocol. It was

    designed as an extremely lightweight publish/subscribe messaging transport.” – mqtt.org
  6. mosquitto - Python MQTT Term 1 $ cat << 'EOF'

    > my_test_client_publish.py > #/usr/bin/env python > import mosquitto > client = "my-test-client" > c = mosquitto.Mosquitto(client) > c.connect("127.0.0.1", 1883, 60) > c.publish("house/announce", "Hello, World! -- %s" % client) > EOF Term1 $ python my_test_client_publish.py Term1 $ mosquitto_pub -t "house/announce" -m "hello there" Term2 $ sudo apt-get install mosquito Term2 $ sudo apt-get install python-mosquitto Term2 $ mosquitto_sub -t "house/announce" Hello, World! -- my-test-client Hello there
  7. XMPP “The Extensible Messaging and Presence Protocol (XMPP) is an

    open technology for real-time communication, which powers a wide range of applications including instant messaging, presence, multi-party chat, voice and video calls, collaboration, lightweight middleware, content syndication, and generalized routing of XML data.” – xmpp.org
  8. gevent-socketio – Socket.io Python “Socket.IO enables real-time web communications between

    a browser and a server, using a WebSocket-like API.” – github.com/abourget/gevent-socketio
  9. Links • http://arduino.cc • http://freetronics.com • http://jajcus.github.io/pyxmpp2/ • http://kuziel.info/home-made/home-automation/mqtt/ •

    http://mqtt.org • http://mosquitto.org/man/mqtt-7.html • https://github.com/binarybucks/homA • http://en.wikipedia.org/wiki/PID_controller • http://seeedstudio.com • http://xmpp.org/