Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created May 11, 2019 13:04
Show Gist options
  • Save colinfwren/ce4b6187666cc1fec611ab0f0f47aa89 to your computer and use it in GitHub Desktop.
Save colinfwren/ce4b6187666cc1fec611ab0f0f47aa89 to your computer and use it in GitHub Desktop.
import pyhue
HUE_IP = 'XXX.XXX.XXX.XXX'
HUE_USERNAME = 'replace_with_username'
HUE_ROOMS = ['Office']
# Get the pyhue.Bridge instance
bridge = pyhue.Bridge(HUE_IP, HUE_USERNAME)
# Find the room in the list of rooms set up by the user
rooms = [room for room in bridge.groups if room.name in HUE_ROOMS]
# Iterate over rooms
for room in rooms:
# Iterate over lights in room
for light_id in room.lights:
# Use the light_id to find the light
light = bridge.get_light(light_id)
# Turn it off
light.on = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment