daikin/api 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

daikin/api

最新稳定版本:3.2.0

Composer 安装命令:

composer require daikin/api

包简介

Manage your Daikin air conditional.

README 文档

README

A PHP library to control and read information from a Daikin air conditioner over the local network through its built-in Wi-Fi HTTP API.

Requirements

  • PHP 8.5 or higher
  • A Daikin air conditioner reachable on your local network (you must know its IP address)

Installation

Install the library with Composer:

composer require daikin/api

Overview

The library exposes a small set of classes that map directly to the Daikin HTTP endpoints:

  • Connect — handles the HTTP communication with the air conditioner. It validates the IP address and performs the GET/POST requests.
  • GetBasicInformation — returns basic device information (firmware, name, MAC address, etc.).
  • GetRemoteMethod — returns the remote control configuration of the device.
  • GetAirconModelInfo — returns the model information of the unit.
  • GetAirconSensorInfo — returns the current sensor readings (indoor/outdoor temperature, humidity, etc.).
  • SendAirconControlInfo — sends control commands to the unit (power, mode, target temperature, fan rate, fan direction).

All "Get*" classes implement Daikin\Interfaces\PresentationInterface and expose a format() method that returns the data as an associative array. SendAirconControlInfo implements Daikin\Interfaces\PushInterface and exposes a push(array $parameters) method.

Any communication error (invalid IP, non-200 HTTP response, etc.) throws a Daikin\Exceptions\DaikinException.

Enums

The library ships with PHP enums to avoid using magic values when sending control commands:

  • Daikin\Enums\PowerON, OFF
  • Daikin\Enums\ModeAUTO, DEHUMIDIFIER, COLD, HOT, FAN
  • Daikin\Enums\FanRateAUTO, SILENCE, LVL_1 to LVL_5
  • Daikin\Enums\FanDirectionALL_WING_STOPPED, VERTICAL_WINGS_MOTION, HORIZONTAL_WINGS_MOTION, VERTICAL_AND_HORIZONTAL_WINGS_MOTION
  • Daikin\Enums\LedON, OFF
  • Daikin\Enums\EquipmentStatus

Basic usage

<?php
require_once('vendor/autoload.php');

use Daikin\SendAirconControlInfo;
use Daikin\Connect;
use Daikin\Enums\Mode;
use Daikin\GetAirconModelInfo;
use Daikin\GetBasicInformation;
use Daikin\GetRemoteMethod;
use Daikin\GetAirconSensorInfo;
use Daikin\Enums\Power;
use Daikin\Enums\FanRate;
use Daikin\Enums\FanDirection;

// Create a Connect instance with the IP address of your Daikin unit.
// An invalid IP throws Daikin\Exceptions\DaikinException.
$connect = new Connect('192.168.1.117');

// Read information from the unit. Each format() call performs an HTTP request
// and returns an associative array parsed from the device response.
var_dump((new GetBasicInformation($connect))->format());
var_dump((new GetRemoteMethod($connect))->format());
var_dump((new GetAirconModelInfo($connect))->format());
var_dump((new GetAirconSensorInfo($connect))->format());

// Send a control command to the unit.
// All values must be strings because they are sent as query parameters.
//   pow    : Power on/off
//   mode   : operating mode (cold, hot, auto, fan, dehumidifier)
//   stemp  : target temperature in Celsius
//   shum   : target humidity (0 if not applicable)
//   f_rate : fan speed
//   f_dir  : fan/wings direction
var_dump((new SendAirconControlInfo($connect))->push([
     'pow' => (string) Power::OFF->value,
     'mode' => Mode::COLD->value,
     'stemp' => '20',
     'shum' => '0',
     'f_rate' => FanRate::SILENCE->value,
     'f_dir' => (string) FanDirection::ALL_WING_STOPPED->value,
]));

Error handling

Wrap calls in a try/catch block to handle network or device errors:

use Daikin\Exceptions\DaikinException;

try {
    $info = (new GetBasicInformation($connect))->format();
} catch (DaikinException $e) {
    // The device is unreachable, returned a non-200 status code,
    // or the IP provided to Connect is not a valid IP address.
    echo $e->getMessage();
}

License

This library is released under the LGPL-3.0-or-later license. See the LICENCE file for details.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2021-05-17

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固