Using Fhem for Heating Control

Having discussed in previous posts my hardware approach to heating control I’ll now talk about the software.

The key to the whole system is FHEM which is a real discovery. As I’ve found before with the hardware, the Germans seem to have really got to grips with home automation. This system is open source and very mature, having been around for quite a long time and now being up to version 5.7. The problem is that at least initially it doesn’t appear particularly accessible or easy to use, but this is rather misleading. With a bit of effort invested you can get the system working well and it is incredibly flexible.

There is a good community supporting it, although it is predominately German speaking. Most of the documentation is too, but Google Translate has proved very helpful in navigating the forums and the wiki .

I won’t go into the basic setup, but you will need some kind of server (I am using a fairly old but extremely useful HP Proliant Microserver) and a suitable operating system. There are various ways to install Fhem which are detailed on the website and elsewhere.

So once you have a working Fhem system you can access it via a local URL and then the fun begins!

The basics are to get the interface installed and working. Fhem does have automatic mechanism for detecting and installing devices, which is based around a set of configuration files, they key one being fhem.cfg. In my case I am using a CUL device (as in previous posts) but there are various other ways of doing it. Some people have used the official MAX controller although it’s not much cheaper than the CUL and some difficulties have been reported. There are some other ways of getting CUL firmware onto cheaper devices but I haven’t explored these as yet.

What I really like about Fhem is that its basic structure supports a whole range of different devices (see the documentation for details) but it has a common approach to dealing with them. Also, whilst it is mostly based on configuration files the standard front end UI whilst basic is very effective.

So once you have a basic Fhem system up and running and your CUL or equivalent device has been detected – what next?

First thing to do is register all the MAX devices and pair them with your system. You will need to do this using the ‘learn’ mode on the devices and also by setting the CUL device to listen out for new devices.

You can do this by selecting ‘pairmode’ on the Fhem screen for the CUL device:


This then sets it to listen for a short period of time, and you then need to set the devices to pair. What exactly you do depends on which device you have, and you’ll need to check the instructions. However, for most of the thermostats I think you have to hold down the ‘boost’ button for a few seconds and then it begins a countdown, which stops again once the pairing is complete.

You will then see the MAX devices appearing in your Fhem screens. The screen for each looks something like this:


This screen demonstrates the strengths and weaknesses of Fhem, depending on who you are. For me this is great – lots of details, loads of options to play with etc. On the other hand you might think it looks overcomplicated and intimidating… in which case this probably isn’t for you.

All Fhem devices have settings (via the ‘set’ button at the top) and the pick list shows you what variables you can set. The ‘readings’ section shows the enormous amount of data you can extract from what is in reality quite a simple device. This includes the weekly ‘profile’ for each device – ie the combination of settings and times throughout the week. This is different for each individual thermostat which is good from a flexibility point of view, but not so good for consistency and ease of programming. There are solutions to this which I will come to in future.

So you should now be able to pair up all your thermostats, and the Fhem screens will allow you to see the measured temperature and make some changes. However, this isn’t much of a control system on its own and I’ll come to what I’ve done to tie it all together in future posts.

I know I’ve kept this quite general but please post comments or questions and I’ll try my best to answer them. There is a lot of info on the Fhem forums / wiki which are a good place to start if you are stuck.

Boiler Control using MAX hardware

So now I’ve got a number of MAX radiator valves around the house which are linked up to FHEM which is providing some monitoring and control. I’ll go into some more detail on the software side in another post. However, I realised that the amount of value that you get out of this system is pretty limited unless you can find a way of controlling the boiler.

Most of the other systems like this which I have seen do have some form of relay or control (sometimes called a ‘boiler interlock’) so that the individual zones can ‘call for hear’ and similarly the boiler shuts off automatically when heat isn’t required. Without this all you have is some fancy valves but the boiler control is still only by a basic thermostat or timer.

Unfortunately, there is nothing available in the MAX range which does this. This seems to me a major omission as all the others do (FHT, HomeMatic, evoHome etc). I had a bit of a problem, as I needed to be able to address the relay via FHEM on the computer, but the CUL device can only be used in one mode at a time. So if I wanted to use a relay from a different system (eg HomeMatic) I would need to have a second device to do so which will obviously cost a lot more.

I thought about this a lot because I really didn’t want to spend a lot of money on this and I didn’t want to overcomplicate matters. After a bit of digging around I found this:


This is one of the MAX products (details here ) although it is a little obscure. To be honest I’m struggling to work out when exactly anyone would use. It is basically a switched mains plug just like many which you find in home automation systems. However it is designed to work as part of a MAX system. So far as I can make out from the documentation it is supposed to be used with electric heaters or pumps that plug in to the wall. I’ve never seen anything quite like that… but maybe they have them in Germany.

The good news is that because it is a MAX device I can address it from FHEM without using any additional devices. However it wasn’t immediately obvious how I would use it to switch my boiler directly, which used a 240V switched circuit which normally goes to the thermostat. I had a few ideas, including stripping the whole unit down and somehow wiring the relay in directly and whilst I did get the board out to have a look there was no obvious way of doing this. The fact that it uses a European plug (aka Schuko) is another obstacle.

So I considered a few options, including buying a Schuko socket to plug it into. However as above I was trying to keep the costs down and keep it simple. My boiler already has main supply to the existing thermostat receiver so it’s fairly easy to wire things in. So what I have ended up with is starting with a UK socket, then an adaptor, then the switch unit, and then an older shaver plug with a flying lead.

The other end of the lead goes to a huge and rather OTT mains relay which I got for a few pounds from ebay:


Luckily it fits quite nicely into a blanked off single switch box, with the wires poked in through a hole in the bottom and fixed to the screw terminals on the base. The output from the flying lead on the switch goes to energise the coil, and the output contacts are wired to the thermostat input. So I’m using a mains relay to switch a relay to switch the boiler on! It’s a bit convoluted… but it works!

The end result in the boiler cupboard looks like this:


So a little inelegant perhaps… but I’m happy with the result.

In FHEM it can be configured as a MAX thermostat (so it appears exactly the same as one of the radiators) but it can be switched on and off by sending an ‘on’ or ‘off’ command to it.

I’ll cover the FHEM configuration in a bit more detail in the next post