Saturday, October 15, 2011

Adventures in Electricity.

Our power bill was getting huge. We were paying $350/month, and that was in the summer. Winter bills would be considerably larger. It was well past time to do something about it.

First up, change electricity providers. In New Zealand, Consumer NZ researched all of the electricity providers and put up a web site, Powerswitch. Now, according to Powerswitch, I was with the most expensive power company (Contact Energy). So, I switched to Powershop. They weren't the cheapest, Meridian Energy is the cheapest, but Powershop had amazing reviews. I also wanted a smart meter so that I could easily track our usage, and Powershop makes them available.

So, I switched to Powershop. According to PowerSwitch, I would save $675 on a bill of $4066, or >15%!

Side comment: Make sure to provide a final reading to your provider. They have a habit of over estimating your power usage to keep your as a customer as long as they can - you pay the estimated final reading, not an actual reading.

In New Zealand, there are different ways of saving money when buying electricity. The first and easiest is to sign up for ripple control. When you sign up for this, in times of peak power demand, the power company will turn off your water heater. If you give them this ability, they will discount your power by ~10%. Sounds like a good idea, except for one problem - it doesn't work. I repeatedly had the ripple controller turn off the water heater and then fail to turn it back on. Nothing is more unpleasant than getting into the shower and there not being any hot water, calling a plumber, who tells you the problem is electrical, and then calling an electrician who tells you the problem is the lines company. TWICE.

When that happened, I turned off ripple control, and I will never turn it back on.

Powershop gives you a different way of saving money. They offer time of day charging. This provides a discount on electricity between the hours of 11PM and 7AM. It has the same effect as ripple control, only it's under my control instead of the lines company's.

With the Powershop "All Inclusive" plan, they currently charge 23.93c/kwh. This is for the ripple controlled power. Then there is uncontrolled at 26.23c/kwh, that's ~10% more.

However, if by switching to Day/Night Uncontrolled, I'm paying 24.07c/kwh day and 15.17c/kwh night. That means that as long as I shift a certain amount of power to the night, I end up saving, and don't need to keep ripple control. The magic ratio is:

23.93 = 24.07 * x + 15.17 * (1-x)
23.93 = 24.07x + 15.17 - 15.17x
8.76  = 8.9x
0.98  = x

That means that as long as I move at least 2% to my night plan, I'm better off. Seems strange, the service rep indicated that the magic number was 10%.

I switched plans, and installed a smart meter, which cost $165. The savings from 26c/kwh to 24c/kwh (the minimum savings), with an average usage of 1600kwh/month, I have a payback of:

2c/kwh * 1600kwh = $32/month
$160 / ($32/month) = 5 months.

five months! That's pretty kick-ass in anyone's book.

To recap:

  1. Shop around. You can save a tonne of money with another provider. Switching is free and easy, just head over to Powerswitch.org.nz
  2. Change plans. Investigate day/night plans, particularly if no one's home during the day,
  3. We're at a savings of >25% from where we started, with more to come.

Saturday, September 03, 2011

Powersavings and water heater.

I have switched to Powershop, a New Zealand power company that provides intelligent meters with daily readings. This makes it really, really easy to see the impact of changes you make to your power usage. Not only that, but they provide time of day billing, where power from 7AM to 11PM is 50% more expensive than night time power.

That convinced me to look at how we used power. First, I shifted the laundry and dishwashing. I made it either the last thing I did before bed, or the first thing I did when I got up. That made a moderately substantial change in our bill, but nowhere near what I was hoping for. It was time to track down the big user in our power bill.

We are currently using about 40-50kwh of power per day. In New Zealand, we have expensive power prices ($0.25/kwh), so that's $10-$15 per day. Not cheap. The power meter we've got will tell us how much power we are currently using, which allowed me to zero in on the big users. First, just sitting there doing nothing, we use ~200w. That's for the server (with six HDs), networking and other vampires. Not bad, and not the main power user, they are constant background use, so they only end up being 5kwh/day. 10%, but not bad, bottom of the heap to fix. Next are the heat pumps and dehumidifiers. The dehumidifiers pull about 400w each, so they're a biggy if they were running all day. Heat pumps, also not a biggy, although they can pull about 5kw each. We're going to have to look at passive dehumidifing for the house if we keep it.

