PyDev of the Week: Paulus Schoutsen

This week's PyDev of the Week is Paulus Schoutsen (@balloob). He is the founder of Home Assistant, an open source home automation tool / package.

You can see what else Paulus is up to over on his GitHub profile.

Paulus Schoutsen

Let's take a few moments to get to know Paulus better!

Can you tell us a little about yourself (hobbies, education, etc):

I am from the Netherlands but have been living now in California for the last 9 years. Currently in Irvine. I have a Bachelor and Master from the University of Twente in Business & IT.

Hobby and work got conflated, as I am working nowadays full-time on Home Assistant. For 5 years I did it on the side and the last 3 I’ve been doing it full-time. We’ve come a long way since then and since I went full-time a lot of focus has been put on making it easier to use. Anything that’s easier to use will get more adoption, and we’ve for sure seen that with Home Assistant. Last year we were #2 most active Python project on GitHub.

What is great about Home Assistant is that it allows you to use your Python knowledge at home and improve your life and that of your family.

I’ve been looking for new hobbies but they usually result in working on things that plug into Home Assistant (because everything does). My last project was setting up LED strip with open source control software WLED. It turned out really neat.

Why did you start using Python?

It was back at university. We had to build a web app, wanted to try something new and ended up with Flask. It was a nice easy way to get something online quick.

Later during my Master thesis I used it a lot for data processing. That was also the time I started on Home Assistant. I didn’t have much experience with Python and just went with it. It used to be a big playground trying out new technologies or technical concepts that I was learning about. Nowadays that’s no longer possible as we estimate over 350 000 households worldwide rely on Home Assistant.

What other programming languages do you know and which is your favorite?

I feel comfortable with JavaScript and TypeScript. It’s what we use for the Home assistant frontend. TypeScript is great because the type system works like the one in Python: you get type safety at compile time, types can be turned off when they get in the way and it has union types. Union types are great because it gives functions more flexibility on what to return and is another way the type system doesn’t get in the way.

What projects are you working on now?

Home Assistant! The project is ever expanding. We integrate over 1800 different devices and services. But we don’t just integrate these, we build features on top. To name a few:

  • Dashboard to get insight into the state of your house and control devices (see https://demo.home-assistant.io)
  • Home automation like being able to turn on the lights when the sun sets.
  • Support for NFC tag readers to let your kids pick songs for the living room.
  • Energy management to get insight in– and optimize your energy usage (see https://demo.home-assistant.io/#/energy)

But besides Home Assistant I am also involved with ESPHome. ESPHome is a Python-based firmware generator for ESP8266 and ESP32 microcontrollers. It allows users to connect sensors to these microcontrollers, write a configuration file describing the board and which sensor is connected which pin and ESPHome will generate a firmware and install it on the microcontroller. While Home Assistant is the brains of your house, ESPHome provides the eyes and ears.

Which Python libraries are your favorite (core or 3rd party)?

Asyncio! It’s such a powerful primitive. A couple of years ago we’ve switched the Home Assistant core from a thread worker pool to asyncio and it has had our work so much easier.

One big benefit is that if you do many different things at the same time, like querying the state of all devices in your house, you don’t need a thread for each task. Instead, it’s all done in asyncio tasks which are very lightweight and you can run as many as you want at the same time. This makes for a powerful core.

The other big benefit is that the caller of the code remains in control. For example, if a device is not responding, Home Assistant can enforce a timeout or decide for other reasons it no longer cares. It doesn’t have to rely on passing a timeout object all the way down.

How did the HomeAssistant package come about?

In 2012 Philips released the Philips Hue lights. I bought them and installed them in my house. I was excited because the lights had an API! So in Python I managed to interact with this API and give me control over them. But then what? So I decided to turn the lights on when the sun was setting. Then I realized that the lights turned on when no one was home so added presence detection. Then I realized at sun set it was already too dark and instead we should look at the sun angle. Then I realized… etc etc 🙂

Creating a Python application that needs to be consumed by end users is hard. Users struggle with Python virtual environments, keeping them up to date, Python upgrades and compiling C-extensions. A real life saver for us has been containers. We ship a container with the right Python version and dependencies tuned for running Home Assistant. We have our own wheel build server where we build thousands of wheels for all the different architectures that we support. We use Alpine as our base OS in our containers and so cannot use the wheels on PyPI (yet).

Because we realized that even running containers is too difficult for many users, we’ve made our own operating system. It is a minimal Linux distribution that runs Home Assistant in a container. It allows the user to update Home Assistant now via a button in the UI. If an update fails – we automatically roll back.

Nowadays you can buy a Raspberry Pi 4 kit, download the Home Assistant image and you get your own smart home hub with a focus on local control and privacy. All your data stays local. All for free.

Where do you see home automation going in the future?

I like to look at it from a “smart home” perspective. The term “home automation" doesn’t tickle the imagination enough. For example, we just added energy management to help people gain insight, save energy and transition to sustainable energy sources.

With Home Assistant we want to support people living their life and not spend time on our product. It runs, it does the things you tell it to do, it gives you the insights you need and that’s enough.

As technology becomes more advanced, I expect it more and more disappear and helping in the background.

Is there anything else you’d like to say?

Have fun with code! When people think of code or open source they immediately think it is to boost your resume for your next job. However, there are so many other great reasons to do open source, the main one to have fun. Make silly things. Don’t worry about linters, tests or whatever. Don’t apply work or big project processes to your small projects.

One of the reasons I love Home Assistant so much is that it allows me to create things that influence the world around me. Is having the lights turn on when the sun sets necessary? No, but it’s convenient and I am lazy. Could I play songs for my children instead of having them play it themselves using NFC cards? Sure, but kids love it to see their actions have effect. That’s why they always want to snatch that remote. Empowering them to play songs makes them happy.

Thanks for doing the interview, Paulus!

Copyright © 2021 Mouse Vs Python | Powered by Pythonlibrary