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:
- Part 1: How did I get data
- Part 2: Get data into SCOM from MySQL
- Part 3: Create the MP
- Part 4: Seeing it in action
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”…
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:
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:
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
Fill in the name of the recovery and select the status where to react upon.
Enter the command:
- Full path: C:\Windows\System32\WindowsPowerShell\V1.0\powershell.exe
- Parameter: -noexit “& “C:\scripts\settempnest.ps1″
The powershell is running a invoke-webrequest on my webserver. The PHP script it is running is copied below:
<?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);
So after running the recovery we see the monitor changing back from error to healthy:
There we go… All good again saving some energy
And final check on the thermostat itself… Back humming at 18 degrees.