Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@atchoo78 atchoo78 commented Aug 17, 2020

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