eWeLink API PHP is a connector for Sonoff / eWeLink devices. This library allows you to interact with your eWeLink-enabled devices from your browser.
- PHP 7.4+
- cURL extension enabled
- get all devices list with their parameters using deviceId or deviceName from ewelink app
- saving devices data and other outputs from API to .json
- search for any value of each device (f.e switch status, productName, MAC etc.)
- set any parameter/state of device using HTTP gateway or websockets
- set parameter for multi-channel devices (like 4CH Pro)
- update power parameters like current, voltage, power for electricity monitoring devices
- debug all requests and responses to debug.log
Go to Wiki Pages to get started read about possible methods.
This is a single case example to turn on device.
Look at Wiki Pages to get knowledge of how to start and other methods.
<?php
$deviceId = 'your_device_id';
$params = ['switch' => 'on'];
$statusUpdateResult = $devices->setDeviceStatus($deviceId, $params);
echo $statusUpdateResult;
Please see example app written based on this class that checks and update chosen parameters in real time (using asynchronous calls) using both HTTP and websocket method alltogether.
Visit wiki page for devs: devs-wiki