1. Go to this page and download the library: Download gared/shelly-php-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
gared / shelly-php-client example snippets
$client = new \ShellyClient\HTTP\Client('http://192.168.1.10');
$client = new \ShellyClient\HTTP\Client('http://shellyuser:[email protected]');
// Create new client for one device
$clientLightA = new \ShellyClient\HTTP\Client('http://192.168.1.10', 'ShellyDeviceLightA');
$clientLightB = new \ShellyClient\HTTP\Client('http://192.168.1.20', 'ShellyDeviceLightB');
// Switch device on and get relay data
$relayRequest = new \ShellyClient\Model\Request\RelayRequest();
$relayRequest->setRelayIndex(0);
$relayRequest->setTurn(\ShellyClient\Model\Request\RelayRequest::TURN_ON);
$relay = $clientLightA->getRelay($relayRequest);
// check if timer has been set
if ($relay->hasTimer()) {
// do something
}
$meter = $clientLightA->getMeter(new \ShellyClient\Model\Request\MeterRequest());
// Get total power consumption in kW/h
$kilowattHours = $meter->getTotalInKilowattHours();
// Get last three watt per minute power consumption values
$counters = $meter->getCounters();
// Parallel call informations from device B
$power = $clientLightB->getMeter(new \ShellyClient\Model\Request\MeterRequest())->getPower();
// Get device name set above in construct
$deviceNameDeviceB = $clientLightB->getDeviceName();
// or use device name set in shelly device
$deviceNameShelly = $clientLightB->getSettings(new \ShellyClient\Model\Request\SettingsRequest())->getName();
gitattributes
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.