# huesdk
Python package to control the Philips Hue lights.
Make the usage of the Philips Hue API 1.0 easier with an object-oriented structure.
## Installation
```
pip install huesdk
```
## Discovery
To find the IP of your hue bridge, go to https://discovery.meethue.com. Or alternatively,
```python
from huesdk import Discover
discover = Discover()
print(discover.find_hue_bridge())
```
Since https://discovery.meethue.com and ```discover.find_hue_bridge()``` are rate limited
and require an internet connection, you can also search for bridges locally using mDNS:
```python
from huesdk import Discover
discover = Discover()
print(discover.find_hue_bridge_mdns(timeout=5))
```
## Connexion
```python
from huesdk import Hue
# For the first usage
# Press your bridge button
# the connect method will return a username
username = Hue.connect(bridge_ip=YOUR_BRIDGE_IP)
# You can now create an instance of the Hue class,
# next you won't need to press the button
hue = Hue(bridge_ip=YOUR_BRIDGE_IP, username=YOUR_USERNAME)
# Turn on all the lights
hue.on()
# Turn off all the lights
hue.off()
```
## Lights
### Get all light objects
```python
lights = hue.get_lights()
# Print light properties
for light in lights:
print(light.id_)
print(light.name)
print(light.is_on)
print(light.bri)
print(light.hue)
print(light.sat)
# turn on each lights
for light in lights:
light.on()
```
### Get single light
```python
# get light with id
light = hue.get_light(id_=1)
# get light with name
light = hue.get_light(name="Room 1")
```
### Lights methods
```python
lights = hue.get_lights()
# turn on
lights[0].on()
# turn off
lights[0].off()
# Change color
# with hue, red=65535, green=21845 and blue=43690
lights[0].set_color(hue=43690)
# with hexadecimal
lights[0].set_color(hexa="#065535")
# Change brightness, from 1 to 254
lights[0].set_brightness(254)
# Change light's name
lights[0].set_name("Hue color lamp 2")
# Change saturation, from 1 to 254
lights[0].set_saturation(254)
```
### Transitions
For each change, you can set a transition time.
This is given as a multiple of 100ms.
So `transition=10` will make the transition last 1 second.
The default value is 4 (400ms).
```python
light = hue.get_light(name="kitchen")
# the light will slowly turn off in 5secs
light.off(transition=50)
# the light will be red after 10 seconds
light.set_color(hexa="#ff0000", transition=100)
```
## Groups
The same methods are available for groups
### Get all group objects
```python
groups = hue.get_groups()
# Print light properties
for group in groups:
print(group.id_)
print(group.name)
# turn on each groups
for group in groups:
groups.on()
```
### Get single group
```python
# get group with id
group = hue.get_group(id_=1)
# get group with name
group = hue.get_group(name="kitchen")
```
### Groups methods
```python
groups = hue.get_groups()
# turn on
groups[0].on()
# turn off
groups[0].off()
# Change brightness, from 1 to 254
groups[0].set_brightness(value)
# Change group's name
groups[0].set_name("Hue color lamp 2")
# Change saturation, from 1 to 254
groups[0].set_saturation(value)
```
### Transitions
Transitions are also available for groups.
```python
group = hue.get_group(name="kitchen")
group.off(transition=1000)
```
## Schedules
### Get all schedules objects
```python
schedules = hue.get_schedules()
# Print schedules properties
for schedule in schedules:
print(schedule.id_)
print(schedule.name)
print(schedule.description)
print(schedule.status)
print(schedule.command)
```
### Schedules methods
```python
schedules = hue.get_schedules()
# Change name
schedules[0].set_name("Schedules 0")
# Change description
schedules[0].set_description("Schedules 0")
# Delete
schedules[0].delete()
```
Raw data
{
"_id": null,
"home_page": "https://github.com/AlexisGomes/huesdk",
"name": "huesdk",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Gomes Alexis",
"author_email": "alexis.gomes19@gmail.com",
"download_url": "",
"platform": null,
"description": "# huesdk\n\nPython package to control the Philips Hue lights.\n\nMake the usage of the Philips Hue API 1.0 easier with an object-oriented structure.\n\n## Installation\n\n```\npip install huesdk\n```\n\n## Discovery\n\nTo find the IP of your hue bridge, go to https://discovery.meethue.com. Or alternatively,\n\n```python\nfrom huesdk import Discover\ndiscover = Discover()\nprint(discover.find_hue_bridge())\n```\n\nSince https://discovery.meethue.com and ```discover.find_hue_bridge()``` are rate limited\nand require an internet connection, you can also search for bridges locally using mDNS:\n\n```python\nfrom huesdk import Discover\ndiscover = Discover()\nprint(discover.find_hue_bridge_mdns(timeout=5))\n```\n\n\n## Connexion\n\n```python\nfrom huesdk import Hue\n# For the first usage \n# Press your bridge button\n# the connect method will return a username\nusername = Hue.connect(bridge_ip=YOUR_BRIDGE_IP)\n\n# You can now create an instance of the Hue class, \n# next you won't need to press the button\nhue = Hue(bridge_ip=YOUR_BRIDGE_IP, username=YOUR_USERNAME)\n\n# Turn on all the lights\nhue.on()\n\n# Turn off all the lights\nhue.off()\n```\n\n## Lights\n\n### Get all light objects\n```python\nlights = hue.get_lights()\n\n# Print light properties\nfor light in lights:\n print(light.id_)\n print(light.name)\n print(light.is_on)\n print(light.bri)\n print(light.hue)\n print(light.sat)\n\n# turn on each lights\nfor light in lights:\n light.on()\n```\n\n### Get single light\n```python\n# get light with id\nlight = hue.get_light(id_=1)\n\n# get light with name\nlight = hue.get_light(name=\"Room 1\")\n```\n\n### Lights methods\n```python\nlights = hue.get_lights()\n\n# turn on\nlights[0].on()\n\n# turn off\nlights[0].off()\n\n# Change color \n# with hue, red=65535, green=21845 and blue=43690\nlights[0].set_color(hue=43690)\n\n# with hexadecimal\nlights[0].set_color(hexa=\"#065535\")\n\n# Change brightness, from 1 to 254\nlights[0].set_brightness(254)\n\n# Change light's name\nlights[0].set_name(\"Hue color lamp 2\")\n\n# Change saturation, from 1 to 254\nlights[0].set_saturation(254)\n```\n### Transitions\nFor each change, you can set a transition time.\nThis is given as a multiple of 100ms. \nSo `transition=10` will make the transition last 1 second.\nThe default value is 4 (400ms).\n\n```python\nlight = hue.get_light(name=\"kitchen\")\n\n# the light will slowly turn off in 5secs\nlight.off(transition=50)\n\n# the light will be red after 10 seconds\nlight.set_color(hexa=\"#ff0000\", transition=100)\n```\n\n## Groups\nThe same methods are available for groups\n\n### Get all group objects\n```python\ngroups = hue.get_groups()\n\n# Print light properties\nfor group in groups:\n print(group.id_)\n print(group.name)\n\n# turn on each groups\nfor group in groups:\n groups.on()\n```\n\n### Get single group\n```python\n# get group with id\ngroup = hue.get_group(id_=1)\n\n# get group with name\ngroup = hue.get_group(name=\"kitchen\")\n```\n\n### Groups methods\n```python\ngroups = hue.get_groups()\n\n# turn on\ngroups[0].on()\n\n# turn off\ngroups[0].off()\n\n# Change brightness, from 1 to 254\ngroups[0].set_brightness(value)\n\n# Change group's name\ngroups[0].set_name(\"Hue color lamp 2\")\n\n# Change saturation, from 1 to 254\ngroups[0].set_saturation(value)\n```\n\n### Transitions\nTransitions are also available for groups.\n```python\ngroup = hue.get_group(name=\"kitchen\")\ngroup.off(transition=1000)\n```\n\n## Schedules\n\n### Get all schedules objects\n```python\nschedules = hue.get_schedules()\n\n# Print schedules properties\nfor schedule in schedules:\n print(schedule.id_)\n print(schedule.name)\n print(schedule.description)\n print(schedule.status)\n print(schedule.command)\n```\n\n### Schedules methods\n```python\nschedules = hue.get_schedules()\n\n# Change name\nschedules[0].set_name(\"Schedules 0\")\n# Change description\nschedules[0].set_description(\"Schedules 0\")\n\n# Delete\nschedules[0].delete()\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "A python SDK for the Philips hue API",
"version": "1.6",
"project_urls": {
"Homepage": "https://github.com/AlexisGomes/huesdk"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "451df5a84ecbacbc28e44e18f6c695d74ad5f06ba03fec0e1d1f5e6bd7075396",
"md5": "e720829113084d99ecb599e91a751183",
"sha256": "ac6eacd96751a487f2374fb8b5fa354602f594a970877fc2498fbe807ccf602d"
},
"downloads": -1,
"filename": "huesdk-1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e720829113084d99ecb599e91a751183",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7656,
"upload_time": "2023-10-12T08:47:12",
"upload_time_iso_8601": "2023-10-12T08:47:12.204124Z",
"url": "https://files.pythonhosted.org/packages/45/1d/f5a84ecbacbc28e44e18f6c695d74ad5f06ba03fec0e1d1f5e6bd7075396/huesdk-1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-12 08:47:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AlexisGomes",
"github_project": "huesdk",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "huesdk"
}