-
-
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) |
If I'm understanding the code correctly, and this being with minimal knowledge of hyperion; I'd guess you would just have to modify the datagram for the bulb/listener to include more data. Hyperion already supports multiple zone led control, it seems it's just a matter or connecting the dots so to speak.
The Lifx-z Strip can come with multiple or a singular strip. up to 12 zones (or bulbs in this instance) or as little as 3 zones. they come in chunks of 3 zone strips, which you can add onto the end of the line of them.
I'd bet with my knowledge of lifx-z, and your knowledge of hyperion displayed here, I could see us coming up with a solution. However, multiple bulbs is a nice thought, an array of some kind perhaps, but the lifx-z strip in question is only a singular bulb in practice. We'd have to dig into the lifx-z api to figure out how to do multiple zones.
I'll start looking into this Lifx-Max Local control Ambilighting to try to find anything of value for us to snag.
If I'm understanding the code correctly, and this being with minimal knowledge of hyperion; I'd guess you would just have to modify the datagram for the bulb/listener to include more data. Hyperion already supports multiple zone led control, it seems it's just a matter or connecting the dots so to speak.
The Lifx-z Strip can come with multiple or a singular strip. up to 12 zones (or bulbs in this instance) or as little as 3 zones. they come in chunks of 3 zone strips, which you can add onto the end of the line of them.
I'd bet with my knowledge of lifx-z, and your knowledge of hyperion displayed here, I could see us coming up with a solution. However, multiple bulbs is a nice thought, an array of some kind perhaps, but the lifx-z strip in question is only a singular bulb in practice. We'd have to dig into the lifx-z api to figure out how to do multiple zones.
I'll start looking into this Lifx-Max Local control Ambilighting to try to find anything of value for us to snag.
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:
Supports white, color, multizone (LIFX Z, LIFX Beam)
MultiZoneLight API
Lights with MultiZone capability, such as the LIFX Z, have all the same methods as the Light API
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" :)
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? :)
Correct, I made this script for a single LIFX bulb, I assume LIFX Z-Strip would work as several bulbs but the script will need to be changed (probably a lot) if you want each individual LED to change in different colors at the same time, let me know if I can help you in any way as I don't own this type of strip but maybe I can point you into the right direction.