The biggest power user in the house is the hot water heater. It looks like it is using about 20kwh per day. However, we don't need a lot of hot water. We don't use it for laundry, the dishwasher uses cold water and our showers all center around 6-7AM.

I looked into ways to save power. The first and easiest is to turn off the hot water heater when you don't need it, so I did that. Our power usage collapsed. From 45kwh to 24kwh. That's a savings of $5/day. Not only that, but we had plenty of hot water for the rest of the day. If we were worried about running out of hot water, we could turn the water heater back on, and it would be at temperature within an hour.

However, there's a big scary monster out there in water heaters - Legionella. The bacteria loves warm, stagnant water between 20C and 45C. That means it loves electric hot water heaters. The recommendation is that water should reach your tap at at least 50C to prevent legionella from colonising the pipes and fixtures.

Oddly, it seems that legionella is found in 40% of electric water heaters, but the disease doesn't seem to be that prevalent (1 case per 100k population/year). It only appears to be a concern for people who are immune compromised. If it does take hold though, it is very dangerous if not caught quickly.

Because of that, we decided to turn the water heater back on during the day. I decided to attack the problem from another direction. Depending on how quickly the water heater loses heat, I can keep it above 50C while still saving on power. If the water heater doesn't drop below 45C during the day, it can be left off safely, bringing it back up to 60C at night, quickly killing off legionella and making use of night rates.

I will conduct some experiments to see:

  1. What the temperature of the water is in the heater.
  2. What temperature water is reaching the taps at.
  3. How quickly the temperature drops off.
  4. How quicly the heater drops into the danger zone.

Sunday, March 06, 2011

Map of Earthquake Prone Buildings in Wellington

On the weekend, I took the PDF that Hon. Peter Dunne (my local MP) provided of the earthquake prone buildings in Wellington New Zealand and put them onto a map.

I initially tried to use Google Docs to do this, because I thought it should be relatively easy to map data from a Google Spreadsheet. I thought that this would be an initial usage scenario. It seems that it isn't. So, instead I used BatchGeo. They have a pretty quick and easy service, complete with Geocoding.

Here is what their online tool created when I gave it the CSV file:

View Wellington NZ, EQP Buildings in a full screen map

The full screen map includes a list of the locations mapped.

Of course, the next morning, I found out that James over at maptd used Google Fusion Tables, which allow you to directly map data from a spreadsheet onto Google Maps. I'll have to look into them next. I would like to be able to keep the grouped view that BatchGeo provides in any reworking.

Sunday, January 17, 2010

Cheaper Internet TV

A while ago, I did some math to show how streaming TV through a US proxy on Amazon was cheaper than torrenting the show, and how it was even competitive with Sky TV if you watches less than 12 hours of TV a week.

That was if you used Amazon as your US proxy. With Amazon, you are paying for both traffic and time, which skews the price considerably. If you already have a US server (several of my friends do) then you already have your US proxy with a huge bundle of data. However, the rest of us need another, easier way.

Of course, the US being the US, and the Internet being the Internet, there is already several groups offering a range of methods, starting from free and getting more expensive from there.

First off, some math:

From last time, we saw the price for Amazon was:

Amazon Cost:
  Instance: US$0.1*(NZ$1/USD$0.67) = NZ$0.15
  Traffic (based on 1 episode of Eureka)
  (304MB/43min)*(60min/hr)*(1GB/1024MB)*(USD$0.27/1GB)*(NZD$1/USD$0.67) = NZ$0.17
  Total   : NZ$0.32/hr
NZ Bandwidth cost:
  (304MB/43min)*(60min/hr)*(1GB/1024MB)*(NZ$1.50/GB) = NZ$0.62/hr
Total cost per hour: NZ$0.94/hr

If we can reduce the Amazon cost, we can substantially reduce our total cost.

My goal is to get the "Amazon" portion of the charge down to 8c/day. That would make the price for a Hulu stream into:

NZ$0.62/hr + $0.08/day

So, the break even point against the Sky basic plan would become:

($11.74 - 0.08*7)/0.62 = 18 hours/week.

