Blog

Using MQTT with Home Assistant

{::options coderay_line_numbers=“table” /}

MQTT support was added to Home Assistant recently. The MQTT component will enable you to do all sort of things. Most likely you will use it to communicate with your devices. But Home Assistant doesn’t care where the data is coming from or is limited to real hardware as long as there is MQTT support. This means that it doesn’t matter if the data is coming from a human, a web service, or a device.

A great example is shown in a Laundry Automation post in this blog.

This post will give you a small overview of some other possibilities on how to use MQTT with Home Assistant.

Read on →

0.7: Better UI and improved distribution

As Home Assistant is gaining more and more users we started to feel the pain from not having a proper release mechanism. We had no version numbering and required users to checkout the source using Git to get started. On top of that, as the number of devices that we support keeps raising, so did the number of dependencies that are used. That’s why we decided to change the way we roll. From now on:

  • Each release will have a version number, starting with version 0.7. This was chosen because it shows that we have been around for some time but are not considering ourselves to be fully stable.
  • Each release will be pushed to PyPi. This will be the only supported method of distribution.
  • Home Assistant is available after installation as a command-line utility hass.
  • The default configuration location has been moved from config in the current working directory to ~/.homeassistant (%APPDATA%/.homeassistant on Windows).
  • Requirements for components and platforms are no longer installed into the current Python environment (being virtual or not) but will be installed in <config-dir>/lib.

A huge shout out to Ryan Kraus for making this all possible. Please make sure you read the full blog post for details on how to migrate your existing setup.

And while Ryan was fixing distribution, I have been hard at work in giving Home Assistant a face lift. We already looked pretty good but lacked proper form of organization for users with many devices. The new UI moves away from a card per entity and has cards per group and domain instead. The demo has been updated so give it a spin.

Screenshots of the new UI

Read on →

Laundry Automation: insight and notifications

This is a guest post by Home Assistant user and contributor Nolan Gilley.

In our house, laundry has been a struggle for quite some time. Our washer and dryer both lack a buzzer which leads to forgotten laundry, and stinky mess that needs to be rewashed. I decided to create a solution by monitoring the washer and dryer myself with some cheap electronics.

As an avid user of Home Assistant, I decided it would be the perfect application to manage the UI and notification system. Now all I needed was a way to monitor the washer and dryer. I tried using sound sensors but found them unreliable. I ended up opting for an accelerometer attached to the back of each appliance. I also added magnetic reed switches on the doors of the washer and dryer to detect if the doors are open or closed. I connected the accelerometers and reed switches to a Moteino, an arduino clone with an RF transceiver. The Moteino can perform the logic to figure out which state the appliances are in and wirelessly communicate that data with another Moteino that is connected via serial to my Raspberry Pi. The Raspberry Pi reads the serial data and repeats it over MQTT for Home Assistant to use. This is great because I don’t have to run Home Assistant on the Raspberry Pi. I can run it on a faster machine and point the MQTT component to my Raspberry Pi.

After taking some sample data from the accelerometers while each appliance was in operation, I decided to plot the data to help determine the proper thresholds of when the devices were running or off. I had to do this in order to get precise ranges so the dryer sensor wouldn’t get tripped by the washer or vice versa. In the plot below you can see the acceleration in the x direction for the accelerometer connected to the washing machine. It’s easy to see when the washing machine is in operation here. I used the same technique for the dryer’s accelerometer.

Graph showing the accelerometer data

Read on →

Verisure devices and modern TP-Link routers now supported

A minor bug fix release to fix some issues that have come up since the last release. Please upgrade as soon as possible by running git pull from the Home Assistant directory.

This release is a major milestone in our test coverage as we’ve crossed into the 80s! It has to be noted that this covers mainly the core and automation components. Platforms that communicate with IoT devices have been excluded.

As we didn’t want to just push out bug fixes, this release includes a few additions:

  • Support for modern TP-Link routers like the ArcherC9 line has been contributed by @chrisvis.
  • Improved support for MQTT topic subscriptions has been contributed by @qrtn

Verisure Support Home Assistant support to integrate your Verisure alarms, hygrometers, sensors and thermometers has been contributed by @persandstrom.

# Example configuration.yaml entry
verisure:
  username: [email protected]
  password: password
  alarm: 1
  hygrometers: 0
  smartplugs: 1
  thermometers: 0

MQTT, Rasperry Pi, Logitech Squeezebox and ASUSWRT routers now supported

It’s time for the August release and there is some serious good stuff this time. The core of Home Assistant has gone some serious clean up and a bump in test coverage thanks to @balloob. If you’re a developer, make sure you read up on the deprecation notices. @fabaff did another great round of documenting all the various components.

MQTT Support The big new addition in this release is the support for the MQTT protocol by @fabaff with some help from @balloob. It will now be possible to integrate any IoT device that talks via MQTT. For the initial release we support connecting Home Assistant to a broker (no TLS yet). Components can now subscribe and publish to MQTT topics and also support for the automation component has been added. For more information, see the MQTT component page.

# Example configuration.yaml entry
mqtt:
  broker: IP_ADDRESS_BROKER
  # All the other options are optional:
  port: 1883
  keepalive: 60
  qos: 0
  username: your_username
  password: your_secret_password
Read on →

