How to set up a web interface for a Heatmiser wi-fi thermostat using a Raspberry Pi

My earlier post on the Heatmiser PRT-TS wi-fi thermostat proved very popular and is the most commented article on this blog. When commenter Rich mentioned the heatmiser-wifi project, a set of Perl scripts that can be installed on a PC or Raspberry Pi to provide a full-featured web interface for the Heatmiser, I just had to give it a go.

Although the project site mentions that it has been tested on Raspberry Pi, I just couldn’t get past one of the steps. A little bit of Googling revealed a possible solution, and it worked. Be warned, the process takes a little while but in my opinion the results are definitely worth it.

Installation of Subversion and the heatmiser-wifi software

To get hold of the software, you have to check it out using the Subversion (SVN) source control system. So the first step is to install SVN:

sudo apt-get install subversion

You can then run the following command to download the heatmiser-wifi software:

svn checkout http://heatmiser-wifi.googlecode.com/svn/trunk/ ~/heatmiser-wifi-read-only

This will create a folder called heatmiser-wifi-read-only in your home directory. If you want to specify a different path, edit the command as appropriate.

Install Perl and essential packages

Check that Perl version 5 is installed by running:

perl -v

This should return some output starting with the following (or similar):

This is perl, v5.10.1 (*) built for arm-linux-gnueabi-thread-multi

If not, install Perl using:

sudo apt-get update
sudo apt-get install perl5

Now you need to install the required packages:

curl -L http://cpanmin.us | perl - --sudo App::cpanminus
sudo cpanm CGI Cwd DBI File::HomeDir Getopt::Std IO::Socket JSON LWP::UserAgent Proc::Daemon Proc::PID::File Time::HiRes
sudo apt-get install libxml-simple-perl
sudo cpanm XML::Simple

This takes a long time, so you may want to have a cup of tea, run a bath or go for a walk!

(Note that the original instructions had the CPAN modules listed on one line, omitting the apt-get before XML::Simple, but this didn’t work for me, hence the change. Also I had trouble getting the standard cpan command to work on the Pi due to its limited hardware, hence using cpanminus instead.)

Test the installation

Run the following command, adjusting the path if necessary, replacing 192.168.0.100 with the actual IP address of your Heatmiser and 1234 with the PIN number:

~/heatmiser-wifi-read-only/bin/heatmiser.pl -h 192.168.0.100 -p 1234

You should get some output like this:

Heatmiser PRT version 1.2
Thermostat is ON (heating mode)
Time 2012-07-07 21:45:59
Temperature 23.5 deg C (internal)
Target 17 deg C
Heating is OFF
Feature 01: Temperature format C
Feature 02: Switching differential 1 deg C
Feature 03: Frost protect 1
Feature 04: Frost temperature 15 deg C
Feature 05: Output delay 0 minutes
Feature 06: Comms # n/a
Feature 07: Temperature limit 0 deg C
Feature 08: Sensor selection internal
Feature 09: Floor limit n/a
Feature 10: Optimum start disabled hours
Feature 11: Rate of change 20 minutes / deg C
Feature 12: Program mode 5/2 day
Weekday 1: 07:00 20 deg C
2: 07:30 17 deg C
3: 17:00 20 deg C
4: 21:30 17 deg C
Weekend 1: 09:30 20 deg C
2: 21:30 17 deg C

For the rest of the steps to work, you need to store the IP address and PIN number in a config file. To do this:

sudo nano /etc/heatmiser.conf

Type the following two lines, substituting 192.168.0.100 with your thermostat’s actual IP address, and 1234 with its PIN:

HOST 192.168.0.100
PIN 1234

Press Ctrl+X and type Y to save the file.

You should now be able to run the following command (same as before but without the IP and password, which will now be read from the conf file).

~/heatmiser-wifi-read-only/bin/heatmiser.pl

Set up the web interface

Happily the project’s web interface instructions seem to work fine on the Pi without any changes.

