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

Опубликовано: 21 Февраль 2020
на канале: Derrick Sherrill
144,099
3.3k

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_me...

Support the Channel on Patreon --
  / derricksherrill  
Join The Socials --
Reddit -   / codewithderrick  
FB -   / codewithderrick  
Insta -   / codewithderrick  
Twitter -   / codewithderrick  
LinkedIn -   / 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/D...

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/D...

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/derricksh...

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-sh...

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

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!