Blog

Home automation: Putting a child lock on my Nest thermostat using SCOM

 

This post is part of a series on how I demonstrate how to use SCOM to basically monitor everything. The other parts can be found here:

After I have successfully been able to get data into SCOM from my Nest Thermostat and my Flukso energy meter it’s time to do some cool stuff with it. More devices are in the pipeline to get data into SCOM to create the ultimate Domotics controller or should I say “SCOMotics”…

The world: Keeping an eye on Teen Trouble

One problem I have in real life is the fact that it’s very hard to explain to my wife and kids the process off radiant floors. It takes some time to heat up but it stays warm a long time so there’s no point in setting the thermostat to a higher point to get instant heat because it takes approx 1 hour to heat up 2 degrees celcius (something I also learned from getting my Nest thermostat data into SCOM).

But you can explain all you want if they find it chilly they’ll turn up the thermostat assuming it will get warm instantly but in fact they are just using more energy than necessary to heat the house in 2 hours when they already left the house.

So the mission was very simple. To stop them from doing this. Yes… I could put a lock code on the Nest thermostat and make it only available to me but if I’m not home and they really need to put the heating higher they are not able to do so.

So I came up with another solution: Setting a hard limit on the degrees and enforcing it.

So in short what do I need to achieve with SCOM:

  • Detection of the current temperature set: Target temperature
  • Alerting when the Target temperature breaches the set limit
  • Take corrective action to make sure the target temperature is set below the max temperature.

So let’s start with the detection of the current target temperature. I can reuse the work I already did to read in this value and compare it to the limit. To keep track of things and as this is a more general approach I’ve documented the process of creating a PowerShell script monitor using Silect MPAuthor here: http://scug.be/dieter/2014/04/24/scom-creating-a-powershell-script-monitor-with-silect-mpauthor/

So now that we have the monitor in place let’s check out whether it’s working!

First of all I’m setting my nest thermostat to 20 Celsius while my limit is set to 19 Celsius:

SNAG-0257

After the first run the monitor is picking up that indeed the temperature is higher than the requested limit. This is detected by running the PowerShell script monitor we’ve configured earlier:

SNAG-0263

Here you can see that the Recovery target which I configured kicked in as well. This recovery target consists out of a PHP file which is located on my Webserver and loaded by using the PowerShell Invoke-Webrequest module..

Note: I’m running this recovery against my Watchernode class which consists of 1 server and thus I’ve copied the “settempnest.ps1” to the local folder of that particular server.

How did I configure the recovery task

First open the monitor and click add on the “configure recovery tasks” section

SNAG-0260

Fill in the name of the recovery and select the status where to react upon.

SNAG-0261

Enter the command:

  • Full path: C:\Windows\System32\WindowsPowerShell\V1.0\powershell.exe
  • Parameter: -noexit “& “C:\scripts\settempnest.ps1”

SNAG-0262

The powershell is running a invoke-webrequest on my webserver. The PHP script it is running is copied below:

[xml]

<?php

require ‘inc/config.php’;
require ‘nest-api-master/nest.class.php’;

define(‘USERNAME’, $config[‘nest_user’]);
define(‘PASSWORD’, $config[‘nest_pass’]);
date_default_timezone_set($config[‘local_tz’]);

$nest = new Nest();
$nest->setTargetTemperatureMode(TARGET_TEMP_MODE_HEAT, 18.0);

[/xml]

So after running the recovery we see the monitor changing back from error to healthy:

SNAG-0259

There we go… All good again saving some energy

SNAG-0265

And final check on the thermostat itself… Back humming at 18 degrees.

SNAG-0264

Enough talk, let’s build
Something together.