2017 © Pedro Peláez
 

library ediplug

Package to communicate with EdiMax EdiPlug smart power plugs.

image

robstiles/ediplug

Package to communicate with EdiMax EdiPlug smart power plugs.

  • Wednesday, March 18, 2015
  • by kebian
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

EdiPlug

A package to communicate with EdiMax EdiPlug smart power plugs., (*1)

This package will allow you to check the power status of your plug, turn it off and on as well as retrieve and set new power schedules., (*2)

A work in progress with basic functionality., (*3)

Example Code

Locating Plugs

// Create the locator
$locator = new Locator();
// Spend 5 seconds looking for plugs
$plugs = $locator->scan(5);
foreach($plugs as $plug) {
    echo "MAC: $plug->mac\n" ;
    echo "Manufacturer: $plug->manufacturer\n";
    echo "Model: $plug->model\n";
    echo "Version: $plug->version\n";
    echo "IP Address: $plug->ip_address\n";
}

Turning a Plug On or Off

// Create object with address, username and password.
$plug = new EdiPlug('192.168.1.100', 'admin', '1234');
// Turn it on
$plug->on();
// Turn it off
$plug->off()
// Or use its power property
$plug->power = true;

Disable All Schedules

    $plug = new EdiPlug('192.168.1.100', 'admin', '1234');

    // Get the week's schedule information from the plug.
    $week_schedule = $plug->schedule;

    // Cycle through each day
    foreach($week_schedule as $day => $day_schedule) {
        // Turn off all the schedules
        $day_schedule->enabled = false;
    }
    // Send new schedule back to the plug
    $plug->schedule = $week_schedule;

Cycle Through Each Period for Tuesday

    $plug = new EdiPlug('192.168.1.100', 'admin', '1234');

    // Get the week's schedule information from the plug.
    $week_schedule = $plug->schedule;

    // Cycle through each on/off period for Tuesday
    foreach($week_schedule[WeekSchedule::TUESDAY] as $period) {
        echo "On at $period->on, off at $period->off<br />\n";
    }

Set Power to Come On Friday 7pm - 11pm

    $plug = new EdiPlug('192.168.1.100', 'admin', '1234');

    $week_schedule = $plug->schedule;

    $friday = $week_schedule[WeekSchedule::FRIDAY];
    $friday->add(TimePeriod::createFromTimes(
        Carbon::createFromTime(19,00),
        Carbon::createFromTime(23,00)
    ));
    $friday->enabled = true;

    $plug->schedule = $week_schedule;

The Versions

18/03 2015

dev-master

9999999-dev

Package to communicate with EdiMax EdiPlug smart power plugs.

  Sources   Download

MIT

The Requires

 

by Rob Stiles