PHP SDK for interacting with the AC Infinity API. Control and monitor your AC Infinity devices programmatically.
⚠️ Disclaimer: This is an unofficial, community-developed project and is not affiliated with, endorsed by, or supported by AC Infinity. AC Infinity is a trademark of AC Infinity Inc. Use this SDK at your own risk. The authors are not responsible for any damages or issues that may arise from using this software.
- PHP >= 8.4
- Guzzle HTTP Client ^7.0
- ext-json
- ext-zlib
Install via Composer:
composer require tvorwachs/ac-infinity-php<?php
require __DIR__ . '/vendor/autoload.php';
use tvorwachs\AcInfinityPhp\AcInfinityApiClient;
// Create client
$client = new AcInfinityApiClient(
'your-email@example.com',
'your-password',
'path/to/token.json' // Optional: for token persistence
);
// Get device information
$deviceInfo = $client->getDeviceInfo();
// Access device data
echo "Temperature: " . $deviceInfo->temperature . "°C\n";
echo "Humidity: " . $deviceInfo->humidity . "%\n";
echo "VPD: " . $deviceInfo->vpd . "\n";
// Access ports
$lightPort = $deviceInfo->getLightPort();
$dFanPort = $deviceInfo->getDFanPort();
$cFanPort = $deviceInfo->getCFanPort();
echo "Light Level: " . $lightPort->getLevel() . "%\n";
echo "D-Fan Level: " . $dFanPort->getLevel() . "%\n";
echo "C-Fan Level: " . $cFanPort->getLevel() . "%\n";// Get complete device data response
$response = $client->fetchDeviceData();
// Check if request was successful
if ($response->isSuccess()) {
// Get first device
$device = $response->getFirstDevice();
// Iterate through all devices
foreach ($response->devices as $device) {
echo "Device: " . $device->deviceName . "\n";
// Iterate through all ports
foreach ($device->ports as $port) {
echo "Port {$port->portId}: {$port->name} - Level: {$port->getLevel()}%\n";
}
}
}// Manually trigger login
$loginResponse = $client->login();
if ($loginResponse->isSuccess()) {
echo "Login successful! Token: " . $loginResponse->token . "\n";
} else {
echo "Login failed: " . $loginResponse->message . "\n";
}// Get current token (auto-login if needed)
$token = $client->getToken();
// Create client with token persistence
$client = new AcInfinityApiClient(
'your-email@example.com',
'your-password',
__DIR__ . '/token.json' // Token will be saved/loaded from this file
);new AcInfinityApiClient(string $email, string $password, ?string $tokenFile = null)$email: AC Infinity account email$password: AC Infinity account password$tokenFile: Optional path to store/load authentication token
login(): LoginResponse
- Authenticates with AC Infinity API
- Returns
LoginResponseobject - Throws
Exceptionon failure
getToken(): string
- Returns current authentication token
- Auto-login if no token exists
- Throws
Exceptionon failure
fetchDeviceData(): DeviceDataResponse
- Fetches all device data from API
- Returns
DeviceDataResponseobject - Throws
Exceptionon failure
getDeviceInfo(): DeviceInfo
- Gets information for the first device
- Returns
DeviceInfoobject - Throws
Exceptionif no device found
Properties:
array $ports- Array of Port objects?float $temperature- Temperature reading?float $humidity- Humidity reading?float $vpd- VPD (Vapor Pressure Deficit)?string $deviceName- Device name?string $deviceId- Device ID
Methods:
getPort(int $index): ?Port- Get port by indexgetLightPort(): ?Port- Get light port (index 0)getDFanPort(): ?Port- Get D-Fan port (index 1)getCFanPort(): ?Port- Get C-Fan port (index 2)
Properties:
int $portId- Port identifier?int $speak- Raw port value?string $name- Port name
Methods:
getLevel(): int- Get level as percentage (speak * 10)
Properties:
int $code- Response code?string $message- Response messagearray $devices- Array of DeviceInfo objects
Methods:
getFirstDevice(): ?DeviceInfo- Get first deviceisSuccess(): bool- Check if request was successful (code === 200)
Properties:
int $code- Response code?string $message- Response message?string $token- Authentication token
Methods:
isSuccess(): bool- Check if login was successful (code === 200)
See the examples/ directory for complete examples:
fetch_device_data.php- Complete example showing how to fetch device data and create a 6-hour history log
MIT License - see LICENSE file for details.
This project is not affiliated with, endorsed by, or supported by AC Infinity Inc. AC Infinity is a registered trademark of AC Infinity Inc. This is an independent, unofficial SDK created by the community.
Use at your own risk. The authors and contributors of this project are not responsible for any damages, data loss, or issues that may occur from using this software. Always test in a safe environment before using in production.
Contributions are welcome! Please feel free to submit a Pull Request.
For issues, questions, or contributions, please visit the GitHub repository.