shadowroot2/gree_ac

通过WiFi模块控制Gree空调的API

1.0 2022-11-27 12:50 UTC

This package is auto-updated.

Last update: 2024-09-27 16:36:13 UTC


README

通过网络控制Gree空调的WiFi API

为了让它工作,您应该通过获取每次重置Gree空调WiFi时生成的密钥来初始化与Gree+的连接。

  1. 按Gree空调遥控器的模式 + WiFi按钮(空调必须响一下)并等待2分钟(空调将进入WiFi接入点模式)。
  2. 搜索名称类似于:f4211ede6d31的WiFi AP,并将您的电脑连接到它(WiFi密码是:12345678)
  3. 编写简单的脚本,例如finder.php
<?php
  require_once 'vendor/autoload.php';

  $gree = new \Gree\GreeAC();
  $gree->setDebug(true); // If you want to see all
  
  print_r($gree->scan());
?>
  1. 在控制台运行 "php finder.php",您将看到响应
Array
(
    [t] => dev
    [cid] => f4211ede6d31
    [bc] => gree
    [brand] => gree
    [catalog] => gree
    [mac] => f4211ede6d31
    [mid] => 10002
    [model] => gree
    [name] => 1ede6d31
    [series] => gree
    [vender] => 1
    [ver] => V1.1.13
    [lock] => 0
)
  1. 将cid复制到某处
  2. 要获取绑定密钥(安全密钥),编写如bind.php的脚本
<?php
  require_once 'vendor/autoload.php';

  $gree = new \Gree\GreeAC(); 
  $gree->setDebug(true); // If you want to see all
  $gree->setCID('f4211ede6d31'); // Replace to your own cid
  
  $key = $gree->getBindKey();
  
  echo 'Secure key is: '.$key;
?>
  1. 在控制台运行 "php bind.php",您将看到响应:安全密钥是:Lz5Op8Rs2Uv4Xy5A
  2. 将此密钥保存到某处
  3. 将空调添加到Gree+应用(它将添加到您的WiFi路由器)
  4. 从您的WiFi路由器获取空调的IP地址(例如,它为192.168.10.3)
  5. 编写简单的脚本,例如test.php
<?php
  require_once 'vendor/autoload.php';

  $gree = new \Gree\GreeAC('192.168.10.3', 'f4211ede6d31', 'Lz5Op8Rs2Uv4Xy5A'); // Replace values to yours
  $gree->setDebug(true); // If you want to see all
  
  print_r($gree->status()); // Will show current settings
  print_r($gree->on()); // Switch on AC
  sleep(3);
  print_r($gree->off()); // Switch off AC
  // ...etc
?>