Up next

Autoplay

Writing a Python Script to Control my Lights | Five Minute Python Scripts

0 Views • 10/30/24
Share
Embed
121gamers
121gamers
14 Subscribers
14

Let's automate some lights with python?

Kite helps fund the channel, thanks for checking them out and supporting me --
⭐ Kite is a free AI-powered coding assistant that will help you code faster and smarter. The Kite plugin integrates with all the top editors and IDEs to give you smart completions and documentation while you’re typing. https://www.kite.com/get-kite/?utm_medium=referral&utm_source=youtube&utm_campaign=derricksherrill&utm_content=description-only

Support the Channel on Patreon --
https://www.patreon.com/join/derricksherrill
Join The Socials --
Reddit - https://www.reddit.com/r/CodeWithDerrick/
FB - https://www.facebook.com/CodeWithDerrick/
Insta - https://www.instagram.com/codewithderrick/
Twitter - https://twitter.com/codewithderrick
LinkedIn - https://www.linkedin.com/in/derricksherrill/
GitHub - https://github.com/Derrick-Sherrill
*****************************************************************
Full code from the video:

from phue import Bridge
from ip_address import bridge_ip_address
import time

def access_lights(bridge_ip_address):
b = Bridge(bridge_ip_address)
light_names_list = b.get_light_objects('name')
return light_names_list

def film_lights():
lights = access_lights(bridge_ip_address)
for light in lights:
lights[light].on = True
lights[light].hue = 7000
lights[light].saturation = 100

def danger_mode():
lights = access_lights(bridge_ip_address)
while True:
time.sleep(1)
for light in lights:
lights[light].on = True
lights[light].hue = 180
lights[light].saturation = 100
time.sleep(1)
for light in lights:
lights[light].on = True
lights[light].hue = 7000
lights[light].saturation = 100

if __name__ == '__main__':
film_lights()


Thanks so much for all the continued support! You guys are awesome. Super thankful that I get the opportunity to make youtube videos for you all. I hope you enjoy this one - A bit different than what I typically put out, but just testing to see if it's a style that you all like. Let me know!

https://github.com/Derrick-Sherrill/DerrickSherrill.com/blob/master/hue_lights.py

Packages (& Versions) used in this video:
PHue - https://github.com/studioimaginaire/phue
Time

*****************************************************************
Code from this tutorial and all my others can be found on my GitHub:
https://github.com/Derrick-Sherrill/DerrickSherrill.com

Check out my website:
https://www.derricksherrill.com/

If you liked the video - please hit the like button. It means more than you know. Thanks for watching and thank you for all your support!!

--- Channel FAQ --

What text editor do you use?
Atom - https://atom.io/

What Equipment do you use to film videos?
https://www.amazon.com/shop/derricksherrill

What editing software do you use?
Adobe CC - https://www.adobe.com/creativecloud.html
Premiere Pro for video editing
Photoshop for images
After Effects for animations

Do I have any courses available?
Yes & always working on more!
https://www.udemy.com/user/derrick-sherrill-2/

Where do I get my music?
I get all my music from the copyright free Youtube audio library
https://www.youtube.com/audiolibrary/music?nv=1

Let me know if there's anything else you want answered!

-------------------------

Always looking for suggestions on what video to make next -- leave me a comment with your project! Happy Coding!

Show more
0 Comments sort Sort By
Facebook Comments

Up next

Autoplay