Raspberry_Pi_Logo.svg.png

Home Automation in the UK Simplified, Part 1: Energenie MiHome

Join Shabaz as he works on his IoT home!

Learn about home automation using the Raspberry Pi, Energenie MiHome and Node Red.

Check out our other Raspberry Pi Projects on the projects homepage

Previous Part
All Raspberry Pi Projects
Next Part

 

Note: This is part 1 of a two-part series. After you've read this, if you're interested to read further, navigate to Home Automation in the UK Simplified, Part 2: Raspberry Pi and Touch Display

Introduction

Home automation is a topic that has been around for decades, using classic wired technologies such as X10. The 21st century has favoured IP (Internet Protocol) to be the communication method of choice for delivering control and management of virtually anything imaginable. Devices can be untethered and operate wirelessly using sub-1GHz license-free bands. Radio is nothing new, but in modern times it has got a lot more easier to produce reliable, low-cost and energy-efficient radio links for consumer items. Small wireless nodes such as door/window monitoring devices can function with a single cell for a year or longer due to ultra-low power microcontrollers.

 

I wanted to see how to deploy home automation, and whether it can be easy-to-use and reliable, and if I can get good value from it. I was also interested to see how well it could integrate with everything else in my surroundings; for example could I control devices using my voice? And how effective is it? Could I also connect a Pi and do some extra things?

home-automation-example.png

 

In an ideal world, there would be no such thing like ugly mains light switches. Everything should be seamless, with lighting turning on when it is desired. My next home will have no mains light switches I’ve decided : )

 

There are many home automation products out there, usually as part of an ecosystem since there are many building blocks and they all need to work together. Some stuff is fun coding and developing, but the interface to the mains power supply requires good quality, approved, off-the-shelf products. It is not worth the risk assembling something with a no-name relay from ebay. How could one know for sure that the material is flame-tested and approved for use in the UK?

 

I wanted to examine those products that were certified for UK use. Some very low cost products are available from overseas particularly from Asia but I believe some are self-certified and I was not about to take a risk by permanently running them inside my home. Lots of high quality stuff exists from overseas, but approvals are expensive for a reason; subtle things like the wrong plastic could cause a flame situation to occur if the electronics went wrong, or electrocution is a possibility too. The legislation has plenty of subtle things such as how mains cables should be attached and what distance there should be between wires. To add to that, there are electromagnetic compatibility (EMC) rules which are designed to prevent equipment interfering with TV and radios, and laws governing how frequently transmissions can occur. The CE marking doesn’t mean much unless there is a reputable firm standing up for their product. In the event of a claim for liability I would want that firm to be located in Europe.

 

I window-shopped for home automation products that I could work with and finally decided to try out the Energenie ecosystem. The products seemed to be of very reasonable cost, and the range looked like it covered many things that I would want home automation to do. The company has been around for many years, so this provided confidence too. This first blog post reports the initial findings and shows how to set up the Energenie solution for control and monitoring using a PC or mobile phone, and natural language based voice control using Amazon’s Alexa service. All of this can be set up within an hour with the Energenie solution.

 

The next blog post will explore the Energenie solution further and investigate how it can work together with the Pi.

mihome-devices-boxed.jpg

 

What Problems does it Solve?

I actually had several use-cases for home automation.

 

One was to make my small apartment ‘upmarket’ so I can sell it for more money : ) I suspect a lot of people think home automation is a lot more complicated to install than it actually is, and therefore there could be good value-add to have this installed in an apartment. Many individuals/couples are away from their apartment all day and would appreciate being able to get some insight and control of their home remotely. The apartment already has a burglar alarm and video system, so home automation would be a nice addition.

 

Another use-case is to keep a light touch view on elderly relatives; it can be useful to see activity occurring in the home to make sure the relative is well.

 

As another idea for the elderly, a virtual voice controlled assistant could be very useful for people who may have trouble walking up/down stairs just to turn on the heating or switching off a light. Voice enablement will help out here. Taking this further, a home can have far more discreet physical buttons and controls if voice enablement is primarily used instead.

 

A very typical scenario where home automation can help out is to energy-save; the ability to get on-the-fly energy readings (either for the entire home, or more granular) provides insight and that drives consumer behaviour such as switching unused lights and TVs off more frequently.

 

Home security solutions can be improved with home automation; it becomes easy to automatically switch on home lighting when you’re out, to make it appear that someone is home. Timer devices are available but home automation provides a far cleaner implementation that can be programmed and schedules adjusted from anywhere and therefore makes it more practical to use. Home automation can provide insight into unusual activity even when an alarm has not been triggered. It provides deeper visibility. In a nutshell the opportunity exists to make home security and home automation better together.

 

For the engineer, home automation is important because it provides real-world sensor data that can be analysed and used to develop interesting future products. For example, I would love to know how long home lighting is switched on, to begin to understand how long LED products in homes could survive and how to improve them.

 

Can it be Installed in any Home?

This blog post will look in detail how to install and use home automation, but in summary there are several ways that a system can be installed. One typical scenario is to retro-fit it inside an existing home without touching any existing wiring. This is feasible and relies predominantly on the use of plug-in adapters which sit in-between the existing mains sockets and the connected device. It allows plug-in things like TVs and table lamps to be monitored or controlled.

 

Permanently wired home lighting can be controlled with some slight modification, by unscrewing the light switch on the wall and replacing it with a smart light switch. This can be achieved by nearly anyone provided some care is taken.

 

It is also possible to replace home mains sockets with smart mains sockets but this is an advanced activity that usually requires an electrician to install it. It is recommended to use the plug-in adapters if an electrician is not available.

 

For all the scenarios, an Internet connection is fairly essential.

 

Mi|Home Gateway

The gateway device which interfaces to all the rest of the Mi|Home ecosystem is really compact. It is only very slightly bigger than an ice hockey puck. There are just two ports on it. One is a USB connector for the 5V power supply (it comes with the Gateway) and the other is for the Ethernet cable to attach the gateway to the home router. One dual-colour LED and a pinhole reset switch completes the external features.

energenie-hub-on.jpg

 

The entire thing is small and unobtrusive and runs cool, and can be hidden from view. The top cover can be unclipped to look inside. There is not a lot to go wrong here, it should provide many years of good service. The circuit consists of a fairly high-end ARM Cortex-M3 based microcontroller from NXP, an Ethernet interface and a very popular RF transceiver module from HopeRF. Good brand parts are used like the Wurth Ethernet transformers. The enclosure is of a sufficient size to allow the antenna to have space around it for good range.

 

What looks like a standard debug port is also present. Lots of great potential to use this as a low-cost board for other projects too!

gateway-inside.jpg

 

Using the Gateway is pretty easy, it is plug-and-play. No configuration needed. You can take the code printed on the underside and apply it to the Mi|Home web portal once you have registered. For most users, there is no router configuration to do either. Just plug in the power supply and Ethernet connection and provided you have the code you’re ready to start using it.

 

Protocols and Examining the Risks

It’s always good to examine these things. Armed with the knowledge, we can deploy solutions in the right scenario and avoid fitting them where there are security risks.

 

The communication between the gateway and the Mi|Home cloud service uses UDP packets and is very lightweight, typical payload size was around 48-69 bytes, with what looks like a heartbeat every five seconds or so. This is a tiny amount of data traffic (less than 2MB per day) and therefore it will not impact Internet usage allowances, and also opens up the possibility of using a 4G/LTE router for monitoring and control of remote locations. The transmission is unencrypted but I could see no username/password/person identifying information transmitted; the MAC address of the gateway is sent. For home automation generally the risk of vulnerability between the gateway and the cloud service is low because it is very difficult for an individual to capture and decode communication over technologies such as 4G or cable or DSL.

 

For those unwilling to connect to a cloud service there is an add-on board available for the Pi, which, with some coding, can be used to control the devices locally.

energenie-pi.jpg

 

The radio communication between the gateway and devices is based on the OpenThings specification (registration required) which is documented, which means (in theory; I have not tried) that the Energenie solution is flexible enough to design your own additions. There are no fees involved to use the specification and modifications are permitted too. The radio communication occurs in the 433MHz band using frequency shift keying (FSK).

 

There is the risk that somebody could record radio transmissions and replay them; it requires some technical skill and it is up to individuals to determine if this poses a security risk in the environment where they are installing their home automation. With low power transmissions between the gateway and devices, it would require someone to be nearby in order to capture radio transmissions. The technology, like most of the current home automation solutions, will be susceptible to radio jamming signals. Due to the ease for jamming, the Energenie solution cannot be used as a replacement for home security solutions (burglar alarms, video cameras, etc).

 

Using the Mi|Home Cloud Service and Mobile App

I browsed to the Energenie Mi|Home website and registered for free and entered the code printed on the back of the Mi|Home gateway, and it was immediately registered. It is all very intuitive and once the gateway is added you can give it a name and start adding additional devices by clicking on ‘Pair New Device’. As soon as you do that the web page shows the entire product range.

mihome-pair-device.png

 

The color coding is roughly proportional to functionality. The basic products are blue and provide simple control in one direction. The pink items are monitoring products that gather information but do not have any controlling capability. The purple items are full-featured and offer both monitoring and control capabilities. This colour-coding matches the glossy card packaging of the devices too, so you can easily see the broad functionality that you are getting.

 

The product range can be configured in a consistent way. The procedure is to connect/plug in the device so that it is powered up, then hold a button down for 5 seconds until and LED flashes. Assuming that ‘Pair Devices’ and then ‘Start Pairing’ had been clicked in the web browser first, then the device will become attached and will appear in the Devices List; in the screenshot below I added a door sensor and a mains control adapter:

mihome-devices.png

 

It is actually possible to do this from a mobile phone too. The pairing for the device can be done anywhere within radio coverage of the Mi|Home gateway using the Mi|Home app.

mihome-mobile-app.jpg

 

You can also assign custom friendly names to each device; this is handy when you have many devices connected, but also is useful for voice control by device name; see further below). The app is easy to use and during my testing I didn’t notice any bugs or crashes. There is also the ability to integrate with IFTTT which is a way to have rules such as “if the weather is cold the turn on the heating” however I’m not keen on IFTTT due to the need to have facebook/twitter for the free account in order to create your own applets. There are other ways of achieving such things and they will be explored in another blog post.

mihome-mobile-screenshots.png

 

An interesting feature in the Mi|Home app is the ability to 'geofence'. This allows the system to control devices based on the location of the mobile phone. An example would be to turn on the heating if you’re approaching home.

 

In summary I thought the app was not bad, it is useful for checking up on the status of things in your home and controlling them of course. There are no fancy features like the ability to have a status widget on your mobile phone or to log data.

 

With the app installed, it was time to start pairing and exploring all the interesting devices!

 

Energenie Mi|Home Adapter Plus

The Energenie Adapter Plus is a very cool advanced ‘smart plug’. I thought it was great. It has a number of features. There is a small button on it and an LED, and any connected equipment can be powered or unpowered by directly pressing the button on it. The status is sent back to the home gateway, so that the user can check via the web portal what the actual status of the Adapter Plus is. This product is within the purple range, i.e. more feature-rich and with control/monitoring capability. Furthermore the Adapter Plus can be used to measure power consumption. This is extremely useful even if you’re not interested in actual energy usage, because it can tell you if the appliance at the end of the cable is actually switched on or off by observing the power consumption. So, you can use it to tell if (say) a television itself is actually powered up or not.

adapter-plus-plugged-in.jpg

 

It was interesting to examine it in more detail, to see precisely how it functioned and how accurate it could be.

 

It has security screws and once they were removed, I was impressed at the quality of construction. The earth and neutral connections are direct from the mains plug side to the mains socket side of the product. The Live connection is switched of course, and all wires are crimped to the metal components of the plug/socket portion of the design. The PCB is made of fiberglass and there is a fair amount of circuitry. The radio transceiver module is a HopeRF board again, with a helix shaped antenna soldered perpendicular to the circuit board on the side hidden from view.

energenie-adapter-plus-rf-side.jpg

 

There is a 2 milliohm shunt resistor for measuring current. The other side of the board contains a nice DC-DC converter circuit. The AC mains input is rectified and directly stepped-down using the DC-DC converter. This type of design will run cool and in practice I could not observe any warmth of the device during operation. There is also a varistor for protecting the circuitry from excessive mains spikes, for hopefully many years of good service. A dedicated IC performs the energy measurement and communications protocol handling before passing the data to the HopeRF module for transmission. The dedicated IC from Sentec handles reactive loads (i.e. it can measure real power) and the datasheet states that power measurement accuracy is 2% or 2W, whichever is greater. Although not spectacular, this is a reasonable level of accuracy for such a device.

energenie-adapter-plus.jpg

 

The mains is switched using a relay which has UL and TUV certificates. In summary I thought the design was good, I liked that it had some protection against spikes from mains input noise, the power consumption feature is really cool to see what devices are actually powered up, and a push-button switch to be able to turn devices on/off locally if desired.

 

Energenie Mi|Home Open Sensor

The Open Sensor does exactly that, it reports when something like a door or window has been opened or closed. It is a small single AAA cell powered device. It has low power consumption, I measured 50uA (it periodically changes between about 40uA and 60uA), and current of course increases during radio transmission whenever an open or close event occurs. Based on this, Energenie’s estimation of 1-1.5 years battery life appears accurate. I liked that it uses a standard AAA cell because they are cheap to replace compared to the small 12V batteries that used to be common in wireless sensors in the past. The sensor has the typical two-part magnet and reed switch implementation.

energenie-open-sensor-closed.jpg

 

The design is very nice; there in an internal 3V DC-DC step-up converter that presumably runs continuously, and a low-power microcontroller. As mentioned a reed switch and magnet performs the actual detection. The transmitter is a tiny 6-pin SOT-23 device, most likely another HopeRF part.

energenie-open-sensor-component-side.jpg

 

There is a very discreet faint LED that shines through the white plastic, and it is useful for confirming that the battery is functioning because it flashes briefly each time the door is opened or closed.

 

Inside the box there were lots of mounting bits and pieces for attaching to doors/windows, and a card instruction leaflet.

energenie-open-sensor-components-all-r.jpg

 

Energenie Mi|Home Double Socket

In the blue range (i.e. control, not monitoring capability), I tried out the Mi|Home mains wall socket. This product can be fitted into a new electrical installation, or retrofitted. Its connections are identical to any standard double socket, and I liked that it had two earth terminal connections which simplified installation.

energenie-double-socket-closed-angled.jpg

 

The unit is quite deep, and it will be a real struggle to fit into a 25mm deep back box if there is more than one mains cable coming into the back box (more than one mains cable is common, since a ring mains will result in two cables into each box). However, a 25mm back box for ring mains is rare and homes should have deeper boxes usually. With a 35mm back box (as in these photos) there is no issue, and I tested with three mains cables; it just about fitted. With two mains cables it fits just fine.

energenie-double-socket-inside-back-box.jpg

 

Another approach for retrofitting is to leave the existing mains socket where it is, and fit the Mi|Home one alongside it as a spur connection. As a result, a 25mm back box is fine since the spur connection only has one mains cable. Also, if you didn’t want to go making too many holes in your wall, you could always fit it alongside to an existing mains outlet but in a surface mount box; that way you only need to plaster and repaint a very small area. This latter option should also result in better radio coverage so it would be worth considering if the Mi|Home gateway is positioned far away (or a second gateway could be purchased; multiple ones can be added in the Mi|Home solution).

 

So, to summarize, if you’re installing with a single cable, then a 25mm back box is ok, otherwise you will definitely need a 35mm back box minimum and it will be tight but feasible with three mains cables, so if you have the choice, go deeper.

energenie-double-socket-closed-top-view.jpg

 

In terms of aesthetics and the finish of the plastic I think it looks quite reasonable, no better or worse than typical home mains wall sockets. There are are also versions with brushed steel, or chrome or nickel finish if you need to match it to others in the home.

 

Energenie Mi|Home Light Switch

Another item in the blue range are the Mi|Home light switches. They are optionally available in the metal finishes just like the mains wall sockets.

mihome-switch-assembled.jpg

 

