daikin / api
Manage your Daikin air conditional.
Requires
- php: >=8.5
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12.0
- symfony/http-client: ^7.4 || ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.95
- infection/infection: ^0.32
- symfony/var-dumper: ^7.4 || ^8.0
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\Power—ON,OFFDaikin\Enums\Mode—AUTO,DEHUMIDIFIER,COLD,HOT,FANDaikin\Enums\FanRate—AUTO,SILENCE,LVL_1toLVL_5Daikin\Enums\FanDirection—ALL_WING_STOPPED,VERTICAL_WINGS_MOTION,HORIZONTAL_WINGS_MOTION,VERTICAL_AND_HORIZONTAL_WINGS_MOTIONDaikin\Enums\Led—ON,OFFDaikin\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.