Perl plugin for TED-5000 Power and Filtrete 3m50 Thermostat

Moderator: Mattk

Post Reply
Cisien
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: Tue Jul 24, 2012 7:56 am

Perl plugin for TED-5000 Power and Filtrete 3m50 Thermostat

Post by Cisien »

Here's a simple script I wrote up to get the temperature values, and mode from my WiFi-enabled thermostat, and Ted-5000 power meter, it should be very easy to extend to read (and log) other values that these two devices provide.

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!
Image

Image

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);
}
User avatar
admin
Platinum Boarder
Platinum Boarder
Posts: 7877
Joined: Mon Oct 01, 2007 10:51 pm

Re: Perl plugin for TED-5000 Power and Filtrete 3m50 Thermos

Post by admin »

great, thanks for sharing!
User avatar
meteo-quimper
Junior Boarder
Junior Boarder
Posts: 20
Joined: Thu Jun 07, 2012 1:13 pm
Location: Quimper - FRance
Contact:

Re: Perl plugin for TED-5000 Power and Filtrete 3m50 Thermos

Post by meteo-quimper »

hi

is it possible to build a plugin to get temperature data from a METAR ?
Cisien
Fresh Boarder
Fresh Boarder
Posts: 4
Joined: Tue Jul 24, 2012 7:56 am

Re: Perl plugin for TED-5000 Power and Filtrete 3m50 Thermos

Post by Cisien »

I don't have a METAR device, but it should be possible using what i've provided as a framework (Download XML/JSON from a web api, parse, output as data, every 60 seconds)
Post Reply