Samsung Smart Aircon and MRTG

We’ve had 4 Samsung Smart air conditioners for a few years and every once and a while I revisit trying to automate them using scripts and a like. This time I was successfull using perl scripts written/edited by Daniel (CloCkWeRX) and Shannon (freman) to deal with the transmission protocol and token management – I personally would’ve never been able to work it out – so thanks and full credit to them. To start with, you have to discover then register the aircons to get a token for each, to discover them you can use this script, which was obtained then slightly modified from here. That script output:
Waiting for responses
$VAR1 = {
'modelcode' => 'SAMSUNG_DEVICE',
'mac_addr' => '',
'cache_control' => 'max-age=60',
'decoded_nickname' => 'Office',
'spec_ver' => 'MSpec-1.00',
'notify * http/1.1' => undef,
'nickname' => '',
'nts' => 'ssdp:alive',
'service_name' => 'ControlServer-MLib',
'message_type' => 'DEVICEDESCRIPTION',
'location' => 'http://',
'host' => ''
From here you can get the IP address of the aircon and now make a request to register the device and get a token file using this script.
perl <ipaddress> register
Turn off the aircon if it's turned on then pres enter.
Turn the aircon back on again, and you should see a success (I forget the exact words).
From there, I’m interested in polling the current temperature from each over a period of time and graph the results. MRTG will do for the graphing, and it’s pretty easy to setup.
/etc/mrtg.cfg additions
Title[Front_Lounge]: Front Lounge Temp
PageTop[Front_Lounge]: <H1>Front Lounge Temp</H1>
Target[Front_Lounge]: `/etc/mrtg/ <removed ip>`
MaxBytes[Front_Lounge]: 10000
YLegend[Front_Lounge]: Temp c
ShortLegend[Front_Lounge]: c
Options[Front_Lounge]: integer, nopercent, gauge
Create /etc/mrtg/ 
ping $1 -c 1 > /dev/nul 
if [ $? = 0 ] 
perl /etc/mrtg/ $1 status |grep "Current temperature"|cut -d ":" -f 2- |xargs 
echo 0 
echo $1 
echo 0 
echo 0 
echo $1 
As long as you have registered the aircon the output of should be similar to this:
14:39:33 up 5 days, 19:31,  1 user,  load average: 0.02, 0.03, 0.05
It seems to be a little hit and miss. The Android app also doesn’t show all of the devices at all times. After a few hours it appears the script is having time out issues – which appears to be an issue with one of the aircons dropping wifi signal. Changes to the script have been added above, now it checks if the aircon is pingable before proceeding, if it’ll output: zero’s for the temp. That will give random drops in the graphs, but if you don’t get random wifi drop outs like me, you wont have that issue.
MRTG Graphing Temperatures

MRTG Graphing Temperatures

Cheers. Sources

Leave a Reply

Your email address will not be published. Required fields are marked *