{"id":20147895,"url":"https://github.com/dutchie027/govee-api","last_synced_at":"2025-04-09T19:50:52.466Z","repository":{"id":42128390,"uuid":"320125584","full_name":"dutchie027/govee-api","owner":"dutchie027","description":"This library is meant to interact with the Govee API using PHP. It was built to run and help assist with home automation.","archived":false,"fork":false,"pushed_at":"2023-04-10T02:57:09.000Z","size":163,"stargazers_count":12,"open_issues_count":5,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-23T21:45:53.406Z","etag":null,"topics":["api","govee","lights","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dutchie027.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-10T01:30:32.000Z","updated_at":"2024-12-04T05:45:05.000Z","dependencies_parsed_at":"2024-11-14T00:16:50.830Z","dependency_job_id":null,"html_url":"https://github.com/dutchie027/govee-api","commit_stats":{"total_commits":58,"total_committers":3,"mean_commits":"19.333333333333332","dds":0.5,"last_synced_commit":"18676d259e3d95c3d9f91d4cd68b2ac52ebbd90a"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutchie027%2Fgovee-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutchie027%2Fgovee-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutchie027%2Fgovee-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dutchie027%2Fgovee-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dutchie027","download_url":"https://codeload.github.com/dutchie027/govee-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103921,"owners_count":21048244,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","govee","lights","php"],"created_at":"2024-11-13T22:32:44.484Z","updated_at":"2025-04-09T19:50:52.443Z","avatar_url":"https://github.com/dutchie027.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Govee PHP API\n\n[![Latest Stable Version](https://poser.pugx.org/dutchie027/govee/v)](//packagist.org/packages/dutchie027/govee)\n[![Total Downloads](https://poser.pugx.org/dutchie027/govee/downloads)](//packagist.org/packages/dutchie027/govee)\n[![License](https://poser.pugx.org/dutchie027/govee/license)](//packagist.org/packages/dutchie027/govee)\n[![CodeFactor](https://www.codefactor.io/repository/github/dutchie027/govee-api/badge)](https://www.codefactor.io/repository/github/dutchie027/govee-api)\n\nA simple PHP package that allows you to control [Govee Smart Lights](https://www.govee.com/) using their [API](https://govee-public.s3.amazonaws.com/developer-docs/GoveeAPIReference.pdf).\n\n## Requirements\n\n* PHP \u003e7.2\n\n## Installation\n\nYou can install the package using the [Composer](https://getcomposer.org/) package manager. You can install it by running this command in your project root:\n\n```sh\ncomposer require dutchie027/govee\n```\n\n## Basic Usage\n\n### Instantiate the client\n\nTo use any of the Govee API functions, you first need a connection reference. The connection refrence can then be fed to either the Lights library or the Plugs library, or even both if you have both Govee Lights and Plugs.\n\n```php\n// Ensure we have the composer libraries\nrequire_once ('vendor/autoload.php');\n\n// Instantiate with defaults\n$govee = new dutchie027\\govee\\Connect(\"GOVEE-API-KEY\");\n\n// Instantiate without defaults, this allows you to change things\n// like log location, directory, the tag and possible future settings.\n$settings = [\n  'log_dir' =\u003e '/tmp',\n  'log_name' =\u003e 'govee-api',\n  'log_tag' =\u003e 'mylights',\n  'log_level' =\u003e 'error'\n];\n\n$govee = new dutchie027\\govee\\Connect(\"GOVEE-API-KEY\", $settings);\n```\n\n#### Settings\n\nThe default settings are fine, however you might want to override the defaults or use your own.**NOTE: All settings are optional and you don't need to provide any**.\n\nField | Type | Description | Default Value\n----- | ---- | ----------- | -------------\n`log_dir` | string | The directory where the log file is stored | [sys_get_temp_dir()](https://www.php.net/manual/en/function.sys-get-temp-dir.php)\n`log_name` | string | The name of the log file that is created in `log_dir`. If you don't put .log at the end, it will append it | 6 random characters + [time()](https://www.php.net/manual/en/function.time.php) + .log\n`log_tag` | string | If you share this log file with other applications, this is the tag used in the log file | govee\n`log_level` | string | The level of logging the application will do. This must be either `debug`, `info`, `notice`, `warning`, `critical` or `error`. If it is not one of those values it will fail to the default | `warning`\n\n## Connect (Core) Functions\n\n### Get Device Count\n\n```php\nprint $govee-\u003egetDeviceCount();\n```\n\n### Get An Array of All Devices\n\n```php\n$array = $govee-\u003egetDeviceList();\n```\n\n#### Example Return Array\n\n```json\nArray\n(\n    [0] =\u003e Array\n        (\n            [device] =\u003e 46:F1:CC:F6:FC:65:FF:AA\n            [model] =\u003e H6159\n            [deviceName] =\u003e Office-Color\n            [controllable] =\u003e 1\n            [retrievable] =\u003e 1\n            [supportCmds] =\u003e Array\n                (\n                    [0] =\u003e turn\n                    [1] =\u003e brightness\n                    [2] =\u003e color\n                    [3] =\u003e colorTem\n                )\n\n        )\n\n)\n```\n\n### Get An Array of All Callable MAC Addresses\n\n```php\n$macArray = $govee-\u003egetDeviceMACArray();\n```\n\n#### MAC Return Array\n\n```php\nArray\n(\n    [0] =\u003e A9:E9:0A:04:AD:CD:12:34\n    [1] =\u003e FA:8F:50:B2:AD:A7:00:12\n    [2] =\u003e E0:94:41:AC:62:13:56:78\n)\n```\n\n### Get An Array of All Device Names\n\n```php\n$nameArray = $govee-\u003egetDeviceNameArray();\n```\n\n#### Device Name Return Array\n\n```php\nArray\n(\n    [0] =\u003e My-Living-Room\n    [1] =\u003e Hallway\n    [2] =\u003e Fire-House\n)\n```\n\n### Get the location of the log file\n\n```php\nprint $govee-\u003egetLogLocation();\n```\n\n#### Example Return String\n\n```txt\n/tmp/2Zo46b.1607566740.log\n```\n\n## Lights Functions\n\n### Controlling Lights\n\nTo control lights, you first need to make a connection and then reference the connection\n\n```php\n// Ensure we have the composer libraries\nrequire_once ('vendor/autoload.php');\n\n// Instantiate with defaults\n$govee = new dutchie027\\govee\\Connect(\"GOVEE-API-KEY\");\n\n```\n\nOnce you've got a reference to the lights, it will preload all of the MAC Address(es) and name(s) of the devices.\n\n#### Turning A Light ON\n\nTo turn a light on, simply feed it the MAC address or the name of the light.\n\n```php\n$govee-\u003elights()-\u003eturnOn(\"AC:14:A3:D5:E6:C4:3D:AE\");\n\nor\n\n$govee-\u003elights()-\u003eturnOn(\"Office-Wall\");\n```\n\n#### Turning A Light OFF\n\nLike turning a light on, to turn a light off, simply feed the MAC address or the name of the light.\n\n```php\n$govee-\u003elights()-\u003eturnOff(\"AC:14:A3:D5:E6:C4:3D:AE\");\n\nor\n\n$govee-\u003elights()-\u003eturnOff(\"Office-Wall\");\n```\n\n#### Adjusting BRIGHTNESS of A Light\n\nTo adjust the brigthness, simply give the name or MAC and the brightness, an INT between 0 and 100.\n\n```php\n$govee-\u003elights()-\u003esetBrightness(\"AC:14:A3:D5:E6:C4:3D:AE\", 75);\n\nor\n\n$govee-\u003elights()-\u003esetBrightness(\"Office-Wall\", 75);\n```\n\n#### Changing the COLOR of A Light\n\nTo adjust the color, simply give the name or MAC and the brightness and then feed the R, G, B colors you'd like the device to set itself to. *NOTE* the values for Red, Green and Blue must be between 0 and 255.\n\n```php\n$govee-\u003elights()-\u003esetColor(\"AC:14:A3:D5:E6:C4:3D:AE\", 255, 255, 0);\n\nor\n\n$govee-\u003elights()-\u003esetBrightness(\"Office-Wall\", 255, 0, 0);\n```\n\n#### Changing the TEMPERATURE of A Light\n\nTo adjust the temperature, simply give the name or MAC and the name and then feed the temperature. *NOTE* Temperature must be an INT between 2000 and 9000.\n\n```php\n$govee-\u003elights()-\u003esetTemp(\"AC:14:A3:D5:E6:C4:3D:AE\", 5000);\n\nor\n\n$govee-\u003elights()-\u003esetTemp(\"Office-Wall\", 5000);\n```\n\n#### Get the STATE of A Light\n\nTo get all of the details about a light, simply feed getDeviceState the name or the MAC address. You'll get a JSON return you can then either read or feed to `json_decode` and turn in to an array to use/read.\n\n```php\n$govee-\u003elights()-\u003egetDeviceState(\"AC:14:A3:D5:E6:C4:3D:AE\");\n\nor\n\n$govee-\u003elights()-\u003egetDeviceState(\"Office-Wall\");\n```\n\n```json\n{\n  \"data\": {\n    \"device\": \"AC:14:A3:D5:E6:C4:3D:AE\",\n    \"model\": \"Office-Wall\",\n    \"properties\": [\n      {\n        \"online\": true\n      },\n      {\n        \"powerState\": \"on\"\n      },\n      {\n        \"brightness\": 100\n      },\n      {\n        \"color\": {\n          \"r\": 255,\n          \"b\": 0,\n          \"g\": 255\n        }\n      }\n    ]\n  }\n}\n```\n\n## Plugs Functions\n\n### Turn On A Plug\n\n```php\n$govee-\u003eplugs()-\u003eturnOn(\"AC:14:A3:D5:E6:C4:3D:AE\");\n\nor\n\n$govee-\u003eplugs()-\u003eturnOn(\"Office-Wall\");\n```\n\n### Turn Off A Plug\n\n```php\n$govee-\u003eplugs()-\u003eturnOff(\"AC:14:A3:D5:E6:C4:3D:AE\");\n\nor\n\n$govee-\u003eplugs()-\u003eturnOff(\"Office-Wall\");\n```\n\n## Contributing\n\nIf you're having problems, spot a bug, or have a feature suggestion, [file an issue](https://github.com/dutchie027/govee-api/issues). If you want, feel free to fork the package and make a pull request. This is a work in progresss as I get more info and the Govee API grows.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdutchie027%2Fgovee-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdutchie027%2Fgovee-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdutchie027%2Fgovee-api/lists"}