Not quite to the 3hrs/day that I have previously boasted about, but close. Within spitting distance, even. If you can get bandwidth for less than NZ$1.50/GB, the break even point will change dramatically. Given that the Southern Cross prices have just dropped by 50%, I hope to see some end-user price changes soon.

So, I went looking for a VPN provider. First I tried free, Hotspot Shield from AnchroFree. I quickly gave up on them. They don't have enough bandwidth, and they seem to be specifically targetted by Hulu.

I thought about using TOR, but quickly discarded that one. It would be just plain rude.

I looked at using the free proxy add-on for Firefox. However, they just aren't reliable enough for the next stage - a set top box.

So, I went looking at commercial offerings. I tried StrongVPN.com, WiTopia.net and HideMyNet.com.

VPN is still pretty new and arcane. There is a lot of magic, and many things that can go wrong. I found it very frustrating to get properly configured, and ultimately had to rely on the support teams at a couple of the providers to get configured. Thankfully, both StrongVPN.com and WiTopia.net offered good support. HideMyNet (and others) were not so good. I had other issues too. Sometimes it felt odd giving these companies my credit card details. So, I only went with ones that used PayPal.

Notes:

  1. Avoid PPTP. It's generally provided by the OS, and is flakey and hard to get configured properly. It may be cheaper, but it's not really worth it.
  2. Go with an OpenVPN based solution. This is available on Windows, OS X and Linux. The benefit is that it is it's own tool, separate from the network stack and therefore a lot easier to diagnose.
  3. CPU, CPU, CPU. My 2.4Ghz AMD single core Athlon 3800+ wasn't fast enough to stream more than 700kbps reliably. My 2.5Ghz Core2Duo is.

StrongVPN.com offers points of presence all over the world. However, they are moderately expensive at US$85/yr, and charge money to change PoPs (Point of Presence). In other words, while they do have PoPs in the UK (for access to BBC iPlayer or Spotify), if you want to switch between UK/US PoPs, they charge money. It really sounds like they should fix their provisioning and access control systems to me.

WiTopia.net is the company that I've ultimately gone with. They offer instant switching between VPN PoPs, UK and US PoPs and a low annual fee of US$60. Even better, they have US PoPs close to the Southern Cross US interconnect points in LA and San Francisco.

Since I've gone with WiTopia.net, Hulu came along and banned them from accessing their streams. However, a quick support message and I was on another PoP, which wasn't filtered (yet). However, I've also got access to BBC's iPlayer and Pandora, which kicks ass.

I just wish NetFlix was supported on Linux, then I would sign up for a NetFlix streaming account.

The final cost analysis works out as:

WiTopia.net Cost:
  Cost: NZ$80/yr
NZ Bandwidth cost:
  (304MB/43min)*(60min/hr)*(1GB/1024MB)*(NZ$1.50/GB) = NZ$0.62/hr

Break-Even point vs Sky: 
  ($11.74 - $80/365)/0.69 = 17 hours.

In other words, if you watch less than 17 hours of Sky specific TV per day (it isn't available on FreeView), you are better off paying for a proxy account and obtaining the content from the US or the UK.

Monday, November 30, 2009

Topic Relevant Comment Spam

On my previous post "Streaming Audio to your iPhone", I received a very odd comment. It was related to the subject, so it didn't immediately look like spam, but it wasn't topical.

Here's the comment (I've removed it from the original post):

Web casting, or broadcasting over the internet, is a media file (audio-video mostly) distributed over the internet using streaming media technology. Streaming implies media played as a continuous stream and received real time by the browser (end user). Streaming technology enables a single content source to be distributed to many simultaneous viewers. Streaming video bandwidth is typically calculated in gigabytes of data transferred. It is important to estimate how many viewers you can reach, for example in a live webcast, given your bandwidth constraints or conversely, if you are expecting a certain audience size, what bandwidth resources you need to deploy.

To estimate how many viewers you can reach during a webcast, consider some parlance:
One viewer: 1 click of a video player button at one location logged on
One viewer hour: 1 viewer connected for 1 hour
100 viewer hours: 100 viewers connected for 1 hour…