I have also set up logging and charting of external temperature (via the Met Office API). Frustratingly, my Met Office API key didn’t work straight away – it kept returning Invalid key please register at http://www.metoffice.gov.uk/public/ddc via both the heatmiser_weather.pl script and the “preview data” feature on the Met Office site itself. Also note that it will take up to five minutes for the weather table to start populating, unless you’ve increased the rate in the heatmiser.conf file.

If you enjoyed this post, please share it!

    28 comments on “How to set up a web interface for a Heatmiser wi-fi thermostat using a Raspberry Pi

    1. Rich says:

      Glad you found it useful.

      This wasn’t the reason for me getting my heatmiser (I wasn’t even aware of it when I bought my PRTHW) but now I don’t know what I would do without it.

      The only downside is it’s linux only, not a problem for me as I have a linux box running sabnzbd, sickbeard, couchpotato, mysql etc. for my XBMC setup, this uses minimum resources so can be bolted on easily with little to no linux knowledge if you can read and follow instructions. And if you don’t have a spare box running linux, it runs on a virtual machine with linux through windows.

      As far as I am aware, although I haven’t spoken with the author for a few months, the googlecode is still being updated and improvements made. Before I started external temperature wasn’t part of it, internet time sync wasn’t part of it, multiple heatmisers weren’t supported and the PRTHW wasn’t fully supported. The more people who got involved the better it got. Keep spreading the word and I’m sure even more features will become available…

      It also helped me see when and if the PRTHW was disconnecting from the network and getting locked out (a common issue with older firmware on the PRTHW), and confirmed that a firmware update to 1.6 solved the problem.

      P.S. Personally I use weather underground not the met office for the external temperature, I found that easier but already use weather underground for other projects

    2. Marc Daniels says:

      Hi,

      This is fantastically useful – thank you.

      One point has me stumped – the install of TimeHiRes fails with:
      “Building and testing Time-HiRes-1.9725 … FAIL”

      I know nothing about Linux (sorry), but the logfile says:

      gcc-4.7 -c -D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fstack-protector -fno-strict-$
      /bin/sh: 1: gcc-4.7: not found

      would be really grateful if you could point me in the right direction.

      thanks,

      Marc

    3. Chris Barnes says:

      Hi Marc,

      Looks like the GCC compiler isn’t installed – try:

      sudo apt-get install gcc

      Then try the package installation again.

    4. Marc Daniels says:

      Chris, really kind of you to respond. That doesn’t seem to be the problem – it says gcc is already installed and the newest version.

      Maybe I should just start again from scratch. Is there a particular flavour of Linux you’d recommend? I was using Raspbian “wheezy”

      cheers,

      Marc

    5. Marc Daniels says:

      OK. Looks like this was a red herring, and HiRes was already installed. The problem was something entirely different – I needed to install json.pm. With that done, everything is working

      sorry to have wasted your time!

      Marc

    6. Chris Barnes says:

      No problem Marc, glad you got it working and thanks for posting the fix :)

    7. Paul says:

      Hi Chris

      Seems like a great app and I have struggled most of the way through installing it (mainly basic errors) got it working as far as displaying the web page but it draws a blank graph. The apache error log refers to not being able to locate json.pm. Iam new to linux so any pointers you could give to getting me over the final hurdle would be great

      Thanks Paul

    8. Chris Barnes says:

      Hi Paul,

      Try running:

      sudo cpanm JSON

      And let me know what output you get.

      Chris

    9. Paul says:

      Sorry for the delay Chris

      I hacve done a new install (fresh download of wheezy), followed your instructions to here

      sudo cpanm CGI Cwd DBI File::HomeDir Getopt::Std IO::Socket JSON LWP::UserAgent Proc::Daemon Proc::PID::File Time::HiRes
      udo cpanm CGI Cwd DBI File::HomeDir Getopt::Std IO::Socket JSON LWP::UserAgent Proc::Daemon Proc::PID::File Time::HiRes

      I get multiple errors/fails messages during the different installs on
      CGI, DBI, JSON

    10. Paul says:

      Further info the error message in the cpan log when i try and install CGI is “C complier cannot create executables” – have googled for help but not getting anywhere :(

    11. Chris Barnes says:

      Hi Paul, try:

      sudo apt-get install libc6-dev libexpat1-dev

      Then run the sudo cpanm… line again

      Chris

    12. Paul says:

      Thanks Chris – but sorry that didn’t work :(

    13. Paul says:

      Heres the output

      sudo apt-get install libc6-dev libexpat1-dev
      Reading package lists… Done Building dependency tree Reading state information… Done libc6-dev is already the newest version.
      The following NEW packages will be installed:
      libexpat1-dev
      0 upgraded, 1 newly installed, 0 to remove and 40 not upgraded.
      Need to get 210 kB of archives.
      After this operation, 650 kB of additional disk space will be used.
      Do you want to continue [Y/n]? y
      Get:1 http://mirrordirector.raspbian.org/raspbian/ wheezy/main libexpat1-dev armhf 2.1.0-1 [210 kB] Fetched 210 kB in 2s (76.2 kB/s) Selecting previously unselected package libexpat1-dev.
      (Reading database … 59675 files and directories currently installed.) Unpacking libexpat1-dev (from …/libexpat1-dev_2.1.0-1_armhf.deb) …
      Setting up libexpat1-dev (2.1.0-1) …
      pi@raspberrypi ~ $ sudo cpanm CGI Cwd DBI File::HomeDir Getopt::Std IO::Socket JSON LWP::UserAgent Proc::Daemon Proc::PID::File Time::HiRes
      –> Working on CGI
      Fetching http://www.cpan.org/authors/id/M/MA/MARKSTOS/CGI.pm-3.60.tar.gz … OK Configuring CGI.pm-3.60 … OK ==> Found dependencies: FCGI
      –> Working on FCGI
      Fetching http://www.cpan.org/authors/id/F/FL/FLORA/FCGI-0.74.tar.gz … OK Configuring FCGI-0.74 … OK Building and testing FCGI-0.74 … FAIL ! Installing FCGI failed. See /root/.cpanm/build.log for details.
      ! Bailing out the installation for CGI.pm-3.60. Retry with –prompt or –force.
      Cwd is up to date. (3.36)
      DBI is up to date. (1.622)
      File::HomeDir is up to date. (0.99)
      skipping F/FL/FLORA/perl-5.17.4.tar.bz2
      IO::Socket is up to date. (1.32)
      –> Working on JSON
      Fetching http://www.cpan.org/authors/id/M/MA/MAKAMAKA/JSON-2.53.tar.gz … OK Configuring JSON-2.53 … OK ==> Found dependencies: JSON::XS
      –> Working on JSON::XS
      Fetching http://www.cpan.org/authors/id/M/ML/MLEHMANN/JSON-XS-2.33.tar.gz … OK Configuring JSON-XS-2.33 … OK Building and testing JSON-XS-2.33 … FAIL ! Installing JSON::XS failed. See /root/.cpanm/build.log for details.
      ! Bailing out the installation for JSON-2.53. Retry with –prompt or –force.
      LWP::UserAgent is up to date. (6.04)
      Proc::Daemon is up to date. (0.14)
      Proc::PID::File is up to date. (1.27)
      –> Working on Time::HiRes
      Fetching http://www.cpan.org/authors/id/Z/ZE/ZEFRAM/Time-HiRes-1.9725.tar.gz
      … OK
      Configuring Time-HiRes-1.9725 … OK
      Building and testing Time-HiRes-1.9725 … FAIL ! Installing Time::HiRes failed. See /root/.cpanm/build.log for details.

    14. Chris Barnes says:

      Hi Paul,

      Sorry for the delay in getting back to you – my Raspi has been out of action for a couple of weeks (turned out to be a dodgy power supply which I’ve now replaced).

      Try:

      sudo apt-get install gcc-4.7

      Then your cpanm command again:

      sudo cpanm CGI Cwd DBI File::HomeDir Getopt::Std IO::Socket JSON LWP::UserAgent Proc::Daemon Proc::PID::File Time::HiRes

      Let me know how that goes!

    15. Ian says:

      Hi Chris,

      Thanks for your efforts here, I got this all up and running after a few problems along the way. All seems to be working very well. I just installed the Heatmiser in a holiday let, this monitoring is fantastic, I can see it saving me several long journies to check things are working OK. My only issue is I will now be able to see just how often my guests turn up the heating!

      Thanks
      Ian

    16. steve says:

      I came across the same problem with JSON. The makefile is looking for gcc-4.7 and rasbian (Nov 2012) is looking for gcc-4.6. I got around this by creating a link:

      in /usr/bin
      sudo ln -s gcc gcc-4.7

      Thanks for the article.

    17. Chris Barnes says:

      Thanks Steve for posting your solution :)

    18. Richard says:

      Hi Chris, Really great. Got working no problems at all. I have two heatmiser thermostats. Am I able to install twice (i.e. create two databases or setup to monitor two thermostats)?

      Regards
      Richard

    19. Chris Barnes says:

      Hi Richard, I don’t think the software is set up to monitor two thermostats but you should be able to install two copies and point the config of each to a separate unit.

    20. D MCM says:

      I see that perl is available in Mac OS X.

      “This is perl 5, version 12, subversion 4 (v5.12.4) built for darwin-thread-multi-2level
      (with 2 registered patches, see perl -V for more detail)

      Copyright 1987-2010, Larry Wall”

      Is it possible to install this software on a Mac?

    21. Chris Barnes says:

      Hi D MCM – I haven’t tried, but with Mac OS X being Unix-based, it should run fine.

    22. D MCM says:

      Thanks Chris I’ll maybe try it sometime – only problem is I’m not Unix literate.

    23. Chris Barnes says:

      Hi D,

      Just to let you know, I’ve recently had a go at getting the software working on OS X myself, and while I got as far as getting the basic script going, I unfortunately didn’t manage to get the web interface up and running. It really needs someone with the necessary skills and regular access to a Mac (neither of which I have) to make the necessary changes to the software to make it Mac-compatible and put together a suitable set of instructions.

      Regards,

      Chris

    24. Marc Daniels says:

      Very late response to Richard, but the software absolutely works for multiple thermostats – I have six. I use the router to give each a friendly network name and then the config file looks like:

      HOST living_room bedroom1 bedroom2 [etc]
      PIN xxxx

      Marc

    25. Dave says:

      Hi Chris, thanks for your amazing work on this. I am a Linux noob with a noob problem!
      I have installed everything to the letter and all tests pass for mysql etc.

      I just can’t fathom what the url to web interface is from another machine on my network.
      I have tried all variations of http://raspberrypiIPaddress/~root/heatmiser-wifi/

      I think the issue is with the /~root/ though I do run everything as root as that is how my siriproxy image was set up. Any ideas?

      Thanks.

    26. Adam says:

      Hi,

      Did anyone ever get a set of instructions for Mac OS X setup?

      I tried last year when I got the thermostat but gave up with too many errors…

      In hope
      Adam

    27. orandaadnaro says:

      Hi

      I’ve used heat miser with my pi since last November 2013. and barring a couple of power outages it has worked continuously.

      If I have any gripes with Heatmiser-wifi they are only minor:

      1 The temperature scale is on the left side of the display but the latest temperatures are on the far right and sometimes it is difficult to scan

      2 The external temperature is not contained in the floating values box and again scanning from left to right is irksome

      Finally more of a question than a gripe, The extended vertical graduated bars, do they represent actual boiler burn of gas? Whenever I’ve inspected my burner, it is not always firing when this bar is ‘on’

      Thanks for a great project, I used it whilst holidaying in Australia, inspecting my UK home and it worked perfectly!!!

    28. Peter Bradbury says:

      I’ve come back to this software after a year or so but the latest Jessie Raspbian OS doesn’t appear to work with the GitHub part of using the web interface. It gets stuck on the upstart part.

      If anyone can suggest a detailed explanation to get me last this en pass, I’d be much obliged

    Comments are closed.