怎么用PHP语言实现远程控制电器呢?
本文描述了使用PHP语言调用HTTP接口,实现控制电器,通过控制电器的电源线路来实现电器控制。
可选用产品:可根据实际场景需求,选择对应的规格
序号 | 设备名称 | 厂商 |
---|---|---|
1 | 智能WiFi通断器AC3 | 统软云物联 |
2 | 智能WiFi通断器AC4-10A | 统软云物联 |
3 | 智能WiFi通断器AC4-20A | 统软云物联 |
4 | 智能WiFi通断器AC4-30A | 统软云物联 |
5 | 智能WiFi通断器AC5-10A | 统软云物联 |
下面以每款产品为例,用编程实现远程:
1. 智能WiFi通断器AC3

体积小巧,方便接入三方电器设备中;
总额定功率2000W(10A版本)、3500W(16A版本);
按钮动作可自定义、可屏蔽;
功率计量版可设置安全功率,超过则自动断电;
HTTP接口远程控制通断;
;
支持远程定时任务,支持自定义联动操作;
使用调用HTTP接口控制智能WiFi通断器AC3的代码
以设备控制(向设备下发命令)为例
全部接口文档复制
php
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append(new http\QueryString(array(
'device' => '设备ID',
'order' => '命令'
)));
/*
device[字符串]:设备唯一ID,可传多个,可在控制台可查看,也可通过接口拉取;
order[json字符串]:命令,取值参考:
1. 线路 - 可用值[1(打开),0(关闭)]
示例[关闭], order为:{"power":"0"}
2. 计量 - 可用值[1(打开),0(关闭)]
示例[关闭], order为:{"metering":"0"}
3. 先通后断 - 自定义
示例[3秒], order为:{"point":"3000"}
4. 先断后通 - 自定义
示例[3秒], order为:{"reset":"3000"}
*/
$request->setRequestUrl("http://iot-api.unisoft.cn/{APP_ID}/device/control/?sign={sign}&ts={ts}");
$request->setRequestMethod("POST");
$request->setBody($body);
$request->setHeaders(array(
"X-APISpace-Token" => "",
"Content-Type" => ""
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
说明:{APP_ID}为您的应用ID(由平台生成),免费注册登录后,可在控制台查看;sign和ts的取值,请参考文档。
2. 智能WiFi通断器AC4-10A

体积小巧,方便接入三方电器设备中;
总额定功率2000W;
按钮动作可自定义、可屏蔽;
HTTP接口远程控制通断;
支持远程定时任务,支持自定义联动操作;
使用调用HTTP接口控制智能WiFi通断器AC4-10A的代码
以设备控制(向设备下发命令)为例
全部接口文档复制
php
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append(new http\QueryString(array(
'device' => '设备ID',
'order' => '命令'
)));
/*
device[字符串]:设备唯一ID,可传多个,可在控制台可查看,也可通过接口拉取;
order[json字符串]:命令,取值参考:
1. 线路 - 可用值[1(打开),0(关闭)]
示例[关闭], order为:{"power":"0"}
2. 先通后断 - 自定义
示例[3秒], order为:{"point":"3000"}
3. 先断后通 - 自定义
示例[3秒], order为:{"reset":"3000"}
*/
$request->setRequestUrl("http://iot-api.unisoft.cn/{APP_ID}/device/control/?sign={sign}&ts={ts}");
$request->setRequestMethod("POST");
$request->setBody($body);
$request->setHeaders(array(
"X-APISpace-Token" => "",
"Content-Type" => ""
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
说明:{APP_ID}为您的应用ID(由平台生成),免费注册登录后,可在控制台查看;sign和ts的取值,请参考文档。
3. 智能WiFi通断器AC4-20A

总额定功率4400W;
按钮动作可自定义、可屏蔽;
HTTP接口远程控制通断;
支持远程定时任务,支持自定义联动操作;
使用调用HTTP接口控制智能WiFi通断器AC4-20A的代码
以设备控制(向设备下发命令)为例
全部接口文档复制
php
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append(new http\QueryString(array(
'device' => '设备ID',
'order' => '命令'
)));
/*
device[字符串]:设备唯一ID,可传多个,可在控制台可查看,也可通过接口拉取;
order[json字符串]:命令,取值参考:
1. 线路 - 可用值[1(打开),0(关闭)]
示例[关闭], order为:{"power":"0"}
2. 先通后断 - 自定义
示例[3秒], order为:{"point":"3000"}
3. 先断后通 - 自定义
示例[3秒], order为:{"reset":"3000"}
*/
$request->setRequestUrl("http://iot-api.unisoft.cn/{APP_ID}/device/control/?sign={sign}&ts={ts}");
$request->setRequestMethod("POST");
$request->setBody($body);
$request->setHeaders(array(
"X-APISpace-Token" => "",
"Content-Type" => ""
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
说明:{APP_ID}为您的应用ID(由平台生成),免费注册登录后,可在控制台查看;sign和ts的取值,请参考文档。
4. 智能WiFi通断器AC4-30A

总额定功率6600W;
按钮动作可自定义、可屏蔽;
HTTP接口远程控制通断;
支持远程定时任务,支持自定义联动操作;
使用调用HTTP接口控制智能WiFi通断器AC4-30A的代码
以设备控制(向设备下发命令)为例
全部接口文档复制
php
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append(new http\QueryString(array(
'device' => '设备ID',
'order' => '命令'
)));
/*
device[字符串]:设备唯一ID,可传多个,可在控制台可查看,也可通过接口拉取;
order[json字符串]:命令,取值参考:
1. 线路 - 可用值[1(打开),0(关闭)]
示例[关闭], order为:{"power":"0"}
2. 先通后断 - 自定义
示例[3秒], order为:{"point":"3000"}
3. 先断后通 - 自定义
示例[3秒], order为:{"reset":"3000"}
*/
$request->setRequestUrl("http://iot-api.unisoft.cn/{APP_ID}/device/control/?sign={sign}&ts={ts}");
$request->setRequestMethod("POST");
$request->setBody($body);
$request->setHeaders(array(
"X-APISpace-Token" => "",
"Content-Type" => ""
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
说明:{APP_ID}为您的应用ID(由平台生成),免费注册登录后,可在控制台查看;sign和ts的取值,请参考文档。
5. 智能WiFi通断器AC5-10A

体积小巧,方便接入三方电器设备中;
总额定功率2000W;
按钮动作可自定义、可屏蔽;
HTTP接口远程控制通断;
提供一路开关量输入,可外接轻触开关;
支持远程定时任务,支持自定义联动操作;
使用调用HTTP接口控制智能WiFi通断器AC5-10A的代码
以设备控制(向设备下发命令)为例
全部接口文档复制
php
<?php
$client = new http\Client;
$request = new http\Client\Request;
$body = new http\Message\Body;
$body->append(new http\QueryString(array(
'device' => '设备ID',
'order' => '命令'
)));
/*
device[字符串]:设备唯一ID,可传多个,可在控制台可查看,也可通过接口拉取;
order[json字符串]:命令,取值参考:
1. 线路 - 可用值[1(打开),0(关闭)]
示例[关闭], order为:{"power":"0"}
2. 先通后断 - 自定义
示例[3秒], order为:{"point":"3000"}
3. 先断后通 - 自定义
示例[3秒], order为:{"reset":"3000"}
*/
$request->setRequestUrl("http://iot-api.unisoft.cn/{APP_ID}/device/control/?sign={sign}&ts={ts}");
$request->setRequestMethod("POST");
$request->setBody($body);
$request->setHeaders(array(
"X-APISpace-Token" => "",
"Content-Type" => ""
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
说明:{APP_ID}为您的应用ID(由平台生成),免费注册登录后,可在控制台查看;sign和ts的取值,请参考文档。
产品参数对比
产品 | 版本 |
---|---|
![]() |
###### 10A |
![]() |
###### 10A计量版 |
![]() |
###### 16A |
![]() |
###### 10A |
![]() |
###### 20A |
![]() |
###### 白色 |
![]() |
###### 白色 |
产品尺寸与走线
1. 智能WiFi通断器AC3接线示意图
产品尺寸





2. 智能WiFi通断器AC4-10A接线示意图
产品尺寸





走线示意
* 接线前请确保断路器上的电源已关闭

3. 智能WiFi通断器AC4-20A接线示意图
产品尺寸





4. 智能WiFi通断器AC4-30A接线示意图
产品尺寸





5. 智能WiFi通断器AC5-10A接线示意图
产品尺寸




