-
-
Save SergioSV96/4118b7175ec16f953eb23a753af3a399 to your computer and use it in GitHub Desktop.
import sys | |
import socket | |
import colorsys | |
import argparse | |
from lifxlan import LifxLAN | |
def search_lifx_bulb(name, lifx): | |
""" | |
Returns the LIFX device for the selected bulb name | |
""" | |
print("Discovering lights...") | |
# get devices | |
devices = lifx.get_lights() | |
print("\nFound {} light(s):\n".format(len(devices))) | |
for i, device in enumerate(devices): | |
try: | |
print(device.get_label()) | |
if device.get_label() == name: | |
return device | |
except: | |
pass | |
sys.exit("Device not found") | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser(description='Connect a LIFX bulb with Hyperion.ng') | |
parser.add_argument('PORT', type=int, help='the hyperion.ng udpraw port selected') | |
parser.add_argument('NAME', type=str, help="the LIFX bulb's name") | |
args = parser.parse_args() | |
# Arguments | |
port = args.PORT | |
name = args.NAME | |
# Connection to LIFX | |
lifx = LifxLAN() | |
device = search_lifx_bulb(name, lifx) | |
""" | |
SOCKET UDP CLIENT | |
""" | |
IP = "127.0.0.1" # LOCAL IP | |
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | |
s.bind((IP, port)) | |
print("waiting on port:", port) | |
packet = bytearray(3) | |
while True: | |
data = s.recvfrom_into(packet) | |
hsv = colorsys.rgb_to_hsv(packet[0], packet[1], packet[2]) | |
hsvk = [hsv[0] * 65535, hsv[1] * 65535, hsv[2] * 257, 3500] | |
device.set_color(hsvk, 0, True) |
Hello again, I've been very caught up in other matters at home, but as far as the lifx strips/beams are concerned, I do believe you are correct with the LifxLan requisites for enabling multi-zone support.
And as you also stated, hyperion would need to be able to send the correct number of zones for the strips.
Hello again, I've been very caught up in other matters at home, but as far as the lifx strips/beams are concerned, I do believe you are correct with the LifxLan requisites for enabling multi-zone support.
And as you also stated, hyperion would need to be able to send the correct number of zones for the strips.
The hyperion part is really easy to do, just add more zones using their website UI, then we need to decode them properly on the script, do you want to do this? :)
Sorry for my late response,
I concur with what you said here, I wish I had one strip to try it myself.
Did you managed to find anything on controlling the Lifx-z strip? I saw that the LifxLan library used in this same gist had been updated already to support the strips as stated in their README:
I gave it a quick look and seems pretty straigthforward to implement with this current script, just need to revamp it a little and set some hyperion "zones" for it to send us more "color data" :)