Home Automation with “Awesome” HASS.IO — Part I

Let me begin by saying that I am a newbie when it comes to home automation. During the past few months, I have come across so many tools and devices that I am absolutely fascinated with the potential that home automation projects have. I will start by charting a course in my home automation journey, which isn’t much, but nevertheless, is a good beginning. This is a three part series. In each post, I have tried to focus only on the integration of the systems and have deliberately tried to veer away from information that can be easily followed from other sources. At the same time,I have tried to provide the relevant links for this kind of available information.

Device Map

Balcony — There are couple of Ikea Trädfri bulbs in the balcony that are connected to a common Trädfri Remote Control. There is also a Trädfri Gateway that enables controlling the lights using Ikea’s Smart Home App. Using the smartphone app, I can set custom timers to turn these lights ON and OFF respectively. However I cannot configure the lights to turn ON automatically at sunset or turn OFF automatically at sunrise.

Top Floor — There is a temperature and humidity sensor in one of the bathrooms. This is a Xiaomi Sensor that uses BLE (Bluetooth Low Energy) to advertise temperature and humidity readings. I can connect to the sensor using Xiaomi’s Mi Home App and see the instantaneous temperature and relative humidity values. However BLE range is quite poor and the smartphone has to be within 5–7 meters to effectively connect to the sensor. Besides, I do not have a BLE Gateway, which means there is no way I can collect and store values from the sensor for a historical view. There is also a Google Home Mini in the hallway that can be used to control the lights in the balcony. But I cannot use Google Assistant to tell me the temperature and humidity values from the Xiaomi sensor.

Basement — There is a Xiaomi temperature and humidity sensor similar to the one on the top floor and it has the same problems as described above.

At one point I was thinking of investing in a BLE-WiFi Gateway that will help solve the problem with the sensors’ data. However these sensors are placed so far apart that I will not be able to use one single gateway to connect to both sensors — reason being the poor range and interference.

Why HASS?

Installation

Light On @ Sunset / Light Off @ Sunrise

homeassistant:
latitude: <find from Google Maps>
longitude: <find from Google Maps>
elevation: <find from freemaptools.com>
unit_system: metric/imperial
time_zone: <find from the timezone database>
name: <name for the hass instance>

More details can be found here. Once this is done, restart HASS to reflect the new configuration. Now, the “Weather Card” shows local weather information more accurately.

Once the required entities (lights and weather) are in place, we need to configure an “Automation” that will toggle the lights based on Sun’s state. Follow the breadcrumbs: HASS → Configuration → Automation → +. On the landing page, there are options to define an automation. For “Trigger” select “Sun” and appropriate event (Sunrise/Sunset). Finally specify the “Actions” to turn on/off the lights. For example to turn off lights at sunrise, action settings would be something like this:

Actions setting to turn lights off

Note that configuration files use YAML syntax. The entity ids for the lights (or any other entities) can be found from: HASS → Configuration → Entity Registry. A similar automation will be needed to turn on the lights at sunset. Once the configuration is done, save the changes and restart HASS. Here’s a snapshot from the Logbook entries (HASS → Logbook) when the automation is triggered based on sunrise:

Automation Logbook

That’s it! For more exotic weather based automation here are more examples.

This solves the problem with the lights in the balcony. In the next post, we will see how HASS can be used to collect and store sensor values from Xiaomi’s BLE based temperature and humidity sensors.

Technology Enthusiast!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store