Typically webcasts will be offered at different bit rates or quality levels corresponding to different user’s internet connection speeds. Bit rate implies the rate at which bits (basic data units) are transferred. It denotes how much data is transmitted in a given amount of time. (bps / Kbps / Mbps…). Quality improves as more bits are used for each second of the playback. Video of 3000 Kbps will look better than one of say 1000Kbps. This is just like quality of a image is represented in resolution, for video (or audio) it is measured by the bit rate.

It was posted by "Andy". I was ready to post a comment thanking Andy for the additional information, but I decided to look to see if it was copied from somewhere else.

It seems that the exact same comment is placed on just about any blog post that mentions streaming. On the Google search I used, I found a lot of comments from the past couple of months.

Seems "Andy" has been a busy boy, and is actually a dirty, rotten spammer.

"Andy" (blogger), who also posts as "andylock", or "Andy Lock" (Facebook) is an automated spam program for vsworld.com, and the website is a flash-only website. I didn't stay there long enough to really figure out what they were selling, but it looked like some sort of contracting agency in India.

Still, I found it interesting that it wasn't immediately obvious that the post was spam.

Monday, November 23, 2009

Audio Streaming to the iPhone, Take Two

I wasn't completely happy with the results of using M3U files. While it did allow me to specify all of the files, I wasn't able to skip forward and back through the song list.

It turns out that the M3U support is there primarily to support live streams. For example, if you have a live stream from a video source (like a TV tuner card), the server records it, splits it into small chunks and converts it to H.264. The iPhone will then use the M3U file as an index to the individual data files, refreshing the M3U file occasionally. I'll have to set that up next. :)

So I went back to Google to see what I could find. I had come across the <OBJECT> tag in my previous searches, but I had discarded it as too difficult. I didn't want to work in HTML, and object embedding just seemed dirty. However, if I wanted to get access to skip forward/back, it looked like I was going to have to use it. I went through and modified the perl program from yesterday to produce an HTML page for each M3U file. It wasn't until I got to the end that I realized that I had done it wrong.

Lots of things don't work with the OBJECT tag, primarily the GOTO command. It seems that the proper way to embed things into a document is with the EMBED tag. That isn't to say that the EMBED tag is prettier. It isn't, they are both nasty. It is platform and player specific. Luckily, this only has to work on the iPhone/iPod Touch, so I'm lucky that way. I would hate to have to support this for multiple clients.

The first nasty surprise is that while you can have multiple songs in a list, you are limited to 255 of them. Even worse, they aren't done through object references in the rest of the document, the entire list is in the single object tag. That makes it harder to do dynamic, on the fly modification of the list. No small cgi to do shuffles here!

Still, 255 songs is enough to cover pretty much all of my artist directories.

It also seems that Mobile Safari ignores GOTO commands. In regular Safari, you are able to loop back around to the start of the playlist by putting "QTNEXT255=GOTO0" into the embed tag. Looks like Apple doesn't want playing loops on the iPhone.

Next, the iPhone ignores the "autohref", "autoplay" and "autostart" parameters. It always waits for user interaction. This is because the object is not really embedded, it takes full control of the screen. If it did start automatically, it would cause problems on many other sites. It's a small pain, but we'll survive.

I still wish it properly supported M3U files. The seamless transitions are nice. With the QTNEXT, there is a definite pause between tracks.

Here is the updated Perl code:

#!/usr/bin/perl

use File::Find;
use File::Basename;

