Homeplug Rebooting Scripts

I use homeplugs for some of the networking in my flat and unfortunately over time they seem to degrade and get into a mess. This leads to high pings and even failure to function at all but thankfully a reset fixes this. However, it’s a pain to wander around and re-plug them all individually so I’ve written a script to do it.

Here’s the script and you can download it here:


use v5.10;
use warnings;
use strict;

use Readonly;
use IPC::Cmd qw/ run /;

# Get the MACs of all other homeplugs
run(command => "echo A038 | faifa -m",
    buffer => \my $out,
    # For some reason it takes about this long to get the data
    timeout => 3);
Readonly my @MACS => $out =~ /\n((?:\w{2}:){5}\w{2})/g;

for my $mac (@MACS) {
    # Reboot other homeplugs one at a time
    run(command => "echo A01C | faifa -m -a $mac",
    timeout => 1);

# Then reboot this one
run(command => "echo A01C | faifa -m",
    timeout => 1);

It uses the faifa program which can interface with the homeplugs and is available in the Ubuntu repos.