Skip to main content

Implementation of the govee API to control LED strips and bulbs.

Project description

govee-api-laggat Package

Python implementation of the govee API 1.0 to control the cheap and colorful LED strips.

Why / Motivation

I want to use this package in an Home Assistant Component to control my new light strips.

demo of integration

Remember: this is NOT the integration, but the library the integration uses.

The integration project lives here: github.com/LaggAt/home-assistant-core

Usage in your project

### using as async content manager
async with Govee(api_key, learning_storage = your_learning_storage) as govee:
    # i will explain that learning_storage below.

    # /ping endpoint in Govee API (uses no api_key)
    ping_ms, err = await govee.ping()
    # get devices list
    devices, err = await govee.get_devices()
    # get states (you must get the devices first)
    devices, err = get_states(self)  # yes, states returns the same object containing device and state info
    # once you have called get_devices() once, you can get this list from cache:
    cache_devices = govee.devices
    # or a specific device from cache
    cache_devices = govee.device(devices[0].device)  # .device returns device-ID
    # turn a device on/off (using device-object or device-id works for all calls)
    success, err = await govee.turn_on(devices[0])
    success, err = await govee.turn_off(devices[0].device)
    # set brightness of a device (we scale all ranges to 0-254, Govee uses 0-100 sometimes)
    success, err = await govee.set_brightness(devices[0], 254)
    # set color temperature (2000-9000)
    success, err = await govee.set_color_temp(devices[0], 6000)
    # set color in RGB (each 0-255)
    red = 0
    green = 0
    blue = 255
    success, err = await govee.set_color_temp(devices[0], (red, green, blue))

    ### rate limiting:
    # set requests left before the rate limiter stops us
    govee.rate_limit_on = 5  # 5 requests is the default
    current_rate_limit_on = govee.rate_limit_on
    # see also these properties:
    total = govee.rate_limit_total
    remaining = govee.rate_limit_remaining
    reset = govee.rate_limit_reset  # ... or more readable:
    reset_seconds = govee.rate_limit_reset_seconds


### without async content manager:
govee = await Govee.create(api_key, learning_storage = YourStorage)
ping_ms, err = await govee.ping()  # all commands as above
print(f"second Ping success? {bool(ping_ms)} after {ping_ms}ms")
await govee.close()

### so what is that: learning_storage = YourStorage
# as we control led strips and get state values from them we also learn how a specific led strip behaves.
# e.g. if the brightness is set in a range from 0-254 or 0-100, as some models use this or the other range.
# no configuration is needed from your user, but you as developer should consider saving/restoring those values.
# if you don't do this, learning will start with no information on every restart. Do not do this in production.

# to make this easy you can just implement GoveeAbstractLearningStorage and override two methods:
class YourLearningStorage(GoveeAbstractLearningStorage):
    async def read(self) -> Dict[str, GoveeLearnedInfo]:
        return {}  # get the last saved learning information from disk, database, ... and return it.
    async def write(self, learned_info: Dict[str, GoveeLearnedInfo]):
        persist_this_somewhere = learned_info  # save this dictionary to disk
# then
your_learning_storage = YourLearnignStorage()
# and your are good to go
async with Govee(api_key, learning_storage = your_learning_storage) as govee:
    pass

Govee trademark

Govee logo

Govee and the Govee logo are trademarks or registered trademarks of Shenzhen Intellirock Company Limited, and used by Govee with permission. Neither your use of the Govee Logo grant you any right, title, or interest in, or any license to reproduce or otherwise use, the Govee logo. You shall not at any time, nor shall you assist others to, challenge Govee's right, title, or interest in, or the validity of, the Govee Marks.

Links

API Key

To get an api key you need to install the 'Govee Home' app on your mobile and browse the user tab - About - Request API key. Usually you get your key within seconds by mail.

Issues / Improvements

There are two projects, this one is the API implementation for python. The second project is the integration into Home Assistant which currently lives here: github.com/LaggAt/home-assistant-core

Feel free to fork and start a pull request in your feature/bug branch. If you cannot fix or extend it yourself, you may want to add an issue in the correct project, but it may take a bit longer.

development

  • pip install setuptools wheel tox
  • Fork and clone the repository
  • Make a 'feature/NAME' or 'bug/NAME' branch
  • Run tests: tox
  • commit and start a pull request

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

govee_api_laggat-0.1.19.tar.gz (16.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

govee_api_laggat-0.1.19-py3.8.egg (35.1 kB view details)

Uploaded Egg

govee_api_laggat-0.1.19-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file govee_api_laggat-0.1.19.tar.gz.

File metadata

  • Download URL: govee_api_laggat-0.1.19.tar.gz
  • Upload date:
  • Size: 16.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for govee_api_laggat-0.1.19.tar.gz
Algorithm Hash digest
SHA256 9d4583b87758d4658b3272e7b05580f07b23653e73626049deb2d426da960a44
MD5 d95d165aadd6efb6804b951817f10d46
BLAKE2b-256 78a8fef0fa72d02885358c042f8c16d33ac3fb10859be7cf9a413c15f9aa3a67

See more details on using hashes here.

File details

Details for the file govee_api_laggat-0.1.19-py3.8.egg.

File metadata

  • Download URL: govee_api_laggat-0.1.19-py3.8.egg
  • Upload date:
  • Size: 35.1 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for govee_api_laggat-0.1.19-py3.8.egg
Algorithm Hash digest
SHA256 89dc2d7d82487a9d89f3ce71af35e4f3871d69afbb338f4da19bcf43b01a08ac
MD5 33fc8e15a8ccf985b19a75adbb5e9ba3
BLAKE2b-256 ffc2e8e724c5ddad1cb96d9277023f738d5c66a1bf99e6c8b602e055dce0b3b9

See more details on using hashes here.

File details

Details for the file govee_api_laggat-0.1.19-py3-none-any.whl.

File metadata

  • Download URL: govee_api_laggat-0.1.19-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.5

File hashes

Hashes for govee_api_laggat-0.1.19-py3-none-any.whl
Algorithm Hash digest
SHA256 e51d5a27203d0b694e69233c4d22c4cb593bfb00ca9c52bf40768e883a7568b4
MD5 914d79832d71eadc3d205e729af50834
BLAKE2b-256 44c0333c717eebb52d7f47834323fa4493dfbeb9dad62587c06d50ed73e8314d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page