/ README.rst
README.rst
1 Introduction 2 ============ 3 4 .. image:: https://readthedocs.org/projects/adafruit-circuitpython-hue/badge/?version=latest 5 :target: https://circuitpython.readthedocs.io/projects/hue/en/latest/ 6 :alt: Documentation Status 7 8 .. image:: https://img.shields.io/discord/327254708534116352.svg 9 :target: https://adafru.it/discord 10 :alt: Discord 11 12 .. image:: https://github.com/adafruit/Adafruit_CircuitPython_Hue/workflows/Build%CI/badge.svg 13 :target: https://github.com/adafruit/Adafruit_CircuitPython_Hue/actions/ 14 :alt: Build Status 15 16 CircuitPython helper library for Philips Hue Lights. 17 18 Dependencies 19 ============= 20 This driver depends on: 21 22 * `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_ 23 * `Adafruit CircuitPython SimpleIO <https://github.com/adafruit/Adafruit_CircuitPython_SimpleIO>`_ 24 * `Adafruit CircuitPython ESP32SPI <https://github.com/adafruit/Adafruit_CircuitPython_ESP32SPI>`_ 25 26 Please ensure all dependencies are available on the CircuitPython filesystem. 27 This is easily achieved by downloading 28 `the Adafruit library and driver bundle <https://github.com/adafruit/Adafruit_CircuitPython_Bundle>`_. 29 30 Installing from PyPI 31 -------------------- 32 On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from 33 PyPI <https://pypi.org/project/adafruit-circuitpython-hue/>`_. To install for current user: 34 35 .. code-block:: shell 36 37 pip3 install adafruit-circuitpython-hue 38 39 To install system-wide (this may be required in some cases): 40 41 .. code-block:: shell 42 43 sudo pip3 install adafruit-circuitpython-hue 44 45 To install in a virtual environment in your current project: 46 47 .. code-block:: shell 48 49 mkdir project-name && cd project-name 50 python3 -m venv .env 51 source .env/bin/activate 52 pip3 install adafruit-circuitpython-hue 53 54 Usage Example 55 ============= 56 57 Load bridge username and IP Address from secrets.py file: 58 59 .. code-block:: python 60 61 username = secrets['hue_username'] 62 bridge_ip = secrets['bridge_ip'] 63 my_bridge = Bridge(wifi, bridge_ip, username) 64 65 Enumerate all lights on the bridge 66 67 .. code-block:: python 68 69 lights = my_bridge.get_lights() 70 71 Turn on a light 72 73 .. code-block:: python 74 75 my_bridge.set_light(1, on=True) 76 77 Turn off a light 78 79 .. code-block:: python 80 81 my_bridge.set_light(1, on=False) 82 83 Set a light to the color yellow (RGB) 84 85 .. code-block:: python 86 87 color = my_bridge.rgb_to_hsb([255, 255, 0]) 88 my_bridge.set_light(1, hue=int(color[0]), sat=int(color[1]), bri=int(color[2])) 89 90 Set a group of lights to a predefined scene 91 92 .. code-block:: python 93 94 my_bridge.set_group(1, scene='AB34EF5') 95 96 Set a group of lights to a predefined color 97 98 .. code-block:: python 99 100 my_bridge.set_group(1, color) 101 102 Contributing 103 ============ 104 105 Contributions are welcome! Please read our `Code of Conduct 106 <https://github.com/adafruit/Adafruit_CircuitPython_Hue/blob/master/CODE_OF_CONDUCT.md>`_ 107 before contributing to help this project stay welcoming. 108 109 Documentation 110 ============= 111 112 For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.