An extensible device communication and automation system written in Python.
10K+
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 )
Pytomation currently has support for the following hardware interfaces with more planned in the future.
Before you can create an instance and run Pytomation automation software you must satisfy a few dependencies. Pytomation is written in Python and is currently being tested well with version 3.6.x, on the Raspberry Pi and Amd64 architectures. There are also pre-built docker images (auto-built by Docker Hub) available at https://hub.docker.com/r/dheaps/pytomation/, or you can build a Docker image, with the Dockerfile.
Pytomation also requires the following packages to be installed for normal operation:
Optional Packages:
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 pip3. Pip3 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 python3-pip package:
sudo apt-get install python3-pip
Once pip is installed it is easy to install the rest of the dependencies with the following commands:
sudo pip3 install pyephem
sudo pip3 install APScheduler
To use the optional websocket server:
sudo pip3 install gevent-websocket
The gevent-websocket server is pretty fast, but can be accelerated further by installing wsaccel and ujson or simplejson
sudo pip3 install wsaccel ujson
The other pip3 packages are listed in requirments.txt and are optional. They are only necessary to use the interface that, which uses that package. For Example, for Phillps Hue support, install the phue package.
Utilize the scrit created by Dobes Vandermeer at https://gist.github.com/dobesv/13d4cb3cbd0fc4710fa55f89d1ef69be
Copy the cert and key files for the server cert (not the root CA) to the ssl folder (or /secured/ssl for docker) as server.crt and server.key
To import the root CA, on your client devices, so all your generated certificates work on your devices follow the steps from: https://thomas-leister.de/en/how-to-import-ca-root-certificate/
To create a cert that can be imported into the android system, using root privelege (does not work with the latst android 11): https://blog.jeroenhd.nl/article/android-7-nougat-and-certificate-authorities#howto-install
openssl x509 -inform PEM -subject_hash_old -in /etc/ssl/certs/cacert.pem | head -1
cat /etc/ssl/certs/cacert.pem > [outputFromFirstCommand].0
openssl x509 -inform PEM -text -in /etc/ssl/certs/cacert.pem -out /dev/null >> [outputFromFirstCommand].0
Example
cat /etc/ssl/certs/cacert.pem > 5ed36f99.0
openssl x509 -inform PEM -text -in /etc/ssl/certs/cacert.pem -out /dev/null >> 5ed36f99.0
Resulting file must be copied to /system/etc/security/cacerts/ on android system.
For the latests Android you must secure your device with pin/patern/etc, copy to your sdcard with the .crt extension, and open it. Android will prompt you to import as a "user" cert. (you can no longer add system cert, unless you roll your own rom or use a Magisk trick.
For Firefox Mobile save the cert to your sdcard and browse to it in firefox like file:///storage/emulated/0. Once you click on your cert it will prompt you to import.
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.
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
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"
sudo pip install urwid louie
/ozwsh.sh --device=/dev/yourzwavestick
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. If you chose that option, be sure to update /etc/init.d/pytomation with the correct installation directory:
./install.sh /some/other/folder/pytomation
The install.sh command does the following:
You are now ready to configure pytomation and create an instance for your devices.
Content type
Image
Digest
sha256:bad8486c7…
Size
481.8 MB
Last updated
2 months ago
docker pull dheaps/pytomation