lumisync 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lumisync-0.1.0/LICENSE +21 -0
- lumisync-0.1.0/PKG-INFO +107 -0
- lumisync-0.1.0/README.md +92 -0
- lumisync-0.1.0/lumisync/lumisync.py +36 -0
- lumisync-0.1.0/lumisync/modes/MonitorSync.py +73 -0
- lumisync-0.1.0/lumisync/modes/MusicSync.py +48 -0
- lumisync-0.1.0/lumisync/utils/GetData.py +34 -0
- lumisync-0.1.0/lumisync/utils/GetDevices.py +88 -0
- lumisync-0.1.0/lumisync/utils/SendData.py +45 -0
- lumisync-0.1.0/lumisync.egg-info/PKG-INFO +107 -0
- lumisync-0.1.0/lumisync.egg-info/SOURCES.txt +15 -0
- lumisync-0.1.0/lumisync.egg-info/dependency_links.txt +1 -0
- lumisync-0.1.0/lumisync.egg-info/entry_points.txt +2 -0
- lumisync-0.1.0/lumisync.egg-info/requires.txt +6 -0
- lumisync-0.1.0/lumisync.egg-info/top_level.txt +1 -0
- lumisync-0.1.0/pyproject.toml +21 -0
- lumisync-0.1.0/setup.cfg +4 -0
lumisync-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Minlor
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
lumisync-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lumisync
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python library for syncing Govee led strips with audio and screen content.
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: colorama>=0.4.6
|
|
9
|
+
Requires-Dist: colour>=0.1.5
|
|
10
|
+
Requires-Dist: dxcam>=0.0.5
|
|
11
|
+
Requires-Dist: numpy>=2.2.4
|
|
12
|
+
Requires-Dist: pillow>=11.1.0
|
|
13
|
+
Requires-Dist: soundcard>=0.4.4
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<h1 align="center">
|
|
18
|
+
<br>
|
|
19
|
+
LumiSync
|
|
20
|
+
<br>
|
|
21
|
+
</h1>
|
|
22
|
+
|
|
23
|
+
<h4 align="center">A program that allows you to easily sync your Govee lights.</h4>
|
|
24
|
+
<p align="center">
|
|
25
|
+
<a href="https://github.com/Minlor/LumiSync/stargazers"><img src="https://img.shields.io/github/stars/Minlor/LumiSync.svg?style=social&label=Star"></a>
|
|
26
|
+
<a href="https://github.com/Minlor/LumiSync/watchers"><img src="https://img.shields.io/github/watchers/Minlor/LumiSync.svg?style=social&label=Watch"></a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<a href="#key-features">Key Features</a> •
|
|
31
|
+
<a href="#how-to-use">How To Use</a> •
|
|
32
|
+
<a href="#download">Download</a> •
|
|
33
|
+
<a href="#credits">Credits</a> •
|
|
34
|
+
<a href="#related">Related</a> •
|
|
35
|
+
<a href="#license">License</a>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
> **Note**
|
|
40
|
+
> This project is in early development.
|
|
41
|
+
|
|
42
|
+
## Key Features
|
|
43
|
+
|
|
44
|
+
* Easy to use - Simple UI that allows you to easily control your lights.
|
|
45
|
+
* MonitorSync - Sync your lights to your monitor. (Alpha)
|
|
46
|
+
* Easy to use - Simple UI that allows you to easily control your lights.
|
|
47
|
+
* MusicSync - Sync your lights to your music. (Alpha)
|
|
48
|
+
* CustomSync - Sync your lights to a custom color/animation. (WIP)
|
|
49
|
+
* Open Source - LumiSync is open source and free to use.
|
|
50
|
+
* Availability - LumiSync is available for Windows and hasn't been tested on Linux or MacOS. (WIP)
|
|
51
|
+
|
|
52
|
+
## TODO
|
|
53
|
+
|
|
54
|
+
* [ ] Make a wiki page for the project.
|
|
55
|
+
* [ ] Add Multiple MusicSync modes and improve the current one.
|
|
56
|
+
* [ ] Add CustomSync feature.
|
|
57
|
+
* [ ] Add a GUI.
|
|
58
|
+
* [ ] Support for basic brightness control.
|
|
59
|
+
* [ ] Support for basic color control.
|
|
60
|
+
* [ ] Support for turning lights on/off.
|
|
61
|
+
|
|
62
|
+
## How To Use
|
|
63
|
+
|
|
64
|
+
Currently, the only way to use LumiSync is to download the source code and run it yourself. This will be changed in the future.
|
|
65
|
+
|
|
66
|
+
> **Note**
|
|
67
|
+
>
|
|
68
|
+
> This requires you to download [python](https://www.python.org/downloads/).
|
|
69
|
+
>
|
|
70
|
+
> All of the python requirements will be installed automatically when you run the program for the first time.
|
|
71
|
+
|
|
72
|
+
## Download
|
|
73
|
+
|
|
74
|
+
You can [download](https://codeload.github.com/Minlor/LumiSync/zip/refs/heads/main) the latest installable version of LumiSync here.
|
|
75
|
+
|
|
76
|
+
## Credits
|
|
77
|
+
|
|
78
|
+
Tools used:
|
|
79
|
+
* [**Wireshark**](https://wireshark.org/) (Massive thanks to the Wireshark team for making this amazing tool.)
|
|
80
|
+
|
|
81
|
+
This software uses the following open source packages:
|
|
82
|
+
|
|
83
|
+
* [dxcam](https://github.com/ra1nty/DXcam)
|
|
84
|
+
* [Pillow](https://github.com/python-pillow/Pillow)
|
|
85
|
+
* [soundcard](https://github.com/bastibe/SoundCard)
|
|
86
|
+
* [colour](https://github.com/colour-science/colour)
|
|
87
|
+
* [colorama](https://github.com/tartley/colorama)
|
|
88
|
+
|
|
89
|
+
## Related
|
|
90
|
+
|
|
91
|
+
[Govee Desktop](https://www.govee.com/download/desktop) - Official Govee desktop app. (Windows only, supports basic color control and monitor sync.)
|
|
92
|
+
|
|
93
|
+
## Support
|
|
94
|
+
|
|
95
|
+
<p>Giving a star to this project is the easiest way to show your support.</p>
|
|
96
|
+
|
|
97
|
+

|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
> [minlor.net](https://minlor.net) ·
|
|
106
|
+
> [cloud.minlor.net](https://cloud.minlor.net) ·
|
|
107
|
+
> GitHub [@minlor](https://github.com/minlor)
|
lumisync-0.1.0/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
|
|
2
|
+
<h1 align="center">
|
|
3
|
+
<br>
|
|
4
|
+
LumiSync
|
|
5
|
+
<br>
|
|
6
|
+
</h1>
|
|
7
|
+
|
|
8
|
+
<h4 align="center">A program that allows you to easily sync your Govee lights.</h4>
|
|
9
|
+
<p align="center">
|
|
10
|
+
<a href="https://github.com/Minlor/LumiSync/stargazers"><img src="https://img.shields.io/github/stars/Minlor/LumiSync.svg?style=social&label=Star"></a>
|
|
11
|
+
<a href="https://github.com/Minlor/LumiSync/watchers"><img src="https://img.shields.io/github/watchers/Minlor/LumiSync.svg?style=social&label=Watch"></a>
|
|
12
|
+
</p>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<a href="#key-features">Key Features</a> •
|
|
16
|
+
<a href="#how-to-use">How To Use</a> •
|
|
17
|
+
<a href="#download">Download</a> •
|
|
18
|
+
<a href="#credits">Credits</a> •
|
|
19
|
+
<a href="#related">Related</a> •
|
|
20
|
+
<a href="#license">License</a>
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
> **Note**
|
|
25
|
+
> This project is in early development.
|
|
26
|
+
|
|
27
|
+
## Key Features
|
|
28
|
+
|
|
29
|
+
* Easy to use - Simple UI that allows you to easily control your lights.
|
|
30
|
+
* MonitorSync - Sync your lights to your monitor. (Alpha)
|
|
31
|
+
* Easy to use - Simple UI that allows you to easily control your lights.
|
|
32
|
+
* MusicSync - Sync your lights to your music. (Alpha)
|
|
33
|
+
* CustomSync - Sync your lights to a custom color/animation. (WIP)
|
|
34
|
+
* Open Source - LumiSync is open source and free to use.
|
|
35
|
+
* Availability - LumiSync is available for Windows and hasn't been tested on Linux or MacOS. (WIP)
|
|
36
|
+
|
|
37
|
+
## TODO
|
|
38
|
+
|
|
39
|
+
* [ ] Make a wiki page for the project.
|
|
40
|
+
* [ ] Add Multiple MusicSync modes and improve the current one.
|
|
41
|
+
* [ ] Add CustomSync feature.
|
|
42
|
+
* [ ] Add a GUI.
|
|
43
|
+
* [ ] Support for basic brightness control.
|
|
44
|
+
* [ ] Support for basic color control.
|
|
45
|
+
* [ ] Support for turning lights on/off.
|
|
46
|
+
|
|
47
|
+
## How To Use
|
|
48
|
+
|
|
49
|
+
Currently, the only way to use LumiSync is to download the source code and run it yourself. This will be changed in the future.
|
|
50
|
+
|
|
51
|
+
> **Note**
|
|
52
|
+
>
|
|
53
|
+
> This requires you to download [python](https://www.python.org/downloads/).
|
|
54
|
+
>
|
|
55
|
+
> All of the python requirements will be installed automatically when you run the program for the first time.
|
|
56
|
+
|
|
57
|
+
## Download
|
|
58
|
+
|
|
59
|
+
You can [download](https://codeload.github.com/Minlor/LumiSync/zip/refs/heads/main) the latest installable version of LumiSync here.
|
|
60
|
+
|
|
61
|
+
## Credits
|
|
62
|
+
|
|
63
|
+
Tools used:
|
|
64
|
+
* [**Wireshark**](https://wireshark.org/) (Massive thanks to the Wireshark team for making this amazing tool.)
|
|
65
|
+
|
|
66
|
+
This software uses the following open source packages:
|
|
67
|
+
|
|
68
|
+
* [dxcam](https://github.com/ra1nty/DXcam)
|
|
69
|
+
* [Pillow](https://github.com/python-pillow/Pillow)
|
|
70
|
+
* [soundcard](https://github.com/bastibe/SoundCard)
|
|
71
|
+
* [colour](https://github.com/colour-science/colour)
|
|
72
|
+
* [colorama](https://github.com/tartley/colorama)
|
|
73
|
+
|
|
74
|
+
## Related
|
|
75
|
+
|
|
76
|
+
[Govee Desktop](https://www.govee.com/download/desktop) - Official Govee desktop app. (Windows only, supports basic color control and monitor sync.)
|
|
77
|
+
|
|
78
|
+
## Support
|
|
79
|
+
|
|
80
|
+
<p>Giving a star to this project is the easiest way to show your support.</p>
|
|
81
|
+
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
## License
|
|
85
|
+
|
|
86
|
+
MIT
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
> [minlor.net](https://minlor.net) ·
|
|
91
|
+
> [cloud.minlor.net](https://cloud.minlor.net) ·
|
|
92
|
+
> GitHub [@minlor](https://github.com/minlor)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
from threading import Thread
|
|
4
|
+
|
|
5
|
+
import colorama
|
|
6
|
+
|
|
7
|
+
def main():
|
|
8
|
+
colorama.init(True)
|
|
9
|
+
|
|
10
|
+
print(colorama.Fore.MAGENTA + f"Welcome to {colorama.Fore.LIGHTBLUE_EX}LumiSync!")
|
|
11
|
+
print(colorama.Fore.YELLOW + "Please select a option:")
|
|
12
|
+
print(colorama.Fore.GREEN + "1) Monitor Sync" "\n2) Music Sync" "\n9) Run test")
|
|
13
|
+
mode = input("")
|
|
14
|
+
match mode:
|
|
15
|
+
case "1" | "2":
|
|
16
|
+
if mode == "1":
|
|
17
|
+
from .modes import MonitorSync as sync
|
|
18
|
+
else:
|
|
19
|
+
from .modes import MusicSync as sync
|
|
20
|
+
|
|
21
|
+
thread = Thread(daemon=True, target=sync.start, name="MonitorSync", args=())
|
|
22
|
+
thread.start()
|
|
23
|
+
input("Press Enter to exit...")
|
|
24
|
+
case "9":
|
|
25
|
+
files = list(enumerate(os.listdir("tests"), 1))
|
|
26
|
+
print(
|
|
27
|
+
f"{colorama.Fore.LIGHTYELLOW_EX}Chose test to run:\n{colorama.Fore.YELLOW}"
|
|
28
|
+
+ "\n".join([f"{i}) {x}" for i, x in files])
|
|
29
|
+
)
|
|
30
|
+
test = input("Test: ")
|
|
31
|
+
for i, x in files:
|
|
32
|
+
if i == int(test):
|
|
33
|
+
exec(open(f"tests/{x}").read())
|
|
34
|
+
case _:
|
|
35
|
+
input(colorama.Fore.RED + "Invalid option!\nPress Enter to exit...")
|
|
36
|
+
sys.exit()
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import time
|
|
2
|
+
|
|
3
|
+
import colour
|
|
4
|
+
import dxcam
|
|
5
|
+
from PIL import Image
|
|
6
|
+
|
|
7
|
+
from ..utils import SendData
|
|
8
|
+
|
|
9
|
+
ss = dxcam.create()
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def lerp(start_value, end, t):
|
|
13
|
+
return start_value + t * (end - start_value)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def start():
|
|
17
|
+
SendData.send_razer_on_off(True)
|
|
18
|
+
previous_colors = [(0, 0, 0)] * 10 # Initialize with black colors
|
|
19
|
+
while True:
|
|
20
|
+
colors = []
|
|
21
|
+
try:
|
|
22
|
+
screen = ss.grab()
|
|
23
|
+
if screen is None:
|
|
24
|
+
continue
|
|
25
|
+
|
|
26
|
+
screen = Image.fromarray(screen)
|
|
27
|
+
width, height = screen.size
|
|
28
|
+
except OSError:
|
|
29
|
+
print("Warning: Screenshot failed, trying again...")
|
|
30
|
+
continue
|
|
31
|
+
|
|
32
|
+
top, bottom = int(height / 4 * 2), int(height / 4 * 3)
|
|
33
|
+
|
|
34
|
+
for x in range(4):
|
|
35
|
+
img = screen.crop((int(width / 4 * x), 0, int(width / 4 * (x + 1)), top))
|
|
36
|
+
point = (int(img.size[0] / 2), int(img.size[1] / 2))
|
|
37
|
+
colors.append(img.getpixel(point))
|
|
38
|
+
colors.reverse()
|
|
39
|
+
img = screen.crop((0, top, int(width / 4), bottom))
|
|
40
|
+
point = (int(img.size[0] / 2), int(img.size[1] / 2))
|
|
41
|
+
colors.append(img.getpixel(point))
|
|
42
|
+
for x in range(4):
|
|
43
|
+
img = screen.crop(
|
|
44
|
+
(int(width / 4 * x), bottom, int(width / 4 * (x + 1)), height)
|
|
45
|
+
)
|
|
46
|
+
point = (int(img.size[0] / 2), int(img.size[1] / 2))
|
|
47
|
+
colors.append(img.getpixel(point))
|
|
48
|
+
img = screen.crop((int((width / 4 * 3)), top, width, bottom))
|
|
49
|
+
colors.append(img.getpixel(point))
|
|
50
|
+
|
|
51
|
+
smooth_transition(previous_colors, colors)
|
|
52
|
+
previous_colors = colors
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def smooth_transition(previous_colors, colors, steps=10, delay=0.01):
|
|
56
|
+
prev_colors = [
|
|
57
|
+
colour.Color(rgb=(c[0] / 255, c[1] / 255, c[2] / 255)) for c in previous_colors
|
|
58
|
+
]
|
|
59
|
+
next_colors = [
|
|
60
|
+
colour.Color(rgb=(c[0] / 255, c[1] / 255, c[2] / 255)) for c in colors
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
for step in range(steps):
|
|
64
|
+
interpolated_colors = []
|
|
65
|
+
for i in range(len(colors)):
|
|
66
|
+
r = lerp(prev_colors[i].red, next_colors[i].red, step / steps)
|
|
67
|
+
g = lerp(prev_colors[i].green, next_colors[i].green, step / steps)
|
|
68
|
+
b = lerp(prev_colors[i].blue, next_colors[i].blue, step / steps)
|
|
69
|
+
interpolated_colors.append((int(r * 255), int(g * 255), int(b * 255)))
|
|
70
|
+
|
|
71
|
+
SendData.send_razer_data(SendData.convert_colors(interpolated_colors))
|
|
72
|
+
time.sleep(delay)
|
|
73
|
+
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
import soundcard as sc
|
|
3
|
+
|
|
4
|
+
from ..utils import SendData
|
|
5
|
+
|
|
6
|
+
# Set the audio parameters
|
|
7
|
+
duration = 0.01 # seconds
|
|
8
|
+
sample_rate = 48000 # You can adjust this based on your requirements
|
|
9
|
+
|
|
10
|
+
LED_COUNT = 20
|
|
11
|
+
colors = [[0, 0, 0]] * LED_COUNT
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def start():
|
|
15
|
+
SendData.send_razer_on_off(True)
|
|
16
|
+
while True:
|
|
17
|
+
with sc.get_microphone(
|
|
18
|
+
id=str(sc.default_speaker().name), include_loopback=True
|
|
19
|
+
).recorder(samplerate=sample_rate) as mic:
|
|
20
|
+
# Try and except due to a soundcard error when no audio is playing
|
|
21
|
+
try:
|
|
22
|
+
data = mic.record(numframes=duration * sample_rate)
|
|
23
|
+
except TypeError:
|
|
24
|
+
data = None
|
|
25
|
+
amp = get_amplitude(data)
|
|
26
|
+
wave_color(amp)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_amplitude(mic_data=None):
|
|
30
|
+
if mic_data is None:
|
|
31
|
+
return 0
|
|
32
|
+
amplitude = np.max(np.abs(mic_data))
|
|
33
|
+
if amplitude > 1:
|
|
34
|
+
amplitude = 1
|
|
35
|
+
return amplitude
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def wave_color(amplitude):
|
|
39
|
+
match amplitude:
|
|
40
|
+
case amplitude if amplitude < 0.04:
|
|
41
|
+
colors.append([int(amplitude * 255), 0, 0])
|
|
42
|
+
case amplitude if amplitude > 0.04 and amplitude < 0.08:
|
|
43
|
+
colors.append([0, int(amplitude * 255), 0])
|
|
44
|
+
case _:
|
|
45
|
+
colors.append([0, 0, int(amplitude * 255)])
|
|
46
|
+
colors.pop(0)
|
|
47
|
+
SendData.send_razer_data(SendData.convert_colors(colors))
|
|
48
|
+
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import time
|
|
3
|
+
|
|
4
|
+
import colorama
|
|
5
|
+
|
|
6
|
+
from . import GetDevices
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def get_device_data():
|
|
10
|
+
try:
|
|
11
|
+
with open("Settings.json", "r") as f:
|
|
12
|
+
data = json.load(f)
|
|
13
|
+
|
|
14
|
+
if time.time() - data.get("time", 0) > 86400:
|
|
15
|
+
print("Device data is older than 24 hours, requesting new data...")
|
|
16
|
+
data = GetDevices.start()
|
|
17
|
+
if len(data["devices"]) > 1:
|
|
18
|
+
print(
|
|
19
|
+
f"{colorama.Fore.LIGHTYELLOW_EX}Please select a device:\n{colorama.Fore.YELLOW}"
|
|
20
|
+
+ "\n".join(
|
|
21
|
+
[
|
|
22
|
+
f"{i + 1}) {device['Device_IP']} ({device['Model']})"
|
|
23
|
+
for i, device in enumerate(data["devices"])
|
|
24
|
+
]
|
|
25
|
+
)
|
|
26
|
+
)
|
|
27
|
+
selectedDevice = input("")
|
|
28
|
+
data["selectedDevice"] = int(selectedDevice) - 1
|
|
29
|
+
GetDevices.writeJSON(data)
|
|
30
|
+
return data
|
|
31
|
+
except FileNotFoundError:
|
|
32
|
+
print("Settings.json not found, requesting new data...")
|
|
33
|
+
data = GetDevices.start()
|
|
34
|
+
return data
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import socket
|
|
3
|
+
import sys
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
import colorama
|
|
7
|
+
|
|
8
|
+
multicast = "239.255.255.250"
|
|
9
|
+
|
|
10
|
+
port = 4001
|
|
11
|
+
listen_port = 4002
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def start():
|
|
15
|
+
requestScan()
|
|
16
|
+
print(f"{colorama.Fore.YELLOW}Trying to find device...")
|
|
17
|
+
data = listen()
|
|
18
|
+
print(f"{colorama.Fore.GREEN}Device found!")
|
|
19
|
+
settings = parseMessages(data)
|
|
20
|
+
writeJSON(settings)
|
|
21
|
+
return settings
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def requestScan():
|
|
25
|
+
data = {"msg": {"cmd": "scan", "data": {"account_topic": "reserve"}}}
|
|
26
|
+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
27
|
+
sock.sendto(bytes(json.dumps(data), "utf-8"), (multicast, port))
|
|
28
|
+
return
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def listen():
|
|
32
|
+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
33
|
+
sock.settimeout(10)
|
|
34
|
+
sock.bind(("", listen_port))
|
|
35
|
+
messages = []
|
|
36
|
+
try:
|
|
37
|
+
while True:
|
|
38
|
+
message, address = sock.recvfrom(1024)
|
|
39
|
+
print(f"{colorama.Fore.LIGHTGREEN_EX}Received message from: ", address)
|
|
40
|
+
messages.append(message)
|
|
41
|
+
except socket.timeout:
|
|
42
|
+
if len(messages) == 0:
|
|
43
|
+
print(f"{colorama.Fore.RED}Error: No device found!")
|
|
44
|
+
sys.exit()
|
|
45
|
+
return messages
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def parseMessages(messages):
|
|
49
|
+
try:
|
|
50
|
+
with open("Settings.json", "r") as f:
|
|
51
|
+
settings = json.load(f)
|
|
52
|
+
except FileNotFoundError:
|
|
53
|
+
settings = {"time": time.time(), "devices": [], "selectedDevice": 0}
|
|
54
|
+
|
|
55
|
+
# Ensure the settings dictionary has the 'devices' and 'selectedDevice' keys
|
|
56
|
+
if "devices" not in settings:
|
|
57
|
+
settings["devices"] = []
|
|
58
|
+
if "selectedDevice" not in settings:
|
|
59
|
+
settings["selectedDevice"] = 0
|
|
60
|
+
|
|
61
|
+
for deviceJson in messages:
|
|
62
|
+
device = json.loads(deviceJson)
|
|
63
|
+
existingDevice = next(
|
|
64
|
+
(
|
|
65
|
+
x
|
|
66
|
+
for x in settings["devices"]
|
|
67
|
+
if x["MAC"] == device["msg"]["data"]["device"]
|
|
68
|
+
),
|
|
69
|
+
None,
|
|
70
|
+
)
|
|
71
|
+
if existingDevice is None:
|
|
72
|
+
data = {
|
|
73
|
+
"MAC": device["msg"]["data"]["device"],
|
|
74
|
+
"Model": device["msg"]["data"]["sku"],
|
|
75
|
+
"Device_IP": device["msg"]["data"]["ip"],
|
|
76
|
+
"Device_Port": 4003,
|
|
77
|
+
}
|
|
78
|
+
settings["devices"].append(data)
|
|
79
|
+
else:
|
|
80
|
+
existingDevice["Device_IP"] = device["msg"]["data"]["ip"]
|
|
81
|
+
settings["time"] = time.time()
|
|
82
|
+
return settings
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def writeJSON(settings):
|
|
86
|
+
with open("settings.json", "w") as f:
|
|
87
|
+
json.dump(settings, f)
|
|
88
|
+
print(f"{colorama.Fore.LIGHTGREEN_EX}Data written to Settings.json")
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import base64
|
|
2
|
+
import json
|
|
3
|
+
import socket
|
|
4
|
+
|
|
5
|
+
from . import GetData
|
|
6
|
+
|
|
7
|
+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
8
|
+
settings = GetData.get_device_data()
|
|
9
|
+
device = settings["devices"][settings["selectedDevice"]]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def convert_colors(colors: list) -> str:
|
|
13
|
+
razer_header = [0xBB, 0x00, 0x0E, 0xB0, 0x01, len(colors)]
|
|
14
|
+
for color in colors:
|
|
15
|
+
razer_header.extend(color)
|
|
16
|
+
checksum = 0
|
|
17
|
+
for byte in razer_header:
|
|
18
|
+
checksum ^= byte
|
|
19
|
+
razer_header.append(checksum)
|
|
20
|
+
base64_header = base64.b64encode(bytearray(razer_header))
|
|
21
|
+
return base64_header.decode("utf-8")
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def send_razer_data(data: base64) -> None:
|
|
25
|
+
data = {"msg": {"cmd": "razer", "data": {"pt": data}}}
|
|
26
|
+
send_data(data)
|
|
27
|
+
return
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def send_on_off(on_off: bool = None) -> None:
|
|
31
|
+
send_data({"msg": {"cmd": "turn", "data": {"value": 1 if on_off else 0}}})
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def send_razer_on_off(on_off: bool = None) -> None:
|
|
35
|
+
send_data(
|
|
36
|
+
{"msg": {"cmd": "razer", "data": {"pt": "uwABsQEK" if on_off else "uwABsgEJ"}}}
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def send_data(data) -> json:
|
|
41
|
+
sock.sendto(
|
|
42
|
+
bytes(json.dumps(data), "utf-8"),
|
|
43
|
+
(device.get("Device_IP"), device.get("Device_Port", 4003)),
|
|
44
|
+
)
|
|
45
|
+
return
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: lumisync
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python library for syncing Govee led strips with audio and screen content.
|
|
5
|
+
Requires-Python: >=3.11
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Dist: colorama>=0.4.6
|
|
9
|
+
Requires-Dist: colour>=0.1.5
|
|
10
|
+
Requires-Dist: dxcam>=0.0.5
|
|
11
|
+
Requires-Dist: numpy>=2.2.4
|
|
12
|
+
Requires-Dist: pillow>=11.1.0
|
|
13
|
+
Requires-Dist: soundcard>=0.4.4
|
|
14
|
+
Dynamic: license-file
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
<h1 align="center">
|
|
18
|
+
<br>
|
|
19
|
+
LumiSync
|
|
20
|
+
<br>
|
|
21
|
+
</h1>
|
|
22
|
+
|
|
23
|
+
<h4 align="center">A program that allows you to easily sync your Govee lights.</h4>
|
|
24
|
+
<p align="center">
|
|
25
|
+
<a href="https://github.com/Minlor/LumiSync/stargazers"><img src="https://img.shields.io/github/stars/Minlor/LumiSync.svg?style=social&label=Star"></a>
|
|
26
|
+
<a href="https://github.com/Minlor/LumiSync/watchers"><img src="https://img.shields.io/github/watchers/Minlor/LumiSync.svg?style=social&label=Watch"></a>
|
|
27
|
+
</p>
|
|
28
|
+
|
|
29
|
+
<p align="center">
|
|
30
|
+
<a href="#key-features">Key Features</a> •
|
|
31
|
+
<a href="#how-to-use">How To Use</a> •
|
|
32
|
+
<a href="#download">Download</a> •
|
|
33
|
+
<a href="#credits">Credits</a> •
|
|
34
|
+
<a href="#related">Related</a> •
|
|
35
|
+
<a href="#license">License</a>
|
|
36
|
+
</p>
|
|
37
|
+
|
|
38
|
+

|
|
39
|
+
> **Note**
|
|
40
|
+
> This project is in early development.
|
|
41
|
+
|
|
42
|
+
## Key Features
|
|
43
|
+
|
|
44
|
+
* Easy to use - Simple UI that allows you to easily control your lights.
|
|
45
|
+
* MonitorSync - Sync your lights to your monitor. (Alpha)
|
|
46
|
+
* Easy to use - Simple UI that allows you to easily control your lights.
|
|
47
|
+
* MusicSync - Sync your lights to your music. (Alpha)
|
|
48
|
+
* CustomSync - Sync your lights to a custom color/animation. (WIP)
|
|
49
|
+
* Open Source - LumiSync is open source and free to use.
|
|
50
|
+
* Availability - LumiSync is available for Windows and hasn't been tested on Linux or MacOS. (WIP)
|
|
51
|
+
|
|
52
|
+
## TODO
|
|
53
|
+
|
|
54
|
+
* [ ] Make a wiki page for the project.
|
|
55
|
+
* [ ] Add Multiple MusicSync modes and improve the current one.
|
|
56
|
+
* [ ] Add CustomSync feature.
|
|
57
|
+
* [ ] Add a GUI.
|
|
58
|
+
* [ ] Support for basic brightness control.
|
|
59
|
+
* [ ] Support for basic color control.
|
|
60
|
+
* [ ] Support for turning lights on/off.
|
|
61
|
+
|
|
62
|
+
## How To Use
|
|
63
|
+
|
|
64
|
+
Currently, the only way to use LumiSync is to download the source code and run it yourself. This will be changed in the future.
|
|
65
|
+
|
|
66
|
+
> **Note**
|
|
67
|
+
>
|
|
68
|
+
> This requires you to download [python](https://www.python.org/downloads/).
|
|
69
|
+
>
|
|
70
|
+
> All of the python requirements will be installed automatically when you run the program for the first time.
|
|
71
|
+
|
|
72
|
+
## Download
|
|
73
|
+
|
|
74
|
+
You can [download](https://codeload.github.com/Minlor/LumiSync/zip/refs/heads/main) the latest installable version of LumiSync here.
|
|
75
|
+
|
|
76
|
+
## Credits
|
|
77
|
+
|
|
78
|
+
Tools used:
|
|
79
|
+
* [**Wireshark**](https://wireshark.org/) (Massive thanks to the Wireshark team for making this amazing tool.)
|
|
80
|
+
|
|
81
|
+
This software uses the following open source packages:
|
|
82
|
+
|
|
83
|
+
* [dxcam](https://github.com/ra1nty/DXcam)
|
|
84
|
+
* [Pillow](https://github.com/python-pillow/Pillow)
|
|
85
|
+
* [soundcard](https://github.com/bastibe/SoundCard)
|
|
86
|
+
* [colour](https://github.com/colour-science/colour)
|
|
87
|
+
* [colorama](https://github.com/tartley/colorama)
|
|
88
|
+
|
|
89
|
+
## Related
|
|
90
|
+
|
|
91
|
+
[Govee Desktop](https://www.govee.com/download/desktop) - Official Govee desktop app. (Windows only, supports basic color control and monitor sync.)
|
|
92
|
+
|
|
93
|
+
## Support
|
|
94
|
+
|
|
95
|
+
<p>Giving a star to this project is the easiest way to show your support.</p>
|
|
96
|
+
|
|
97
|
+

|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
MIT
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
> [minlor.net](https://minlor.net) ·
|
|
106
|
+
> [cloud.minlor.net](https://cloud.minlor.net) ·
|
|
107
|
+
> GitHub [@minlor](https://github.com/minlor)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
lumisync/lumisync.py
|
|
5
|
+
lumisync.egg-info/PKG-INFO
|
|
6
|
+
lumisync.egg-info/SOURCES.txt
|
|
7
|
+
lumisync.egg-info/dependency_links.txt
|
|
8
|
+
lumisync.egg-info/entry_points.txt
|
|
9
|
+
lumisync.egg-info/requires.txt
|
|
10
|
+
lumisync.egg-info/top_level.txt
|
|
11
|
+
lumisync/modes/MonitorSync.py
|
|
12
|
+
lumisync/modes/MusicSync.py
|
|
13
|
+
lumisync/utils/GetData.py
|
|
14
|
+
lumisync/utils/GetDevices.py
|
|
15
|
+
lumisync/utils/SendData.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lumisync
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "lumisync"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "A Python library for syncing Govee led strips with audio and screen content."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.11"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"colorama>=0.4.6",
|
|
13
|
+
"colour>=0.1.5",
|
|
14
|
+
"dxcam>=0.0.5",
|
|
15
|
+
"numpy>=2.2.4",
|
|
16
|
+
"pillow>=11.1.0",
|
|
17
|
+
"soundcard>=0.4.4",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
lumisync = "lumisync.lumisync:main"
|
lumisync-0.1.0/setup.cfg
ADDED