Image by Pixel-Shot on Shutterstock

Awesome Home Automation Libraries for Python

Jump Start Your Next Domotics Project

Mike Riley
4 min readNov 25, 2021

--

🎁 Black Friday Sale. Our annual sale is on now through November 29, 2021, save 40 percent on ebooks on The Pragmatic Bookshelf website using code turkeysale2021. For Turkey Day, we are featuring all Python books and all Hardware, Hobby and Home books, including Mike Riley’s new book, Portable Python Projects.

I am always on the lookout for new and interesting libraries to use for my Python projects. One particular category I seek out is home automation libraries. Following are the most helpful home automation Python libraries, listed in alphabetical order, that I have used in my own projects.

Home Assistant

The Home Assistant is a huge Python framework that includes the ability to manage a variety of home automation hardware and services. It can integrate with Amazon Alexa, Google Assistant, Lutron, Philips Hue, Plex, Sonos, Z-wave, and Zigbee devices — just to name a few. Scripting is defined in YAML files that call upon or trigger targeted services, such as lights on in a specific sequence. Install the library using the following pip command:

$ pip install homeassistant

Pyecobee API Wrapper

The ecobee API can be called upon to control a spectrum of ecobee-embedded thremostats (). While the Home Assistant offers ecobee integration, sometimes all you want to do is check the temperature. The pyecobee API wrapper provides a Pythonic interface to call upon the ecobee JSON objects to query and control the device. Install the wrapper using the following pip command:

$ pip install pyecobee

phue Philips Hue Python Library

One of the most used home automation libraries in my Python toolbox is phue. Phue is a Pythonic interface used to communicate with the Philips Hue Bridge hardware, thereby controlling the entirety of Hue appliances associated with that bridge. Thanks to the simple setup and command structure of issuing Hue commands, phue makes it easy to create elaborate Python scripts to control every facet of your Philips Hue accessorized environment. I called upon the phue library in several of the projects featured in my Python home automation book, Portable Python Projects. Install the phue package using the following pip command:

$ pip install phue

PushNotif (IfTTT Notifier)

PushNotif is a relatively young and basic Python project library that leverages the IFTTT service and its accompanying free Android or iOS application to use that service’s push notification to send and display a pop-up alert on your phone. While such notifications can be sent via email, text, or chatbot services hosted on Discord or Slack, those services require additional code and configuration to get working. If all you want is something like a simple pop-up showing on your phone when, say, the temperature in your basement drops below 60 degrees Fahrenheit, a temperature sensor attached to a Pi can trigger the PushNotif message and use your IFTTT account and associated mobile phone app to alert you. Install the PushNotif library using the following pip command:

$ pip install pushnotif

PyVizio Soundbar Control

Vizio SmartCast TVs and soundbars are budget-priced home entertainment products that expose their control functions via WiFi. Vizio offers a free mobile app to control their SmartCast products, but its interface is kludgy and rather ugly, in my opinion. Additionally, I would rather control these devices via Alexa or Google Voice, which at the time of this article’s publication is planned but not yet officially supported. Using the same approach discussed in the voice projects in my book, I use Google Voice to turn on and off both my Philips TV (via IR) and its accompanying Vizio soundbar (via WiFi), keeping my phone in my pocket and shielding my eyes from that ugly Vizio app. To install the pyvizio library, use the following pip command:

$ pip install pyvizio

Samsung Smart TV

For those of you who own a member of the popular family of Samsung TV WiFi-connected displays, you can control these TVs using the samsungtvws Samsung Smart TV WS API wrapper. Similar to the other API wrappers covered in this article, this Python project provides a Pythonic interface to the manufacturer’s exposed API, making it simple to register and control the device from a Python script. Install the samsungtvws package using this pip command:

$ pip install samsungtvws

I use several other Python libraries in my home environment to check local weather, communicate with my local network monitoring, and use automation-related web services, but those general-purpose libraries go beyond the scope of home automation.

👓 If there are other Python home automation libraries not mentioned in this article that you would like to share with fellow readers, please leave a comment — and thanks for reading my article!

--

--