use vars qw/*name *dir *prune/;

my $URL_BASE= "http://10.10.10.5/";

my @M3Us;

sub createPlaybackHTMLHeader {
    my ($filename, $target, $song) = @_;

    my $title = basename(dirname($filename));

    # open the file, 
    open(HTML, ">$target");

    # Write the HTML/Head elements,

    print HTML <<END;
<html>
  <head>
    <title>$title</title>
    <meta name="viewport" content="width=device-width; initial-scale=1.25"/>
  </head>
  <body>
    <p>Play all music in the "$title" directory, click the button below</p>
    <embed src="$song">
      autoplay="true"
      controller="true"
END
;
    # close the file.
    close(HTML);
}

sub createPlaybackHTMLFooter {
    my ($filename, $target) = @_;

    # open the file, 
    open(HTML, ">>$target");

    # Write the HTML/Head elements,

    print HTML <<END;
      qtnext255="GOTO0"
    </embed>
  </body>
</html>

END
;
    # close the file.
    close(HTML);
}

sub createPlaybackAddSong {
    my ($filename,$target, $song, $count) = @_;

    open(HTML, ">>$target");
    print HTML <<END;
      qtnext$count="<$song> T<myself>"
END
;
    # close the file.
    close(HTML);
}

sub convertM3UToHTML {
    my ($m3ufile, $target) = @_;

    print "Converting $m3ufile to $target...";

    if ( ! -f $m3ufile ) {
 print "No m3ufile, returning\n";
 return;
    }

    # Open that m3u file, and convert it to a playback html page.
    open(M3U, $m3ufile) or die "Can't open m3u file";
    my @songs=<M3U>;
    close(M3U);

    if (@songs > 255) {
 print "Too many songs! Oh well\n";
 @songs = @songs[0..254];
    } elsif (@songs == 0) {
 print "No songs, returning\n";
 return;
    } else {
 print "No problems!\n";
    }

    my $first_song = shift @songs;

    chomp $first_song;

    createPlaybackHTMLHeader($m3ufile, $target, $first_song);
    my $count = 1;

    foreach my $song (@songs) {
 chomp $song;
 createPlaybackAddSong($m3ufile, $target, $song, $count);
 $count += 1;
    }

    createPlaybackHTMLFooter($m3ufile, $target);
}

sub entering {
    print "entering Directory boundary ", $File::Find::name, "\n";

    push @M3Us, $File::Find::dir;

    if ($File::Find::name =~ /.AppleDouble/) {
 return;
    }

    return sort(@_);
}

sub leaving {
    print "leaving Directory boundary ", $File::Find::name, "\n";

    my $directory = pop @M3Us;

    # open the file, 
    my $source = $directory . "/PLAY.m3u";
    my $target = $directory . "/PLAY_ALL.html";

    convertM3UToHTML($source, $target);
}

sub wanted {
   print "Checking ", $File::Find::name,"\n";

   if ( $File::Find::name =~ /\.mp3/ ) {
       print "MP3 Found ", $File::Find::name, "\n";
       my $url = $File::Find::name;
       $url =~ s/ /%20/g;
       $url =~ s/\/export\///g;
       $url = $URL_BASE . $url;
       foreach my $dir (@M3Us) {
    my $m3u_file = $dir . "/PLAY.m3u";
    open (M3U, ">>$m3u_file") or die "Boom!";
    print M3U "$url\n";
    close(M3U);
       }
   }
}

sub cleaner {
    if ($File::Find::name =~ /PLAY.m3u/ ) {
 print "Removing ", $File::Find::name, "\n";
 unlink($File::Find::name);
    }

    if ($File::Find::name =~ /PLAY_ALL.html/ ) {
 print "Removing ", $File::Find::name, "\n";
 unlink($File::Find::name);
    }
}

find ({ wanted => \&cleaner},"/export/mp3");

find ({ wanted => \&wanted , preprocess => \&entering, postprocess => \&leaving},"/export/mp3");

open(M3U, "/export/mp3/PLAY.m3u") or die "Unable to open play";

my @main_m3u = <M3U>;
close(M3U);

my @music = grep(!/AudioBooks/, @main_m3u);
my @random = sort { int(rand(3))-1 } @music;

open(M3U, ">/export/mp3/MUSIC.m3u") or die "Unable to open MUSIC.m3u";

print M3U @music;
close(M3U);

convertM3UToHTML("/export/mp3/MUSIC.m3u", "/export/mp3/MUSIC_PLAY.html");

open(M3U, ">/export/mp3/RANDOM.m3u") or die "Unable to open RANDOM.m3u";
print M3U @random;
close(M3U);

convertM3UToHTML("/export/mp3/RANDOM.m3u", "/export/mp3/RANDOM_PLAY.html");

Sunday, November 22, 2009

Streaming Audio to your iPhone

I'm trying to hide the CDs and DVDs that are steadily taking over my house. I've managed to get rid of all of the DVDs, they've all been ripped to the server and are now happily up in the attic. The last problem are the CDs.

Yes, I have them all ripped to the server. The problem is that I don't have any way of getting at them everywhere in the house. Specifically, my wife likes to listen to murder mysteries as she cooks (me, I like cooking to the news). Since I don't have a network enabled stereo, I have to put up with a stack of CDs sitting on the counter.

I have given up waiting for a network enabled stereo system. The squeezebox just doesn't do it for me. I want something small, with wifi and wired, with a radio, clock and a streaming mp3 player. It should also have .m3u support and a "shuffle".

I decided to see what I could do with what we already have...

  • First realization. We both have iPhones.
  • Second realization. We have a WiFi network in the house.
  • Third realization. The iPhone will happily stream music off of a web page.

So the project was formed. First, I tried the SqueezeBox server (previously SlimServer) a server which serves up streams to network attached stereo component equipment. I've got a 1st generation SliMP3, it was a great device. The server just doesn't play well with the iPhone. So, I decided to go the bare bones route. I decided to setup Apache on my file server so that it will serve up music to the iPhones in the house. Then the phones can be used to stream the music/books wherever anyone is in the house. I would finally be allowed to hide all of the CDs! Perfect!

Setting up Apache was pretty easy. I followed the instructions that are easily Googled. I didn't create any HTML files, but I did configure the auto_index module (/etc/apache2/mods-available/autoindex.conf). My changed settings were:

IndexOptions SuppressDescription SuppressSize SuppressLastModified
IndexOptions SuppressHTMLPreamble
HeaderName /include/iPhone_Header.html

NOTE: HeaderName is relative to the DocumentRoot, not the filesystem.

This allowed me to keep the listing to just the filenames, and replaced the standard HTML header with one of my own:

<html>
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.25"/>
</head>
<body>

This header provides a hint to the iPhone of where to set the viewport. It seems to work for my listings, making the file list usable.

Once we have that, we've got a server with a directory listing that we can scroll through and play individual MP3s. We don't have any playlists though, which is pretty unpleasant.

Bring in the Perl!

I've written a small piece of Perl code to iterate over my MP3 tree and create M3U files in each directory containing URLs for all of the MP3s that are children of that directory. Because of how I store my MP3s, that gives me album, artist and full play lists. I then randomize the playlist to give me a shuffled list.

The new iPhone release is able to play M3U files, with one problem. You can't skip to the next track, which is pretty poor. But now I've got a method of delivering music to any room in the house. I just have to get one of those 3rd party iPod speaker systems, and I can get rid of all of the CDs in the kitchen!

#!/usr/bin/perl

use File::Find;

use vars qw/*name *dir *prune/;

my $URL_BASE= "http://10.10.10.5/";

my @M3Us;

sub entering {
    print "entering Directory boundary ", $File::Find::name, "\n";

    push @M3Us, $File::Find::dir;
    return sort(@_);
}

sub leaving {
    print "leaving Directory boundary ", $File::Find::name, "\n";

    pop @M3Us;
}

sub wanted {
   print "Checking ", $File::Find::name,"\n";

   if ( $File::Find::name =~ /\.mp3/ ) {
       print "MP3 Found ", $File::Find::name, "\n";
       my $url = $File::Find::name;
       $url =~ s/ /%20/g;
       $url =~ s/\/export\///g;
       $url = $URL_BASE . $url;
       foreach my $dir (@M3Us) {
    my $m3u_file = $dir . "/PLAY.m3u";
    open (M3U, ">>$m3u_file") or die "Boom!";
    print M3U "$url\n";
    close(M3U);
       }
   }
}

sub cleaner {
    if ($File::Find::name =~ /PLAY.m3u/ ) {
 print "Removing ", $File::Find::name, "\n";
 unlink($File::Find::name);
    }
}

find ({ wanted => \&cleaner},"/export/mp3");

find ({ wanted => \&wanted , preprocess => \&entering, postprocess => \&leaving},"/export/mp3");

open(M3U, "/export/mp3/PLAY.m3u") or die "Unable to open play";

my @main_m3u = <M3U>;
close(M3U);

my @music = grep(!/AudioBooks/, @main_m3u);
my @random = sort { int(rand(3))-1 } @music;

open(M3U, ">/export/mp3/MUSIC.m3u") or die "Unable to open MUSIC.m3u";
print M3U "@music";
close(M3U);

open(M3U, ">/export/mp3/RANDOM.m3u") or die "Unable to open RANDOM.m3u";
print M3U "@random";
close(M3U);