hellojb/foxess-php
Composer 安装命令:
composer require hellojb/foxess-php
包简介
PHP SDK for the FoxESS Cloud API with Laravel support
README 文档
README
PHP SDK for the FoxESS Cloud Open API with Laravel support.
Features
- OAuth 2.0 Authorization Code Grant authentication
- Automatic token refresh
- Real-time device data (battery SOC, solar generation, grid import/export, load statistics)
- Batch queries for multiple devices
- Typed DTOs with helper methods
- Laravel Service Provider, Facade, and config
- Rate limit exception handling
Requirements
- PHP 8.2+
- GuzzleHTTP 7.0+
Installation
composer require hellojb/foxess-php
Standalone Usage
use Hellojb\Foxess\FoxEss; use Hellojb\Foxess\Auth\AccessToken; $token = new AccessToken('your-access-token'); $client = new FoxEss([ 'base_url' => 'https://www.foxesscloud.com/', 'token' => $token, ]); $realTime = $client->realTimeData()->query(['YOUR_DEVICE_SN']); foreach ($realTime as $data) { echo "SoC: {$data->soc()}%\n"; echo "PV Power: {$data->pvPower()} kW\n"; echo "Charging: " . ($data->isCharging() ? 'Yes' : 'No') . "\n"; }
Laravel Usage
Publish the config:
php artisan vendor:publish --tag=foxess-config
Set .env variables:
FOXESS_CLIENT_ID=your-client-id FOXESS_CLIENT_SECRET=your-client-secret FOXESS_REDIRECT_URI=https://your-app.com/auth/foxess/callback
Use the Facade:
use Hellojb\Foxess\Laravel\FoxEssFacade as FoxEss; $realTime = FoxEss::realTimeData()->query(['SN001']);
Real-Time Data Helpers
The RealTimeData DTO provides convenient accessors:
| Method | Description |
|---|---|
soc() |
Battery state of charge (%) |
pvPower() |
Solar generation (kW) |
loadsPower() |
Home load (kW) |
batteryPower() |
Battery power (negative = charging, positive = discharging) |
isCharging() |
Is battery currently charging? |
isDischarging() |
Is battery currently discharging? |
isImporting() |
Is power being imported from grid? |
isExporting() |
Is power being exported to grid? |
License
MIT
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-07-10