This tutorial assumes that you already installed and configured FHEM and know how to use AngularJS.

 

As you might know I use my Raspberry PI to automate tasks at home. I already detect my SmartPhone, and my FitBit and also control my Webcam and Harmony remote using a raspberry and a web interface.

Now I also wanted to include actors from HomeMatic thermostats into my configuration and display it in a nice way.

Hardware used:

  • HomeMatic Wireless Configuration Adapter LAN (HM-CFG-LAN)
  • HomeMatic Thermostate HM-CC-RT-DN
  • Raspberry Pi V2.

Software used:

  • HTML/CSS
  • JavaScript
  • AngularJS
  • FHEM
  • PHP (optional)

Before we begin make sure you have already installed FHEM and the hardware for it. I will not discuss that here as there are a lot of good tutorials for that. A good (german) tutorial can be found in the FHEM Wiki. (If you got any english documentation, feel free to post it in the comments.)

I wrote a “general” PHP script to send commands and receive commands from FHEM. This can also be done without PHP and pure JavaScript-Code. I chose this solution because my configuration website is accessable through the internet, but my FHEM isn’t. So JS-Could (running on the client) would not work, but PHP (running on the server) does.

The PHP-Script:

The only thing you need to modify here is the IP-Adress (or hostname) and maybe the port from the $host – variable. As you can see, this is a simple GET-Request which could easily used through JavaScript (or even just inside a href) also.

You can test this script by simply calling it with some parameters:

Replace “Sensorname” by the name of your sensor. You should receive the current temperature of the sensor as a result.

Now it is time to display this data in a fancy way in html. Create any HTML – Page using AngularJS. To use these nice Gauges you need ng-Google-Chart

Now lets see the HTML-Part containing the AngularJS-Directives to display and set the thermostate values:

Some explanation:

piApp is the AngularJS – App for the website, getStats() loads the current Sensors using FHEM.php mentioned above directly from the start. This html uses Bootstrap (for repsonsive design) and Font Awesome to display the Battery indicator. Both use CSS to achieve this. (The Gauge-Display works without these libraries)

The Angular-Controller looks like this:

Explanation:

“googlechart” in the module-configuration allows to paint those fancy gauges.

in $scope.heaterSettings.allHeaters you have to modify the Names of your Sensors. Enter as many sensors as you want.

All other functions communicate with fhem.php or display values.