Skip to content

Instantly share code, notes, and snippets.

@atchoo78
Created August 17, 2020 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atchoo78/5cc0376f1b3323458fda3f1bc557683a to your computer and use it in GitHub Desktop.
Save atchoo78/5cc0376f1b3323458fda3f1bc557683a to your computer and use it in GitHub Desktop.
LIFX Cloud Scenes CLI - Python 3
#!/usr/bin/env python3
# Get API key/token: https://cloud.lifx.com/settings
# PIFX python library: https://github.com/cydrobolt/pifx
from pifx import PIFX
import pifx
import sys
import subprocess
API_KEY = '<PASTE API TOKEN HERE>'
lifx = PIFX(API_KEY)
scenes = lifx.list_scenes()
syntax = "Usage: python3 lifxScenes.py <scene name>"
def main():
print("\n" + "Choose a scene:" + "\n")
print("_______________________________" + "\n")
for x in range(len(scenes)):
scene_name = (scenes[x]['name'])
scene_uuid = (scenes[x]['uuid'])
print(scene_name)
print("\n" + syntax)
def activate_scene():
name = sys.argv[1]
for x in range(len(scenes)):
uuid = ["uuid"]
label = scenes[x]["name"]
if name in label:
scene = scenes[x]['uuid']
lifx.activate_scene(scene, 1)
print("Scene \"" + label + "\" is active.")
if(len(sys.argv) > 1 ):
activate_scene()
else:
main()
@atchoo78
Copy link
Author

Skjermbilde 2020-08-17 kl  21 39 43

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment