定制 robstiles/ediplug 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

robstiles/ediplug

Composer 安装命令:

composer require robstiles/ediplug

包简介

Package to communicate with EdiMax EdiPlug smart power plugs.

README 文档

README

A package to communicate with EdiMax EdiPlug smart power plugs.

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.

A work in progress with basic functionality.

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;

统计信息

  • 总下载量: 21
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-16