Blog
OpenEnergyMonitor

emonPi as a Home Automation Hub

I believe automation can play an useful role in helping to reduce energy consumption. For example being able to control my home central heating system remotely enables me to only turn on the heating when it’s required and not have it running on a set schedule when the house is empty.

As previously mentioned in a blog post, the emonPi (running emonSD pre-built SD card) can function as a powerful home automation hub. Utilising the emonPi as a home automation hub is a good fit for a number of reasons:

  • It’s already running 24/7 for energy monitoring
  • It’s optimised for robust long term operation: the root Raspberry Pi file-system is read-only to increase SD card lifespan
  • It’s already connected to your local network
  • It’s running Debian Raspbian Jessie therefore installing extra packages is easy and lots of support is available
  • Raspberry Pi 3 has plenty of space capacity
  • Extra radios / accessories can be connected via USB
  • It’s already running an MQTT server
  • emonSD pre-built SD card comes pre loaded with the following integrations nodeRED, OpenHAB and LightWaveRF

In this post I want to share with you how I use the emonPi in my own home.

Here is a video demo using Google Home to control my central heating and devices via MQTT:

Read on to learn how this is achieved using an emonPi and open-source software…

There are many many options when it comes to home automation and control. Where possible I prefer open-source solutions which do not depend on any third-party services. All the software services for my home system as I describe in this post runs locally on my emonPi and apart from Google Home voice integration does not require an internet connection to function. A self-hosted open-source solution has the added benefit of increased privacy and security which you are in fully in control of.

MQTT

MQTT lightweight communication protocol is used as the ‘glue’ communication layer between all the following services. See technical/MQTT section of the User Guide for more info about how MQTT works on the emonPi.

Energy Monitoring

Emoncms…obviously!

Recently I have been loving using the V2 Emoncms Android app (currently in beta) which supports multiple pages (see forum thread).

Video demo Emoncms Android app V2 beta:

I have also recently enjoyed using the redesigned Emoncms Apps module which have just bee released on Emoncms.org. It’s now possible to have more than one MyElectric or MySolarPV ‘app’ per Emoncms account and Economy 7 split time of use tariffs are now spported (see forum thread):

myelectric-e7.png

Control

Central Heating

To control my gas central heating boiler I use an MQTT WiFi relay which also has a built in thermostat and scheduler, although I don’t use these features, I just control directly via MQTT. The WiFi Relay has been very reliable, it’s been used daily for the past two years in my home and never once required a reboot.

mqtt-relay-overview.png

Plug sockets (lights)

I use LightWave RF plugs to which I have lights and other entertainment devices connected e.g. stereo and chromecast. Being able to switch a whole plug bank on/off has the advantage of being able to turn devices fully off when not in use to minimise any vampire drain.

The emonPi can control LightWave RF devices directly via MQTT if an RF OOk modules is fitted. See LightWave RF emonPi User Guide.

lightwave-rf-diagram.png

LightWave RF devices are not perfect, the OOK RF protocol is simplistic, unsecure, occasionally unreliable and state feedback is not available. I am considering swithcing to ESp8266 based Sonoff plug with third party MQTT firmware or EmonESP firmware.

Interface

For the past few years I have been using OpenHAB as the control interface. OpenHAB is pre-loaded onto the emonPi emonSD pre-built image. I am yet to upgrade to OpenHAB V2.0, it looks very nice. However, V1.8 has been very reliable and fits my needs. I use the OpenHAB Android app to access the interface quickly from my phone:

open-hab-home.pngopen-hab-all.png

OpenHAB also integrates with my Pebble smartwatch which makes it super easy to turn on/off the heating while out and about:

openhab-pebble

A while back (early 2016) I dabbled with HomeAssistant, (see blog post). I was quite impressed, I have been following the project and it looks like it’s matured to be an excellent home automation platform. Quit possibly a rival to OpenHAB.

Another option for an interface is NodeRED Dashboard which is now officially part of the NodeRED project.

The beauty of MQTT is that it’s platform agnostic, it’s possible to have many different interfaces controlling the same control nodes.

Voice interface

I’ve recently acquired a Google Home voice activated speaker, with a little help from ha-bridge to emulate a Philips Hue bridge it’s quite easy to get Google Home to control local devices via MQTT. The same setup will also work with Amazon Echo. See ha-bridge setup guide for emonPi

See video demo at the top of this post.

Device config using ha-bridge webpage GUI:

ha-bridge-device-config.png

Google Home app setup:

google-home-app.png

Integration & Automation

I use NodeRED which is pre-loaded on emonPi / emonSD to integrate with other services such a getting the latest outdoor temperature from Weather Underground, send push notifications (heating on / off temperature alert) to my phone using Pushover. Both these services have pre-made nodeRED flows making integration very easy. NodeRED is pre-installed and configured on emonPi / emonSD. The example flow included on emonPi demonstrates reading emonTH data from MQTT and external temperature data from Weather Underground.

I also have a nodeRED flow that handles turning off the heating when the temperature in the livingroom (as measured by emonTH) reaches a set point. I could have used the thermostat controller on the WiFi relay to do this, however it would be difficult in my house to run the wired temperature sensor from the Wifi relay to the living room, therefore I use a wireless emonTH temperature instead.

Security and remote access

Remote control (from outside the local network) can be achieved using a dynamic DNS service such as DuckDNS or secure VPN to give access to services from the outside. E.g I open port 8080 to give access to OpenHAB running on my emonPi from the internet. OpenHAB has authentication turned on and HTTPS can be used to create a secure connection.

Alternatively, and possibly a better solution could be to use MyOpenhab.org service to allow remote control without having to open up a port externally.

Home Assistant has got an example of using Tor Onion Services to access Home Assistant running locally.

To engage in discussion regarding this post, please post on our Community Forum.

Comments