Pytomation is an extensible device communication and automation system written in Python. It's uses include home automation and lighting control but is certainly not limited to that. It is supported on any platform that supports Python ( Windows, Mac OS-X, Linux, etc )
Python Java JavaScript CSS Arduino HTML Shell
Pull request Compare This branch is 49 commits ahead, 4 commits behind zonyl:master.
Permalink
Failed to load latest commit information.
.settings Setup Eclipse / PyDev project files. Implement first real TDD test. Jun 13, 2012
HomeControl pytomation_web -> Added "Desktop" code to Home Control and made it th… Jan 18, 2015
PyHomeRemote I have no idea how it disappeared from git, but recommitting Jul 24, 2014
contrib Add support for Groups and fix add new bulb Jan 9, 2016
docs Added note to use web for updated docs Jan 22, 2016
instances Instance -> Lets move my graburns out of the user folder. Created a C… Jan 23, 2013
pytomation Updated status check so it won't trigger unless required Jan 26, 2016
pytomation_django Pytomation UI -> Create Initial DJANGO project and app. This is proab… Dec 16, 2012
pytomation_ui Pytomation UI -> Create Initial DJANGO project and app. This is proab… Dec 16, 2012
pytomation_web pytomation_web->Fixed runtime theme switching Jan 3, 2016
tests Fix thermostat unit tests Dec 18, 2014
uno_sketch probeport - Add Arduino to list of devices. Feb 27, 2013
.gitignore merging texnofobix/pytomation Mar 22, 2015
.project
.pydevproject Organize code a bit better Jun 14, 2012
AUTHORS Admin commit Nov 29, 2014
LICENSE Update LICENSE Sep 17, 2012
README.md Adding Phillips HUE Jan 4, 2016
clean.sh Add clean.sh to remove all *.pyc files Dec 15, 2012
install.sh
manage.py Pytomation UI -> Create Initial DJANGO project and app. This is proab… Dec 16, 2012
probeport.py Bump version Feb 27, 2013
pytomation.init More robust init script Jul 1, 2014
pytomation.py More robust init script Jul 1, 2014
pytomation.sh Add logging for STDERR so faults are not missed Jan 17, 2014
requirements.txt Adding phue requirement Jan 4, 2016
runtests.sh Tests - > Enable test runs from command line. Jan 23, 2013
setup.py

README.md

Pytomation


Pytomation is an extensible device communication and automation system written in Python. It's uses include home automation and lighting control but is certainly not limited to that. It is supported on any platform that support Python ( Windows, Mac OS-X, Linux, etc )

Supported

Pytomation currently has support for the following hardware interfaces with more planned in the future.

Future

  • Weeder Analog I/O board (Wtaio/RS232)
  • Ube Wifi Devices
  • CoralStar WiFi Devices

FEATURES

  • Written in Python
  • REST API
  • Mobile Web and Android clients w/ continuous device state updates (web-sockets)
  • Voice Commands from Android (“Home Control” app)
  • Local Telnet and Web access
  • Unique language to describe devices and actions
  • Smart objects: Doors, Lights, Motion, Photocell etc.
  • Optional “Mainloop” programming, for more complicated control
  • Optional “Event driven” programming, for complex actions when a device state changes
  • Time of day on and off control
  • Delays for time off
  • Idle command, device will return to "idle" state
  • Map one command to another with optional source and time
  • Good hardware support with more coming
  • Very easy to add new hardware drivers
  • Good documentation complete with examples
  • Much more

INSTALLATION

DEPENDENCIES

Before you can create an instance and run Pytomation automation software you must satisfy a few dependencies. Pytomation is written in Python and currently has been tested under versions 2.6.x and 2.7.x.

Pytomation also requires the following packages to be installed for normal operation:

  • pySerial - Support for RS232 serial interfaces.
  • Pyephem - High-precision astronomy computations for sunrise/sunset.
  • Pytz - World timezone definitions.
  • APScheduler - Advanced Python Scheduler

Optional Packages:

  • python-gevent - A coroutine-based Python networking library (PytoWebSocketServer)
  • python-openssl - Allows the PytoWebSocketServer to use native SSL (https and wss connections)

Additional packages are required for development and testing. See requirements.txt for a more complete list.

Debian packages are available for pySerial, pytz, python-gevent, and python-openssl. They can be installed with :

sudo apt-get install git python-dev python-serial python-tz python-gevent python-openssl

For other operating systems, search your package manager for the equivalent packages or use pip to install the Python dependencies.

The remaining dependencies can be installed with pip. Pip is a tool for installing and managing Python packages, such as those found in the Python Package Index.

Again, under Debian distributions you can install the python-pip package:

sudo apt-get install python-pip

Once pip is installed it is easy to install the rest of the dependencies with the following commands:

sudo pip install pyephem 
sudo pip install APScheduler

To use the optional websocket server:

sudo pip install gevent-websocket

The gevent-websocket server is pretty fast, but can be accelerated further by installing wsaccel and ujson or simplejson

sudo pip install wsaccel ujson

Build openzwave and python-openzwave

Aeon Labs Z-Wave requires python-openzwave, which must be compiled from source. It's highly recommend you use the archived source code. Version 3.0+ no longer requires Cython, which was the source of most of the build/seg fault issues with python-openzwave. 3.0beta2 has been tested to work on both a 64bit Ubuntu 14.04 system and a Raspberry PI. Instructions are at https://github.com/OpenZWave/python-openzwave/blob/master/INSTALL_ARCH.txt.

The config for OpenZwave will be located in the extracted archive, at openzwave/config. I recommend copying the config to your system /etc:

sudo cp -R openzwave/config /etc/openzwave
sudo chown -R pyto:root /etc/openzwave
sudo chmod 660 /etc/openzwave/options.xml

Also note that if you have any security devices in your Zwave network, you will need to set the NetworkKey option in options.xml. That network key is why it's recommend to change the file permissions on options.xml, so only root and the pyto user can read it.

Permissions

Like with all other interfaces. Make sure the pyto user account owns or otherwise has permissions to use the device. You may want to give your own usr account access as well.

sudo chown youruseraccount:pyto /dev/yourzwavestick
sudo chmod 770 /dev/yourzwavestick

or

sudo chown pyto:pyto /dev/yourzwavestick
sudo chmod 770 /dev/yourzwavestick

Make Permissions Permanent

Add the following either /etc/udev/rules.d or /lib/udev/rules.d (Similar procedure can be used for other serial interfaces. lsusb -v can grab the necessary ATTRS info.)

SUBSYSTEM=="tty", ATTRS{idVendor}=="10c4", ATTRS{idProduct}=="ea60", ATTRS{serial}=="0001", SYMLINK+="zwave", GROUP="pyto", OWNER="pyto"

ozwsh (OpenZWave Shell, for testing)

sudo pip install urwid louie
/ozwsh.sh --device=/dev/yourzwavestick

INSTALL

You are now ready to install pytomation. First, clone the pytomation git repository. Change into the pytomation repo directory and run ./install.sh. You may have to make it executable with the command chmod +x ./install.sh first. Install.sh can take an optional argument which points to an alternate installation directory:

 ./install.sh /some/other/folder/pytomation

The install.sh command does the following:

  • Confirms where you are installing Pytomation to.
  • Makes a "pyto" user and creates the home directory.
  • Copies all the necessary files into Pytomation's HOME.
  • Creates an /etc/init.d/pytomation init script for starting Pytomation on boot.
  • Configures pytomation to start automatically at boot time

You are now ready to configure pytomation and create an instance for your devices.