Print Shortlink

Home Assistant – home automation in Python

TL, DR:  Python project that you can run on your Raspberry Pi/server/HTPC that will monitor your devices and provides triggers and APIs to control them. Grab Home Assistant from GitHub

Since I acquired my Philips Hue bulbs late 2012 I have been interested in the “Internet of Things”. Ever since I felt like it was time for automating my house. I imagined it couldn’t be so hard so in September 2013 I decided to start from scratch using Python.

My initial goal for the project was a simple script that would:

  • query the router to see which devices are connected
  • turn lights on when people get home after sunset
  • turn lights off when everyone is gone but lights are still on

Once that was done I noticed it gets darker while the sun is setting. Wouldn’t it be nice if the lights would start fading in before the sun actually sets to compensate the dusk.

Fast forward 3 months and a lot of “wouldn’t it be nice if” moments later Home Assistant is mature enough and ready for it’s first release. And because a picture says more then a 1000 words. Let’s start with a screenshot of the web interface:

Home Assistant dashboard

Home Assistant dashboard

It is currently able to:

  • Track if devices are home by monitoring connected devices to a wireless router (currently supporting modern Netgear routers or routers running Tomato firmware)
  • Track which lights are on
  • Track what your Chromecasts are up to
  • Turn on the lights when people get home when the sun is setting or has set
  • Slowly turn on the lights to compensate for light loss when the sun sets and people are home
  • Turn off lights and connected devices when everybody leaves the house
  • Start YouTube video’s on the Chromecast
  • Quit current running application on a Chromecast
  • Download files to the host machine
  • Open a url in the default browser at the host machine
  • Simulate key presses on the host for Play/Pause, Next track, Prev track, Volume up, Volume Down
  • Controllable via a REST API and web interface
  • Support for thin client Home Assistant instances that will forward all their commands to the main instance
  • Android Tasker project to control Home Assistant from your phone and report charging state. Combine it with AutoVoice to be able to tell your phones to turn the lights off!

Adding rules or functionality is as simple as writing small Python snippets that get triggered on a state change or get exposed via the API as a service. An example rules that could be implemented: When the Chromecast starts running the PlayMovies app (and thus a movie is being played): call service to dim the lights.

Grab Home Assistant from GitHub

Leave a Reply