TED 5000
Filtrete 3m50
- change the URIs in the script to point to your devices (I use DNS names to make my life easier)
- copy this script to your meteohub device
- chmod it to 777
- configure meteohub with a new weather station
- with it's source set to plug-in
- set up the sensors
- and done!


Code: Select all
#!/usr/bin/perl
use strict;
use warnings;
use XML::Simple;
use JSON;
use Data::Dumper;
my $tedAPI = "http://ted/api/LiveData.xml";
my $tstatTempAPI = "http://thermostat/tstat/temp";
my $tstatTTempAPI = "http://thermostat/tstat/ttemp";
my $tstatTmodeAPI = "http://thermostat/tstat/tmode";
while(1)
{
sleep(15);
my $start = time();
#TED Data
my $tedXML = `curl --silent $tedAPI`;
my $txml = new XML::Simple;
my $teddata = $txml->XMLin($tedXML);
my $kwh = sprintf('%.2f', $teddata ->{Power}->{MTU1}->{PowerNow});
my $volt = sprintf('%.1f', $teddata ->{Voltage}->{MTU1}->{VoltageNow});
#TSTAT Data
my $ttempJSOut = `curl --silent $tstatTTempAPI`;
my $json = JSON->new->allow_nonref;
my $tstatTemp = $json->decode(`curl --silent $tstatTempAPI`)->{temp};
my $tstatTTempHeat = $json->decode($ttempJSOut)->{t_heat};
my $tstatTTempCool = $json->decode($ttempJSOut)->{t_cool};
my $tstatTmode = sprintf('%.2f', $json->decode(`curl --silent $tstatTmodeAPI`)->{tmode});
$tstatTemp = sprintf('%.1f', ($tstatTemp - 32) * 5/9);
$tstatTTempHeat = sprintf('%.1f', ($tstatTTempHeat - 32) * 5/9);
$tstatTTempCool = sprintf('%.1f', ($tstatTTempCool - 32) * 5/9);
$tstatTemp =~ s/\.//g;
$tstatTTempHeat =~ s/\.//g;
$tstatTTempCool =~ s/\.//g;
$tstatTmode =~ s/\.//g;
$kwh =~ s/\.//g;
$volt =~ s/\.//g;
print("data0 $kwh"."\n");
print("data1 $volt"."\n");
print("t0 $tstatTemp"."\n");
print("t1 $tstatTTempHeat"."\n");
print("t2 $tstatTTempCool"."\n");
print("data2 $tstatTmode"."\n");
my $end = time();
my $time = 45 - ($end - $start);
sleep($time);
}