tvorwachs/ac-infinity-php

PHP SDK for AC Infinity API

Installs: 2

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/tvorwachs/ac-infinity-php

0.1.0 2025-10-04 18:36 UTC

This package is auto-updated.

Last update: 2025-10-04 18:39:11 UTC


README

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.

Requirements

  • PHP >= 8.4
  • Guzzle HTTP Client ^7.0
  • ext-json
  • ext-zlib

Installation

Install via Composer:

composer require tvorwachs/ac-infinity-php

Usage

Basic Example

<?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";

Advanced Usage

Fetch All Device Data

// 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";
        }
    }
}

Manual Login

// Manually trigger login
$loginResponse = $client->login();

if ($loginResponse->isSuccess()) {
    echo "Login successful! Token: " . $loginResponse->token . "\n";
} else {
    echo "Login failed: " . $loginResponse->message . "\n";
}

Token Management

// 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
);

API Reference

AcInfinityApiClient

Constructor

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

Methods

login(): LoginResponse

  • Authenticates with AC Infinity API
  • Returns LoginResponse object
  • Throws Exception on failure

getToken(): string

  • Returns current authentication token
  • Auto-login if no token exists
  • Throws Exception on failure

fetchDeviceData(): DeviceDataResponse

  • Fetches all device data from API
  • Returns DeviceDataResponse object
  • Throws Exception on failure

getDeviceInfo(): DeviceInfo

  • Gets information for the first device
  • Returns DeviceInfo object
  • Throws Exception if no device found

Models

DeviceInfo

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 index
  • getLightPort(): ?Port - Get light port (index 0)
  • getDFanPort(): ?Port - Get D-Fan port (index 1)
  • getCFanPort(): ?Port - Get C-Fan port (index 2)

Port

Properties:

  • int $portId - Port identifier
  • ?int $speak - Raw port value
  • ?string $name - Port name

Methods:

  • getLevel(): int - Get level as percentage (speak * 10)

DeviceDataResponse

Properties:

  • int $code - Response code
  • ?string $message - Response message
  • array $devices - Array of DeviceInfo objects

Methods:

  • getFirstDevice(): ?DeviceInfo - Get first device
  • isSuccess(): bool - Check if request was successful (code === 200)

LoginResponse

Properties:

  • int $code - Response code
  • ?string $message - Response message
  • ?string $token - Authentication token

Methods:

  • isSuccess(): bool - Check if login was successful (code === 200)

Examples

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

License

MIT License - see LICENSE file for details.

Disclaimer

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.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Support

For issues, questions, or contributions, please visit the GitHub repository.