IP Cameras, Arduinos, Kodi and Efergy Energy Monitors now supported

Another month has passed and some great new features have landed in Home Assistant. This month release has been made possible by balloob, ettisan, fabaff, gyran, jamespcole, michaelarnauts, miniconfig and rmkraus.

This release includes some architectural changes by me. The first is that the frontend is now based on a NuclearJS JavaScript backend. This has greatly helped to organize and optimize the frontend code. Another change is that Home Assistant will now install dependencies on-demand instead of installing dependencies for all supported devices.

IP Camera Support James has worked very hard to add support for IP cameras to Home Assistant which is included in this release. The initial release focusses on providing generic IP camera support. This means that any webcam that can exposes a JPEG image via a URL can be integrated.

Home Assistant will route the requests to your camera via the server allowing you to expose IP camera’s inside your network via the Home Assistant app.

# Example configuration.yaml entry
camera:
  platform: generic
  name: my sample camera
  username: MY_USERNAME
  password: MY_PASSWORD
  still_image_url: http://194.218.96.92/jpg/image.jpg

Note

To update to the latest version, run scripts/update. Please report any issues on GitHub.

Read on →

Release notes for June 10, 2015

Wow, almost a month has gone by since the last release and this release is packed. The biggest part of this release is probably one that you won’t notice: the frontend has been upgraded from Polymer 0.5 to the brand new released Polymer 1.0. Polymer has been declared stable by the Google overlords which will allow us to expand functionality that was waiting for this moment to arrive.

This release sets a record for the amount of people involved: 8! Andythigpen, Jamespcole, Azelphur, Fabaff, Dutchy-, Fbradyirl, wind-rider and ettisan, thanks a lot for your contributions!

A big improvement has been brought this release by wind-rider. He took the time to revive the Chromecast support and started improving the media player integration. This triggered other people to join in resulting in a revamped media player experience and support for the Music Player Daemon.

Example of the new media player cards

Note

To update to the latest version, run scripts/update. Please report any issues on GitHub.

Read on →

Release notes for May 14, 2015

Almost three busy weeks have past since the last release. We used this time to finally make the overhaul to use UTC as the internal date time format. We added a bunch of test coverage in the process to make sure the transition went smoothly. Pleas see the blog post about the UTC refactor for backwards incompatible changes.

This release includes a significant startup boost for the frontend and a fix for Wemo discovery after their latest firmware upgrade.

I would like to give a big shout out to our newest contributor fabaff for taking the time to improve the documentation.

Note

To update to the latest version, run scripts/update. Please report any issues on GitHub.

Read on →

UTC & Time zone awareness

I have recently merged code to refactor Home Assistant to use only UTC times internally. A much needed refactor. I’ve added some extra test coverage to time sensitive parts to ensure stability. The code has been live in the dev branch for the last 9 days and will be soon released to the master branch.

From now on all internal communication will be done in UTC: time changed events, datetime attributes of states, etc. To get the current time in UTC you can call homeassistant.util.dt.utcnow(). This is a timezone aware UTC datetime object. homeassistant.util.dt is a new util package with date helpers.

There is also such a thing as local time. Local time is based on the time zone that you have setup in your configuration.yaml. Local times should only be used for user facing information: logs, frontend and automation settings in configuration.yaml.

Setting up your time zone

Setting up a time zone happens in configuration.yaml. If you have no time zone setup, it will be auto detected using the existing detection code using freegeoip.net. You can find a list of compatible time zones on Wikipedia.

homeassistant:
  time_zone: America/Los_Angeles

Compatibility

The changes to the code are mostly backwards compatible. The old hass.track_time_change and hass.track_point_in_time use now internally two new methods: hass.track_utc_time_change and hass.track_point_in_utc_time. The usage of the old methods have not changed and should be backwards compatible.

This refactor adds a new migration for the database adding a utc_offset column to events and states. This information is currently not used but can prove useful in the future when we start analyzing the historical data.

Backwards incompatible stuff

All built-in components have been upgraded. The following list is only for people that run custom components:

  • hass.track_time_change and hass.track_point_in_time will now return a time zone aware datetime object. Python does not allow comparing a naive with an aware datetime object.
  • the sun attributes for rising and setting are now in UTC. The methods sun.next_rising(hass) and sun.next_setting(hass) are backwards compatible, just be careful if you used to read the raw attributes.
  • the API sends all times in UTC. If you use anything else besides the frontend to talk to HA, make sure it handles it differently.

Release notes for April 25, 2015

It’s been a month since the latest update and a lot has happened again. Here a quick overview of the new things.

Line Charts James has upgraded the history in the frontend to support line graphs. Line graphs will be shown for any entity that has a unit of measurement. The line graphs will also be shown in the more info card of an entity. See the demo for a live example.

ISY994 hub support Ryan has contributed support to integrate the ISY994 hub by Universal Devices. This allows you to integrate your X10/Insteon sensors, switches and lights.

He has created an extensive getting started guide which can be found on the ISY994 component page.

# Example configuration.yaml entry
isy994:

Logbook I (Paulus) have added a logbook component. The logbook component provides a different perspective on the history of your house by showing all the changes that happened to your house in chronological order. See the demo for a live example.

# Example configuration.yaml entry
logbook:
Read on →