PHP code example of dutchie027 / govee

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

    

dutchie027 / govee example snippets


// Ensure we have the composer libraries
ew dutchie027\govee\Connect("GOVEE-API-KEY");

// Instantiate without defaults, this allows you to change things
// like log location, directory, the tag and possible future settings.
$settings = [
  'log_dir' => '/tmp',
  'log_name' => 'govee-api',
  'log_tag' => 'mylights',
  'log_level' => 'error'
];

$govee = new dutchie027\govee\Connect("GOVEE-API-KEY", $settings);

print $govee->getDeviceCount();

$array = $govee->getDeviceList();

$macArray = $govee->getDeviceMACArray();

Array
(
    [0] => A9:E9:0A:04:AD:CD:12:34
    [1] => FA:8F:50:B2:AD:A7:00:12
    [2] => E0:94:41:AC:62:13:56:78
)

$nameArray = $govee->getDeviceNameArray();

Array
(
    [0] => My-Living-Room
    [1] => Hallway
    [2] => Fire-House
)

print $govee->getLogLocation();

// Ensure we have the composer libraries
ew dutchie027\govee\Connect("GOVEE-API-KEY");


$govee->lights()->turnOn("AC:14:A3:D5:E6:C4:3D:AE");

or

$govee->lights()->turnOn("Office-Wall");

$govee->lights()->turnOff("AC:14:A3:D5:E6:C4:3D:AE");

or

$govee->lights()->turnOff("Office-Wall");

$govee->lights()->setBrightness("AC:14:A3:D5:E6:C4:3D:AE", 75);

or

$govee->lights()->setBrightness("Office-Wall", 75);

$govee->lights()->setColor("AC:14:A3:D5:E6:C4:3D:AE", 255, 255, 0);

or

$govee->lights()->setBrightness("Office-Wall", 255, 0, 0);

$govee->lights()->setTemp("AC:14:A3:D5:E6:C4:3D:AE", 5000);

or

$govee->lights()->setTemp("Office-Wall", 5000);

$govee->lights()->getDeviceState("AC:14:A3:D5:E6:C4:3D:AE");

or

$govee->lights()->getDeviceState("Office-Wall");

$govee->plugs()->turnOn("AC:14:A3:D5:E6:C4:3D:AE");

or

$govee->plugs()->turnOn("Office-Wall");

$govee->plugs()->turnOff("AC:14:A3:D5:E6:C4:3D:AE");

or

$govee->plugs()->turnOff("Office-Wall");