PHP code example of antriver / energenie-mihome-api
1. Go to this page and download the library: Download antriver/energenie-mihome-api 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/ */
antriver / energenie-mihome-api example snippets
use Antriver\EnergenieMihomeApi\Entities\Subdevice;
'password');
$subdevices = $api->listAllSubdevices();
print_r($subdevices);
$fairyLights = array_values(
array_filter(
$subdevices,
function (Subdevice $subdevice) {
return $subdevice->label === 'Fairy Lights';
}
)
)[0];
$api->powerOnSubdevice($fairyLights->id);
sleep(5);
$api->powerOffSubdevice($fairyLights->id);