ewelink-api-php lets you talk to your eWeLink–enabled devices (Sonoff, KingArt, etc.) directly from PHP. It wraps the official HTTP & WebSocket endpoints, handles OAuth, and gives you a neat object‑oriented façade.
composer require pjanisio/ewelink-api-phpComposer installs the library, creates vendor/autoload.php, and you’re ready to go.
$lampId = '100xxxxxx';
$devices->setDeviceStatus($lampId, ['switch' => 'on']); // turn it onFull examples live in the Wiki.
| Area | What you can do |
|---|---|
| Discovery | • Fetch all devices in one call • Search by deviceid or human name• Persist raw data as devices.json |
| Status | • Read any single or multi params live (switch, voltage, power, …)• Grab all live params at once • Check if a device is online |
| Control | • Set one or many params (HTTP) • Multi‑channel helpers ( switches[n])• WebSocket realtime control |
| Monitoring | • Live power metrics (voltage / current / power) • Device history endpoint ( /v2/device/history) |
| Maintenance | • Force wake‑up (handshake + echo params) |
| Dev tools | • PSR‑4 autoloading via Composer • DEBUG mode – full request/response log to debug.log |
Need an out‑of‑the‑box dashboard? Check the companion project ewelinkapiphp‑device‑monitoring – asynchronous UI, HTTP + WS under the hood.
- Getting started / API reference → see the Wiki Pages
- Developer notes (architecture, contribution guide) → Developers Wiki
- PHP 7.4 or newer
- Extensions:
curl,json,openssl( enabled by default on typical PHP installs)
MIT – do what you want, just keep the copyright notice.
- Drupal eWeLink module – integrate Sonoff devices into your Drupal site via drupal.org/project/ewelink
- Bee Hotel Reservation Access – powers the Bee Hotel, see Bee Hotel docs