Created
August 17, 2020 19:35
-
-
Save atchoo78/5cc0376f1b3323458fda3f1bc557683a to your computer and use it in GitHub Desktop.
LIFX Cloud Scenes CLI - Python 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
Author
atchoo78
commented
Aug 17, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment