Energenie Integration with Python on a Raspberry Pi

Using pyenergenie to do Energenie automation with out need for the cloud

It is disappointing what IoT hardware manufacturers provide regarding software with their products. I don’t want to single out Energenie - at least they created a tremendous hackable radio board specifically for the Raspberry Pi. The ENER314-RT provides two-way communication with all Energenie products including all their power switches, energy monitors and radiator valves. This means that you don’t need to buy an Energenie Gateway MIHO001, and you also don’t need cloud connectivity and the worry that somebody might be snooping on your data.

ENER314-RT Figure 1 : Energenie ENER314-RT 2 Way Pi-mote

However, as I said, their software support for this is pretty rubbish. Luckily a third party developer @whaleygeek made a great start at providing support for this board. His GitHub repository is here. Really when I say great start I really mean he’s done most of the work to create a full-featured API in Python for this board. It supports most of the hardware but unfortunately not the Energenie MIHO013 Smart Radiator Valves. I found this out the hard way. These smart valves aren’t cheap at £75 for two so after getting them I just had to make them work.

TL;DR I did get them to work, but it wasn’t easy. It turns out there was a reason why whaleygeek didn’t get them working. These battery powered devices operate a two-way radio, but to save power they only listen for a few milliseconds after each transmission. This requires some quick action by the code if you want to send them any messages. There are two reasons you need to send messages to these devices, firstly and obviously you need to tell them what temperature you want, or to open and close the valve. Secondly, retrieving battery level and diagnostic updates require asking them. So to communicate with these devices the code needs to queue up requests to send to them, and then dispatch these messages quickly after receiving. Getting that to happen required me getting down quite deep into the code and making some changes. This job was made all the harder by the fact that the valves only send out messages around every 5 minutes. This makes debugging painful, to say the least!

Anyway my Github repository with the changes required is here.

Another compelling use case for Energenie technology is their individual appliance monitors MIHO004. Because they give real-time output on power use, you get some interesting data on the operation of appliances. I currently have them on the aquarium as well as fridge and freezer. By monitoring duty cycles (basically the ratio of on to off time) you can detect when the fridge door has been left open, or new stuff has been added.

Fridge duty cycle Figure 2 : Duty cycle of fridge over 1 week period

If you want to see a good example of using this Energenie python library take a look at my production code in use at home. It monitors and controls the various devices via an HTTP REST API. The main data reported as XML looks like this:

<data>
    <MIHO004_fridge power="0" avgPower="16.25" dutyCycle="0.24" dutyCycle2="0.25" volt="228" freq="49.85" age="9"/>
    <MIHO004_aquarium power="65" avgPower="90.26" dutyCycle="0.11" dutyCycle2="0.07" volt="229" freq="49.85" age="13"/>
    <MIHO004_freezer power="93" avgPower="34.41" dutyCycle="0.38" dutyCycle2="0.36" volt="230" freq="49.85" age="9"/>
    <MIHO013_rad1 temp="19.70" voltage="3.06" diag="0" age="339"/>
    <MIHO013_rad2 temp="19.70" voltage="2.78" diag="0" age="400"/>
    <MIHO013_rad3 temp="19.20" voltage="3.00" diag="0" age="564"/>
    <MIHO013_rad4 temp="19.30" voltage="2.94" diag="0" age="78"/>
</data>

One last bit of technology I’ve used from Energenie is their MIHO032 Smart Motion Sensors. These are battery powered and appear to have a battery life of over a year. They send messages when motion is detected and then again after motion has stopped. They can also report low battery.

So the complete hardware schematic of my Energenie setup is this:

Schematic Figure 3 : Schematic of Energenie setup

My only concern with the whole Energenie system is range. I’ve struggled to get good connectivity on a few occasions and even resorted to putting the Raspberry Pi in a central location. The radiator valves are a particular concern - once the battery voltage drops below 2.8v their transmission strength seems to drop off. The range is certainly much less than LightwaveRF but I don’t have any hard analysis of this fact.

Smart Radiator Use cases

MIHO013

I’ve had a few use-cases for these smart radiator valves that kind of justifies their cost.

  1. Our lounge room is large and without double glazing. We never use this in the mornings except at weekends and holidays, so it doesn’t make sense to heat it.

  2. Often my son isn’t at home, so his bedroom doesn’t need heating when he’s not there.

  3. We have a porch that is quite draughty due to an old badly fitting door. For a long time, I’ve had the radiator permanently off here because it’s such a waste to heat it. However, we do use it for drying things, and it is nice to have it warm on cold mornings.