chipneedham/laravel-govee 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

chipneedham/laravel-govee

最新稳定版本:v1.0.0

Composer 安装命令:

composer require chipneedham/laravel-govee

包简介

integrating Govee with Laravel

README 文档

README

A Laravel package for interacting with the Govee Smart Home API, allowing easy control and management of Govee smart devices. At the moment only lights are supported.

Installation

You can install the package via Composer:

composer require chipneedham/laravel-govee

Configuration

Publish the configuration file:

php artisan vendor:publish --tag="config"

This will create a config/govee.php file. Add your Govee API key to your .env file:

GOVEE_API_KEY=your_govee_api_key_here

Getting an API key

See Govee's Docs

Usage

Retrieving Devices

use Govee;

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

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

Device Control

// 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);

Directly Accessing a Device

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

Rate Limits

Govee's rate limits are annoyingly low. Sorry.

Endpoint Limit
DeviceList 10 per minute
DeviceControl 10 per minute per device
DeviceState 10 per minute per device
Total Requests 10000 per day

Error Handling

Error handling has a lot of work to be done, at the moment be sure to use trys. The package throws exceptions for invalid inputs or API errors:

try {
    $device->setBrightness(150); // Will throw an exception
} catch (\Exception $e) {
    // Handle error
    echo $e->getMessage();
}

Facade

The package includes a Govee facade for easy access to the Govee API client.

Requirements

  • PHP 8.1+
  • Laravel 10.x+
  • Govee API Key

Security

Please ensure your Govee API key is kept secure and not committed to version control.

Contributing

Contributions are welcome! Please submit pull requests or file issues on the GitHub repository.

Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-27