### Install `yeelight` Python Library Source: https://github.com/skorokithakis/python-yeelight/blob/master/README.rst Instructions for installing the `yeelight` library using various methods. Pip is the preferred installation method for this package. ```Shell pip install yeelight ``` ```Shell easy_install yeelight ``` ```Shell python setup.py install ``` -------------------------------- ### Install `yeelight` Python Library Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/index.rst This snippet shows how to install the `yeelight` Python library using pip, the Python package installer. This is the first step required to set up the library for use. ```bash pip install yeelight ``` -------------------------------- ### Install Development Dependencies for `yeelight` Source: https://github.com/skorokithakis/python-yeelight/blob/master/README.rst Command to install all required development libraries from `requirements_dev.txt`. It is recommended to run this command within a virtual environment to manage dependencies effectively for contributing to the `yeelight` project. ```Shell pip install -Ur requirements_dev.txt ``` -------------------------------- ### Use Preset Transitions for Flow in Python Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/flow.rst This example illustrates how to utilize pre-defined transition presets from the `yeelight.transitions` module. It shows how to call a preset function, like `disco()`, to easily populate a Flow object with a sequence of transitions. ```python from yeelight.transitions import * from yeelight import Flow flow = Flow( count=10, transitions=disco(), # Call the transition preset to get the # transitions you like. ) bulb.start_flow(flow) ``` -------------------------------- ### Create a Quick Pulse Notification Flow in Python Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/flow.rst This example demonstrates how to create a rapid, pulsing light effect, suitable for notifications. It uses HSV transitions to cycle through hues, creating a dynamic pulse that repeats twice. ```python from yeelight import * transitions = [HSVTransition(hue, 100, duration=500) for hue in range(0, 359, 40)] flow = Flow( count=2, transitions=transitions ) bulb.start_flow(flow) ``` -------------------------------- ### Install Git Pre-Commit Hook for `yeelight` Source: https://github.com/skorokithakis/python-yeelight/blob/master/README.rst Command to install the `pre-commit` hook. This hook automatically runs various code quality checks before each commit, ensuring that contributions adhere to project standards and pass continuous integration (CI). ```Shell pre-commit install ``` -------------------------------- ### Create an Infinite Color Cycle Flow in Python Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/flow.rst This example shows how to set up a Flow that continuously cycles through a specific RGB color. The 'count' parameter is set to 0 to enable infinite looping. It also includes the code to stop the flow using `bulb.stop_flow()`. ```python from yeelight import * transitions = [ RGBTransition(255, 0, 255, duration=1000) ] flow = Flow( count=0, # Cycle forever. transitions=transitions ) bulb.start_flow(flow) ``` ```python bulb.stop_flow() ``` -------------------------------- ### Create a Simple Temperature Cycle Flow in Python Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/flow.rst This example demonstrates how to create a Flow object to cycle the bulb's color temperature between 1700K and 6500K twice, with a one-second delay between transitions. The flow is configured to recover the bulb's original state upon completion. ```python from yeelight import * transitions = [ TemperatureTransition(1700, duration=1000), SleepTransition(duration=1000), TemperatureTransition(6500, duration=1000) ] flow = Flow( count=2, action=Flow.actions.recover, transitions=transitions ) bulb.start_flow(flow) ``` -------------------------------- ### Instantiate and Control a YeeLight Bulb Source: https://github.com/skorokithakis/python-yeelight/blob/master/README.rst Demonstrates how to create a `Bulb` object by providing its IP address and then how to turn the bulb on. Ensure 'development mode' is enabled on your YeeLight bulb via its official app for this to work. ```Python bulb = Bulb("192.168.0.5") bulb.turn_on() ``` -------------------------------- ### Control YeeLight Bulb Instance Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/index.rst This snippet shows how to instantiate a `Bulb` object with a known IP address and perform various control actions. It covers basic power operations (on, off, toggle), setting brightness, RGB, HSV, and color temperature, and saving current settings as default. ```python >>> from yeelight import Bulb >>> bulb = Bulb("192.168.0.19") # Turn the bulb on. >>> bulb.turn_on() # Turn the bulb off. >>> bulb.turn_off() # Toggle power. >>> bulb.toggle() # Set brightness to 50%. >>> bulb.set_brightness(50) # Set RGB value. >>> bulb.set_rgb(255, 0, 0) # Set HSV value. >>> bulb.set_hsv(320, 100, 50) # Set hue and saturation, but keep value (brightness) the same. >>> bulb.set_hsv(320, 100) # Set color temperature. >>> bulb.set_color_temp(4700) # Save this setting as default. >>> bulb.set_default() ``` -------------------------------- ### API Documentation: yeelight.HSVTransition Class Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `HSVTransition` class within the `yeelight` module. This class defines a transition step based on Hue, Saturation, and Value color model for use in light flows. All public and undocumented members are included. ```APIDOC .. autoclass:: yeelight.HSVTransition :members: :undoc-members: ``` -------------------------------- ### API Documentation: yeelight.transitions Module Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `transitions` module within the `yeelight` package. This module likely contains predefined transition presets or utility functions for creating light flows. All public and undocumented members, along with inheritance information, are included. ```APIDOC .. automodule:: yeelight.transitions :members: :undoc-members: :show-inheritance: ``` -------------------------------- ### yeelight.Flow Class API Documentation Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/flow.rst Documentation for the `Flow` class, which defines a sequence of light transitions for Yeelight bulbs. It details the constructor parameters: `count` (number of loops), `action` (behavior at flow end), and `transitions` (list of `Transition` instances). ```APIDOC yeelight.Flow: __init__(count: int, action: Flow.actions, transitions: list) count: int Description: Number of loops to perform. 0 means loop forever. Note: In yeelight library, this means "number of loops", not "number of transitions". action: Flow.actions Description: What to do at the end of the flow. Possible values: Flow.actions.recover: Return to original state. Flow.actions.stay: Stay at the last state of the flow. Flow.actions.off: Turn off the bulb. transitions: list Description: A list of transition instances (e.g., TemperatureTransition, RGBTransition, HSVTransition, SleepTransition). Note: Bulbs are limited to around nine transitions. ``` -------------------------------- ### API Documentation: yeelight.TemperatureTransition Class Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `TemperatureTransition` class within the `yeelight` module. This class defines a transition step based on color temperature for use in light flows. All public and undocumented members are included. ```APIDOC .. autoclass:: yeelight.TemperatureTransition :members: :undoc-members: ``` -------------------------------- ### Import `Bulb` Class from `yeelight` Source: https://github.com/skorokithakis/python-yeelight/blob/master/README.rst Shows the initial step to import the `Bulb` class from the `yeelight` library, which is necessary to interact with YeeLight devices. ```Python from yeelight import Bulb ``` -------------------------------- ### API Documentation: yeelight.RGBTransition Class Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `RGBTransition` class within the `yeelight` module. This class defines a transition step based on Red, Green, and Blue color model for use in light flows. All public and undocumented members are included. ```APIDOC .. autoclass:: yeelight.RGBTransition :members: :undoc-members: ``` -------------------------------- ### API Documentation: yeelight.discover_bulbs Function Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `discover_bulbs` function within the `yeelight` module. This function is used to automatically discover Yeelight smart bulbs available on the local network. ```APIDOC .. autofunction:: yeelight.discover_bulbs ``` -------------------------------- ### Manually Run `pre-commit` Checks Source: https://github.com/skorokithakis/python-yeelight/blob/master/README.rst Command to manually execute all `pre-commit` checks on all files. This is useful for verifying changes before committing or if a commit was made without the hook running automatically. ```Shell pre-commit run -a ``` -------------------------------- ### API Documentation: yeelight.Flow Class Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `Flow` class within the `yeelight` module, which is used to define a sequence of light transitions for Yeelight bulbs. This allows for complex lighting effects. All public and undocumented members are included. ```APIDOC .. autoclass:: yeelight.Flow :members: :undoc-members: ``` -------------------------------- ### Discover YeeLight Bulbs on Network Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/index.rst This Python snippet demonstrates how to use the `discover_bulbs` function to find all YeeLight devices on the local network. It returns a list of dictionaries, each containing the IP address, port, and capabilities of a discovered bulb. ```python >>> from yeelight import discover_bulbs >>> discover_bulbs() [{'capabilities': {'bright': '50', 'color_mode': '1', 'ct': '2700', 'fw_ver': '45', 'hue': '359', 'id': '0x0000000002dfb19a', 'model': 'color', 'name': 'bedroom', 'power': 'off', 'rgb': '16711935', 'sat': '100', 'support': 'get_prop set_default set_power toggle ' 'set_bright start_cf stop_cf set_scene cron_add ' 'cron_get cron_del set_ct_abx set_rgb set_hsv ' 'set_adjust set_music set_name'}, 'ip': '192.168.0.19', 'port': 55443}, {'capabilities': {'bright': '50', 'color_mode': '1', 'ct': '2700', 'fw_ver': '45', 'hue': '359', 'id': '0x0000000002dfb2f1', 'model': 'color', 'name': 'livingroom', 'power': 'off', 'rgb': '16711935', 'sat': '100', 'support': 'get_prop set_default set_power toggle ' 'set_bright start_cf stop_cf set_scene cron_add ' 'cron_get cron_del set_ct_abx set_rgb set_hsv ' 'set_adjust set_music set_name'}, 'ip': '192.168.0.23', 'port': 55443}] ``` -------------------------------- ### API Documentation: yeelight.Bulb Class Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `Bulb` class within the `yeelight` module. This class represents a single Yeelight smart bulb and provides methods for controlling its state and properties. All public and undocumented members of the class are included. ```APIDOC .. autoclass:: yeelight.Bulb :members: :undoc-members: ``` -------------------------------- ### Configure and use automatic power-on for Yeelight bulb Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/index.rst Demonstrates how to enable `auto_on` for a Yeelight bulb, ensuring the bulb is powered on before executing commands. This can be set on an existing bulb object or during instantiation, allowing commands like `set_brightness` to work even if the bulb is initially off. ```Python bulb.auto_on = True ``` ```Python bulb = Bulb("192.168.0.19", auto_on=True) ``` ```Python bulb.set_brightness(10) ``` -------------------------------- ### API Documentation: yeelight.BulbException Class Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `BulbException` class within the `yeelight` module. This class serves as a base exception for errors encountered when interacting with Yeelight bulbs. All public and undocumented members are included. ```APIDOC .. autoclass:: yeelight.BulbException :members: :undoc-members: ``` -------------------------------- ### API Documentation: yeelight.enums Module Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `enums` module within the `yeelight` package. This module contains various enumeration definitions used throughout the Yeelight API, such as light states or properties. All public and undocumented members, along with inheritance information, are included. ```APIDOC .. automodule:: yeelight.enums :members: :undoc-members: :show-inheritance: ``` -------------------------------- ### API Documentation: yeelight.SleepTransition Class Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `SleepTransition` class within the `yeelight` module. This class defines a transition step that introduces a pause or sleep duration within a light flow. All public and undocumented members are included. ```APIDOC .. autoclass:: yeelight.SleepTransition :members: :undoc-members: ``` -------------------------------- ### Manage effects for Yeelight bulb state changes Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/index.rst Explains how to control the transition effects (e.g., 'smooth', 'sudden') and duration for Yeelight bulb commands. Effects can be set during instantiation, overridden for specific calls, or changed dynamically on the bulb object, influencing how the bulb changes from one state to another. ```Python bulb = Bulb("192.168.0.19", effect="smooth", duration=1000) ``` ```Python bulb.turn_on() ``` ```Python bulb.turn_on(effect="sudden") ``` ```Python bulb.effect = "sudden" ``` ```Python bulb.turn_on() ``` -------------------------------- ### Default Yeelight Bulb Properties Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/index.rst Illustrates the default properties returned by a Yeelight bulb, noting the absence of `flow_params` by default. These properties represent the current state of the bulb, such as power status, color, and name. ```Python { 'delayoff': '0', 'flowing': '0', 'hue': '300', 'music_on': '0', 'name': 'My light', 'power': 'off', 'rgb': '16737280', 'sat': '100' } ``` -------------------------------- ### Retrieve YeeLight Bulb Properties Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/index.rst This Python snippet demonstrates how to retrieve the current properties of a connected YeeLight bulb using the `get_properties()` method. It returns a dictionary containing various state attributes like brightness, color mode, and color temperature. ```python >>> bulb.get_properties() {'bright': u'10', 'color_mode': u'2', 'ct': u'2700', ``` -------------------------------- ### yeelight.Bulb.stop_flow Method API Documentation Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/flow.rst Documentation for the `stop_flow` method of the `Bulb` class, used to terminate an active flow on the Yeelight bulb. The bulb's behavior after stopping depends on the `action` parameter set in the original Flow. ```APIDOC yeelight.Bulb.stop_flow(): Description: Stops the currently active flow on the bulb. Behavior: The bulb returns to its previous state if Flow.actions.recover was set, stays at the last state if Flow.actions.stay was set, or turns off if Flow.actions.off was set. ``` -------------------------------- ### API Documentation: yeelight.BulbType Class Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/yeelight.rst Documents the `BulbType` class within the `yeelight` module. This class likely defines an enumeration or set of constants representing different types of Yeelight bulbs. All public and undocumented members are included. ```APIDOC .. autoclass:: yeelight.BulbType :members: :undoc-members: ``` -------------------------------- ### Handle Bulb Off State Error Source: https://github.com/skorokithakis/python-yeelight/blob/master/docs/source/index.rst This snippet illustrates that `yeelight` prevents commands from being executed when the bulb is off, raising an `AssertionError`. This behavior ensures commands only apply when the bulb is in an active state. ```python >>> bulb.set_brightness(10) AssertionError: Commands have no effect when the bulb is off. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.