Thanks to visit codestin.com
Credit goes to github.com

Skip to content

API connector for Sonoff / ewelink devices

License

Notifications You must be signed in to change notification settings

PJanisio/ewelinkApiPhp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

202 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eWeLink API PHP – Connect to Sonoff / eWeLink devices

Packagist PHP >= 7.4 CI License

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.


📦 Installation

composer require pjanisio/ewelink-api-php

Composer installs the library, creates vendor/autoload.php, and you’re ready to go.


🚀 Quick‑example (after authorization)

$lampId  = '100xxxxxx';
$devices->setDeviceStatus($lampId, ['switch' => 'on']);  // turn it on

Full examples live in the Wiki.


✅ Features

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

🖥️ Demo Monitoring App

Need an out‑of‑the‑box dashboard? Check the companion project ewelinkapiphp‑device‑monitoring – asynchronous UI, HTTP + WS under the hood.

Monitoring screenshot


🗂 Documentation

  • Getting started / API reference → see the Wiki Pages
  • Developer notes (architecture, contribution guide) → Developers Wiki

⚙️ Requirements

  • PHP 7.4 or newer
  • Extensions: curl, json, openssl ( enabled by default on typical PHP installs)

📝 License

MIT – do what you want, just keep the copyright notice.


🔗 Integrations & Use Cases

About

API connector for Sonoff / ewelink devices

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published

Contributors 2

  •  
  •  

Languages