PHP code example of chipneedham / laravel-govee

1. Go to this page and download the library: Download chipneedham/laravel-govee 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/ */

    

chipneedham / laravel-govee example snippets


GOVEE_API_KEY=your_govee_api_key_here

use Govee;

// Get all Govee devices
$devices = Govee::getDevices();

foreach ($devices as $device) {
    echo $device->name; // Device name
    echo $device->deviceId; // Device ID
}

// Turn a device on/off
$device->setPowerState(true); // Turn on
$device->setPowerState(false); // Turn off

// Set brightness (1-100)
$device->setBrightness(50);

// Set color using RGB
$device->setColor(255, 0, 0); // Red

// Set color using Hex
$device->setHexColor('#00FF00'); // Green

// Set white color temperature (2000-9000K)
$device->setWhiteTemperature(4000);

// If you know the device ID and model
$specificDevice = Govee::getDevice('your-device-id', 'your-device-model');

try {
    $device->setBrightness(150); // Will throw an exception
} catch (\Exception $e) {
    // Handle error
    echo $e->getMessage();
}
bash
php artisan vendor:publish --tag="config"