It has a depth of about 22mm, and so it requires a 25mm depth back box at a minimum (usually the boxes are recessed by at least a few millimetres into the wall, so that will also help to provide sufficient clearance for the mains cable. The photos here shows a 25mm box.

mihome-switch-side.jpg

 

If you’re replacing an existing light switch then the chances are that the back box will be more than 25mm deep, however I have seen very shallow back boxes (15mm) as was the case in one room at home, and these would not be suitable. It isn’t difficult to make any cavity deeper (no need to do that with a stud wall) and replace the back box of course.

mihome-switch-wiring.jpg

 

What seems to be missing from the range currently are double light switches. This actually made it awkward to install in a couple of rooms, since I wanted individual control of the two lights in the room.

 

Virtual Voice Assistant with Amazon Alexa

Amazon, Google and Apple all offer virtual voice assistant services. If you’re not familiar with them, they basically consist of small Internet-connected devices (usually WiFi enabled) that have a loudspeaker and an array of microphones inside. By saying a keyword (‘Alexa’ in the case of the Amazon service) the device wakes up and streams any subsequent speech to a cloud service which performs speech recognition and natural language processing to try to discover the intent of the speech. Once that is done, it formulates an intelligent response based on the wealth of information searchable on the Internet and streams a synthesized voice response which gets played out of the speaker on the device. I also find it handy for playing music, or for answering all silly questions from my little nephews : )

 

So, the virtual assistants today consist of two elements; the physical hardware and the cloud service. Recently Google came out with their AIY hardware kit which also provides a virtual assistant using the Google cloud service, with the Raspberry Pi and AIY kit forming the physical hardware device. Meanwhile, the Raspberry Pi also has another multi-functional hardware attachment for similar purposes called the MatrixCreatorMatrixCreator. In summary there are plenty of options.

 

I decided to try Amazon’s Alexa voice assistant service. It uses physical hardware known as the Amazon Echo range, and the Mi|Home service directly integrates with it. There are several models in the Echo range; the one in the photo is called the Echo Dot and costs about £50. There are some buttons on top but in normal use they are not used; the entire interaction can be by voice.

amazon-echo-dot.jpg (Picture source: Amazon)

 

The setup is extremely easy; I signed into my Amazon Alexa account and searched for the Energenie ‘skill’ and enabled it.

alexa-skills.png

 

Next, by clicking on the Smart Home item on the menu on the left, a ‘Discover’ button appears. I pressed that and less than a minute later the Mi|Home devices appeared.

mihome-alexa-app.jpg

 

That’s it! Now the home can be controlled by speaking to Alexa. The devices can be named anything in the Mi|Home web portal or mobile phone app, so turning a device on is as simple as saying (for example if the device has been named ‘bedroom lamp’) “Alexa, turn on the bedroom lamp”.

 

Application Programming Interface (API)

The Mi|Home cloud service has what is known as an Application Programming Interface (API). This offers control of your home programmatically. In other words, you can connect additional software and services to control the home. I did a basic ‘hello world’ type of test to confirm that I could connect using the API, but further use of the API will be explored in more detail in a subsequent blog post.

 

Summary

Generally, I’ve been quite impressed with the Energenie Mi|Home solution. I like that the gateway and all the devices appear well constructed, even on the inside for those that I took apart. Furthermore the electronics look designed for a long service life with cool operation. I didn’t observe any problems related to safety and mains wires were crimped and separated from each other in the plastic moulding.

 

In terms of functionality, Energenie have made it easy to choose what you need using their colour-coding scheme.

 

I also like that everything is actually really good value for money. The hub device, the Mi|Home gateway, is not expensive at all, just £39+VAT currently from CPC.

 

In contrast, LightwaveRF’s hub is almost twice that, currently £78 from Amazon. The Hive hub is a similar price. Given that you might need a couple of gateway/hub devices for adequate coverage of a home, the cost difference is quite large.

 

The Hive plug-fitting mains control device costs £31, and, described as a ‘British Gas Innovation’ (British Gas is an energy company) it does not support energy monitoring. In contrast, the Mi|Home Adapter Plus supports control and energy monitoring at just £18.50+VAT from CPC.

 

To me it seems an easy decision to go with the Energenie products currently. Even if in future years one was to adopt a different home automation solution, the Energenie offering has another trick up its sleeve to help with that too; a radio board is available for the Pi, so that an owner could continue to use the hardware provided they were willing to do the integration work (coding). However the Mi|Home cloud service is free to use and has a northbound application programming interface (API) so a user could directly integrate with that as well.

 

Improvements that I would like to see to the Mi|Home solution would be a dual light switch, and a thermostat. There are Mi|Home radiator valves, but I’d prefer to directly control the entire heating system. (update - the Mi|Home range now includes a thermostat).

 

I’m excited that I have the beginnings of a decent home automation solution, and in my next blog post I’ll explore how to integrate this with the Pi.