The UK Home Automation Archive

Archive Home
Group Home
Search Archive


Advanced Search

The UKHA-ARCHIVE IS CEASING OPERATIONS 31 DEC 2024

Latest message you have seen: Re: MK grid switches


[Message Prev][Message Next][Thread Prev][Thread Next][Message Index][Thread Index]

Re: Current Cost data extract



If you=E2=80=99d prefer you can send your VB one over to me and
I=E2=80=99l=
l have a look at it for where you may be going wrong?

Cheers,

Michael


From: Peter Church=20
Sent: Monday, February 13, 2012 5:45 PM
To: ukha_d@xxxxxxx=20
Subject: RE: [ukha_d] Current Cost data extract

=20=20
OK. Got ActivePerl - it gives me a Perl Package Manager and a Perl Critic
application. No idea of where I drop this code script.

Can anyone give me any more pointers on what to do. I'm guessing I'll have
to muck around with baud rates and Comports when I get that far, but I'm
no=
t
sure even where to start to get the script even thinking about running!?

Thanks

Pete

From: mailto:ukha_d%40yahoogroups.com
[mailto:mailto:ukha_d%40yahoogroups.c=
om] On Behalf Of
Jason Pearce
Sent: 13 February 2012 10:19
To: mailto:ukha_d%40yahoogroups.com
Subject: RE: [ukha_d] Current Cost data extract

Hi,

Google activeperl

Regards,

Jason
On Feb 13, 2012 9:43 AM, "Peter Church" <mailto:yahoo%40petechurch.co.uk
<mailto:yahoo%40petechurch.co.uk>
> wrote:

> **
>
>
> Thanks Alex
>
> "drop on a Perl interpreter" might be beyond my rough and
ready
> capabilities, but I'll see if I can have a go.
>
> Any recommendations of one for Windows?
>
> P
>
> From: mailto:ukha_d%40yahoogroups.com
<mailto:ukha_d%40yahoogroups.com>
[mailto:mailto:ukha_d%40yahoogroups.com
<mailto:ukha_d%40yahoogroups.com>
]=
On Behalf
Of
> Alex Monaghan
> Sent: 13 February 2012 08:04
> To: mailto:ukha_d%40yahoogroups.com
<mailto:ukha_d%40yahoogroups.com>=20
> Subject: RE: [ukha_d] Current Cost data extract
>
> I used this Perl script on a Linux box a while back (not got round to
> re-configuring after Google ditched the Windows app). Very rough &
ready,
> looks like it was cobbled together from a snippet of someone else's
example
> code, but you should be able to drop on a Perl interpreter make a few
> tweaks
> and you'll be running again.
>
> #!/usr/bin/perl -w
>
> use strict;
>
> use Device::SerialPort;
> use XML::Parser;
> use XML::XPath;
> use DBI;
>
> my $port =3D Device::SerialPort->new("/dev/ttyUSB0");
> my $dbh =3D
DBI->connect("dbi:mysql:ccost:localhost:3306",
"ccost",
"ccost");
>
> $port->baudrate(57600);
> $port->parity("none");
> $port->handshake("none");
> $port->databits(8);
> $port->stopbits(1);
> $port->read_char_time(0);
> $port->read_const_time(1);
>
> print "\nStart\n";
> # read data until new data is not found five times in a row
> while (1)
> {
> my $readData =3D &read(5);
> if ($readData ne "")
> {
> #print $readData;
> eval
> {
> my $xml =3D XML::XPath->new(xml =3D> $readData);
> my $date =3D $xml->find('//msg/time');
> my $watts =3D $xml->find('//msg/ch1/watts');
> #print $date, "," , $watts, "\n";
> # prepare the query
> my $sth =3D $dbh->prepare("insert into readings(date, reading)
> values(now(), $watts)");
>
> # execute the query
> $sth->execute();
> }
> }
>
> }
>
> $port->close();
> print "\nEnd\n";
>
> sub read()
> {
> my $maxCnt =3D shift;
> my $notFndCnt =3D 0;
>
> # clear the read buffer variables
> my $readChars =3D 0; my $readBytes =3D ""; my $readBuffer
=3D "";
>
> while ($notFndCnt < $maxCnt) {
> # Read serial port data
> ($readChars, $readBytes) =3D $port->read(1);
>
> #print $readBytes;
>
> $readBuffer .=3D $readBytes;
>
> if ($readChars =3D=3D 0) {
> $notFndCnt++;
> } else {
> $notFndCnt =3D 0;
>
> }
> }
>
> #print "\n";
>
> $readBuffer;
> }
>
> -----Original Message-----
> From: mailto:ukha_d%40yahoogroups.com
<mailto:ukha_d%40yahoogroups.com>
<mailto:ukha_d%40yahoogroups.com>
> [mailto:mailto:ukha_d%40yahoogroups.com
<mailto:ukha_d%40yahoogroups.com>
<mailto:ukha_d%40yahoogroups.com>
] On
> Behalf
> Of
> peter_church
> Sent: 12 February 2012 08:26
> To: mailto:ukha_d%40yahoogroups.com
<mailto:ukha_d%40yahoogroups.com>
<mailto:ukha_d%40yahoogroups.com>
> Subject: [ukha_d] Current Cost data extract
>
> Hi all,
>
> I've searched the web on this and cannot find anything suitable, but
was
> wondering if anyone here has a homebrew solution to this (or a pointer
to
> something I missed).
>
> I was using Google to gather the data from my CurrentCost unit, but
was
> ignoring their web part but instead pulling out my own values from the
> local
> database that Google was creating on my machine.
>
> Since Google discontinued their monitoring service their software no
longer
> seems to be working (obviously I suppose).
>
> Does anyone have a simple solution to retriveing the CurrentCost info
int=
o
> a
> local database? All the ones ont the web contain a fancy front end or
> upload
> to the web which I don't want.
>
> I've tried writing my own in VB (my only language) but it uses all
> resources
> of the processor which is a bit of a problem - down to my limitations
I
> guess.
>
> Many thanks in advance
>
> Pete
>
> ------------------------------------
>
> Yahoo! Groups Links
>
> [Non-text portions of this message have been removed]
>
>=20
>

[Non-text portions of this message have been removed]

[Non-text portions of this message have been removed]





[Non-text portions of this message have been removed]



------------------------------------

<*> Join the Automated Home Forums
http://www.automatedhome.co.uk/vbulletin/


UKHA_D Main Index | UKHA_D Thread Index | UKHA_D Home | Archives Home

Comments to the Webmaster are always welcomed, please use this contact form . Note that as this site is a mailing list archive, the Webmaster has no control over the contents of the messages. Comments about message content should be directed to the relevant mailing list.