pymidi-controller 0.1.0__py3-none-any.whl

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.
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
File without changes
@@ -0,0 +1,55 @@
1
+ import requests
2
+ from pymidi_controller.config import ELGATO_LIGHT_IP
3
+
4
+ # -------------------------------------------------------------------
5
+ # 💡 Elgato Ring Light Controls
6
+ # -------------------------------------------------------------------
7
+
8
+ def get_ring_info():
9
+ """
10
+ Fetch and display full status info for the Elgato Ring Light.
11
+ Includes power state, brightness, and temperature.
12
+ """
13
+ url = f"http://{ELGATO_LIGHT_IP}:9123/elgato/lights"
14
+ try:
15
+ response = requests.get(url, timeout=2)
16
+ response.raise_for_status()
17
+ data = response.json()
18
+ light = data["lights"][0]
19
+
20
+ print("Elgato Ring Light Info:")
21
+ print(f" Power: {'ON' if light['on'] else 'OFF'}")
22
+ print(f" Brightness: {light['brightness']}%")
23
+ print(f" Temperature: {light['temperature']}K")
24
+ return light
25
+
26
+ except Exception as e:
27
+ print(f"❌ Failed to reach Elgato light at {ELGATO_LIGHT_IP}: {e}")
28
+
29
+
30
+ def get_light_state():
31
+ """
32
+ Return the current power state of the Elgato Ring Light (on/off).
33
+ """
34
+ url = f"http://{ELGATO_LIGHT_IP}:9123/elgato/lights"
35
+ response = requests.get(url).json()
36
+ light = response.get("lights", [{}])[0]
37
+ on = light.get("on", 0)
38
+ print(f"Elgato light is {'ON' if on else 'OFF'}")
39
+ return on
40
+
41
+
42
+ def toggle_light():
43
+ """
44
+ Toggle the Elgato Ring Light on/off based on current power state.
45
+ """
46
+ current = get_light_state()
47
+ new_state = 0 if current else 1
48
+
49
+ url = f"http://{ELGATO_LIGHT_IP}:9123/elgato/lights"
50
+ response = requests.put(url, json={
51
+ "lights": [{"on": new_state}]
52
+ })
53
+
54
+ print(f"Set Elgato light to {'ON' if new_state else 'OFF'}")
55
+ return response.status_code
@@ -0,0 +1,50 @@
1
+ from zeroconf import Zeroconf, ServiceBrowser, ServiceListener
2
+ from pymidi_controller.utils.config_manager import load_config, save_config
3
+ import time
4
+
5
+ # -------------------------------------------------------------------
6
+ # 🔎 Elgato Device Discovery via mDNS
7
+ # -------------------------------------------------------------------
8
+
9
+ class ElgatoListener(ServiceListener):
10
+ """
11
+ Zeroconf listener that prints and optionally saves discovered Elgato devices.
12
+ """
13
+ def add_service(self, zeroconf, type_, name):
14
+ info = zeroconf.get_service_info(type_, name)
15
+ if info:
16
+ ip = ".".join(str(b) for b in info.addresses[0])
17
+ model = info.properties.get(b'md').decode("utf-8") if b'md' in info.properties else "Unknown"
18
+
19
+ print(f"Found Elgato Device: {model} @ {ip}")
20
+
21
+ save = input("💾 Save this IP to config as elgato ip? [y/N] ").strip().lower()
22
+ if save == "y":
23
+ config = load_config()
24
+ config.setdefault("elgato", {})
25
+ config["elgato"]["ip"] = ip
26
+ save_config(config)
27
+ print(f"✅ Saved elgato ip={ip} to config")
28
+ else:
29
+ print("⚠️ Skipped saving IP to config")
30
+
31
+
32
+ def main(timeout=5):
33
+ """
34
+ Discover Elgato devices via Zeroconf (Bonjour/mDNS) and optionally save IP.
35
+ """
36
+ print("🔍 Searching for Elgato lights on the network...")
37
+
38
+ zeroconf = Zeroconf()
39
+ listener = ElgatoListener()
40
+
41
+ # Some devices use _elgato._tcp.local., others use _elg._tcp.local.
42
+ browser1 = ServiceBrowser(zeroconf, "_elgato._tcp.local.", listener)
43
+ browser2 = ServiceBrowser(zeroconf, "_elg._tcp.local.", listener)
44
+
45
+ time.sleep(timeout)
46
+ zeroconf.close()
47
+
48
+
49
+ if __name__ == "__main__":
50
+ main()
@@ -0,0 +1,224 @@
1
+ import requests
2
+ from pymidi_controller.config import HUE_BRIDGE_IP, HUE_API_KEY
3
+ from pymidi_controller.utils.state_manager import get_last_color, set_last_color
4
+ from pymidi_controller.utils.color_cycle import get_color_cycle
5
+
6
+ # -------------------------------------------------------------------
7
+ # 🎨 Color Presets
8
+ # -------------------------------------------------------------------
9
+
10
+ PRESET_COLORS = {
11
+ "red": 0,
12
+ "orange": 8000,
13
+ "yellow": 12750,
14
+ "green": 25500,
15
+ "cyan": 35000,
16
+ "blue": 46920,
17
+ "purple": 50000,
18
+ "pink": 56100,
19
+ "white": 0, # White achieved by setting saturation to 0
20
+ }
21
+
22
+ # -------------------------------------------------------------------
23
+ # 📋 List Functions
24
+ # -------------------------------------------------------------------
25
+
26
+ def list_groups():
27
+ """Print all Hue groups with their current on/off state."""
28
+ url = f"http://{HUE_BRIDGE_IP}/api/{HUE_API_KEY}/groups"
29
+ groups = requests.get(url).json()
30
+
31
+ for group_id, group in groups.items():
32
+ state = group.get('action', {}).get('on')
33
+ print(f"Group ID: {group_id}, Name: {group.get('name')}, State: {'on' if state else 'off'}")
34
+
35
+
36
+ def list_schedules():
37
+ """Print all configured Hue schedules."""
38
+ url = f"http://{HUE_BRIDGE_IP}/api/{HUE_API_KEY}/schedules"
39
+ schedules = requests.get(url).json()
40
+
41
+ if not schedules:
42
+ print("No schedules found.")
43
+ return
44
+
45
+ for sched_id, sched in schedules.items():
46
+ print(f"ID: {sched_id}, Name: {sched.get('name')}, Status: {sched.get('status')}, Command: {sched.get('command')}")
47
+
48
+
49
+ def list_lights():
50
+ """Print all individual Hue lights with their state, brightness, and effect."""
51
+ url = f"http://{HUE_BRIDGE_IP}/api/{HUE_API_KEY}/lights"
52
+ lights = requests.get(url).json()
53
+
54
+ if not lights:
55
+ print("No lights found.")
56
+ return
57
+
58
+ print("Lights:")
59
+ for light_id, light in lights.items():
60
+ state = light.get("state", {})
61
+ name = light.get("name")
62
+ on = state.get("on")
63
+ effect = state.get("effect", "none")
64
+ bri = state.get("bri", "-")
65
+ print(f" ID: {light_id} | Name: {name} | On: {on} | Brightness: {bri} | Effect: {effect}")
66
+
67
+ # -------------------------------------------------------------------
68
+ # 💡 Group Controls
69
+ # -------------------------------------------------------------------
70
+
71
+ def toggle_group(group_name):
72
+ """Toggle a group on or off based on its current state."""
73
+ url = f"http://{HUE_BRIDGE_IP}/api/{HUE_API_KEY}/groups"
74
+ groups = requests.get(url).json()
75
+
76
+ for group_id, group in groups.items():
77
+ if group.get("name") == group_name:
78
+ current_state = group.get("action", {}).get("on")
79
+ new_state = not current_state
80
+ response = requests.put(
81
+ f"{url}/{group_id}/action",
82
+ json={"on": new_state}
83
+ )
84
+ print(f"Toggled group '{group_name}' to {'on' if new_state else 'off'}")
85
+ return response.json()
86
+
87
+ raise ValueError(f"No group found with name: {group_name}")
88
+
89
+ def toggle_red_blue(group_name):
90
+ """Toggle a group color between red or blue based on its current state."""
91
+ last = get_last_color(group_name)
92
+ next_color = "blue" if last == "red" else "red"
93
+ set_group_color(group_name, next_color)
94
+ set_last_color(group_name, next_color)
95
+ print(f"Toggled {group_name} from {last or '[unknown]'} to {next_color}")
96
+
97
+ def cycle_group_color(group_name):
98
+ """Cycle the color of the group between the values specified in the user settings."""
99
+ colors = get_color_cycle(group_name)
100
+ if not colors:
101
+ raise ValueError(f"No color cycle defined for group '{group_name}'")
102
+
103
+ last_color = get_last_color(group_name)
104
+ if last_color not in colors:
105
+ next_index = 0
106
+ else:
107
+ next_index = (colors.index(last_color) + 1) % len(colors)
108
+
109
+ next_color = colors[next_index]
110
+ set_group_color(group_name, next_color)
111
+ set_last_color(group_name, next_color)
112
+
113
+ print(f"Cycled color for '{group_name}': {last_color or '[unknown]'} → {next_color}")
114
+
115
+ def set_group_color(group_name, hue_or_color, sat_val=254, bri_val=254):
116
+ """Set a group's color by hue value or preset name."""
117
+ if isinstance(hue_or_color, str):
118
+ hue_key = hue_or_color.lower()
119
+ if hue_key not in PRESET_COLORS:
120
+ raise ValueError(f"Unknown color name: {hue_key}")
121
+ hue_val = PRESET_COLORS[hue_key]
122
+ if hue_key == "white":
123
+ sat_val = 0 # Desaturate for white
124
+ else:
125
+ hue_val = hue_or_color
126
+
127
+ url = f"http://{HUE_BRIDGE_IP}/api/{HUE_API_KEY}/groups"
128
+ groups = requests.get(url).json()
129
+
130
+ for group_id, group in groups.items():
131
+ if group.get("name") == group_name:
132
+ action_url = f"{url}/{group_id}/action"
133
+ data = {
134
+ "on": True,
135
+ "hue": hue_val,
136
+ "sat": sat_val,
137
+ "bri": bri_val
138
+ }
139
+ response = requests.put(action_url, json=data)
140
+ print(f"Set group '{group_name}' to hue={hue_val}, sat={sat_val}, bri={bri_val}")
141
+ return response.json()
142
+
143
+ raise ValueError(f"No group found with name: {group_name}")
144
+
145
+ # -------------------------------------------------------------------
146
+ # ⏰ Schedule Controls
147
+ # -------------------------------------------------------------------
148
+
149
+ def toggle_schedule(schedule_name):
150
+ """Enable or disable a Hue schedule by name."""
151
+ url = f"http://{HUE_BRIDGE_IP}/api/{HUE_API_KEY}/schedules"
152
+ schedules = requests.get(url).json()
153
+
154
+ for schedule_id, schedule in schedules.items():
155
+ if schedule.get("name") == schedule_name:
156
+ current_status = schedule.get("status", "enabled")
157
+ new_status = "disabled" if current_status == "enabled" else "enabled"
158
+
159
+ response = requests.put(f"{url}/{schedule_id}", json={
160
+ "status": new_status
161
+ })
162
+
163
+ print(f"Toggled schedule '{schedule_name}' to {new_status}")
164
+ return response.json()
165
+
166
+ raise ValueError(f"No schedule found with name: {schedule_name}")
167
+
168
+ # -------------------------------------------------------------------
169
+ # 🌈 Colorloop Effect
170
+ # -------------------------------------------------------------------
171
+
172
+ def toggle_colorloop(group_name, effect=""):
173
+ """
174
+ Toggle colorloop effect for all lights in a group.
175
+ Accepts an optional override: --effect colorloop / none
176
+ """
177
+ group_url = f"http://{HUE_BRIDGE_IP}/api/{HUE_API_KEY}/groups"
178
+ light_url_base = f"http://{HUE_BRIDGE_IP}/api/{HUE_API_KEY}/lights"
179
+
180
+ effect = effect.strip().lower()
181
+ valid_effects = {"", "none", "colorloop"}
182
+ if effect not in valid_effects:
183
+ raise ValueError(f"Invalid effect '{effect}'. Valid options: {', '.join(valid_effects - {''})}")
184
+
185
+ groups = requests.get(group_url).json()
186
+
187
+ for group_id, group in groups.items():
188
+ if group.get("name") == group_name:
189
+ light_ids = group.get("lights", [])
190
+ if not light_ids:
191
+ print(f"No lights found in group '{group_name}'")
192
+ return
193
+
194
+ print(f"Found group '{group_name}' with lights: {light_ids}")
195
+
196
+ is_colorloop = False
197
+
198
+ if effect == "colorloop":
199
+ is_colorloop = False # Force toggle "on"
200
+ elif effect == "none":
201
+ is_colorloop = True # Force toggle "off"
202
+ else:
203
+ # Auto-detect based on lights
204
+ for light_id in light_ids:
205
+ light = requests.get(f"{light_url_base}/{light_id}").json()
206
+ current_effect = light.get("state", {}).get("effect", "none")
207
+ print(f"Light {light_id}: current effect = {current_effect}")
208
+ if current_effect == "colorloop":
209
+ is_colorloop = True
210
+
211
+ new_effect = "none" if is_colorloop else "colorloop"
212
+ print(f"\nToggling all lights in group to: {new_effect}")
213
+
214
+ for light_id in light_ids:
215
+ result = requests.put(f"{light_url_base}/{light_id}/state", json={
216
+ "on": True,
217
+ "effect": new_effect
218
+ })
219
+ print(f" → Set Light {light_id} to effect '{new_effect}' - response: {result.status_code}")
220
+
221
+ print(f"\nAll lights in group '{group_name}' updated.")
222
+ return
223
+
224
+ raise ValueError(f"No group found with name: {group_name}")
@@ -0,0 +1,81 @@
1
+ import requests
2
+ import time
3
+ from pymidi_controller.utils.config_manager import load_config, save_config
4
+
5
+ # -------------------------------------------------------------------
6
+ # 🌐 Hue Bridge Discovery & API Key Creation
7
+ # -------------------------------------------------------------------
8
+
9
+ def discover_bridge():
10
+ """
11
+ Discover the Hue Bridge on the local network using Philips N-UPnP service.
12
+ """
13
+ print("🔍 Discovering Hue Bridge via N-UPnP...")
14
+
15
+ response = requests.get("https://discovery.meethue.com/")
16
+ bridges = response.json()
17
+
18
+ if not bridges:
19
+ raise RuntimeError("❌ No Hue Bridge found on the local network.")
20
+
21
+ bridge_ip = bridges[0]["internalipaddress"]
22
+ print(f"✅ Found Hue Bridge at {bridge_ip}")
23
+ return bridge_ip
24
+
25
+
26
+ def create_user(bridge_ip, app_name="pymidi-controller"):
27
+ """
28
+ Prompt user to press the bridge link button and create a new API key.
29
+ """
30
+ print("🟡 Press the physical link button on the Hue Bridge, then press Enter...")
31
+ input("🔘 Waiting for confirmation...")
32
+
33
+ url = f"http://{bridge_ip}/api"
34
+ payload = {"devicetype": f"{app_name}#linux"}
35
+
36
+ for i in range(30): # Retry for up to 30 seconds
37
+ response = requests.post(url, json=payload).json()
38
+ print(".", end="", flush=True)
39
+ time.sleep(1)
40
+
41
+ if "error" in response[0]:
42
+ if response[0]["error"]["type"] == 101:
43
+ continue # Link button not pressed yet
44
+ else:
45
+ raise RuntimeError(response[0]["error"]["description"])
46
+ elif "success" in response[0]:
47
+ username = response[0]["success"]["username"]
48
+ print(f"\n✅ API key created: {username}")
49
+ return username
50
+
51
+ raise TimeoutError("❌ Timeout waiting for link button to be pressed.")
52
+
53
+
54
+ def save_to_config(ip, api_key):
55
+ """
56
+ Ask to save the discovered IP and API key into .env.
57
+ """
58
+ print(f"\nDiscovered Bridge IP: {ip}")
59
+ print(f"Generated API Key: {api_key}")
60
+
61
+ save = input("\n💾 Save this info to your .env file? [y/N] ").strip().lower()
62
+ if save == "y":
63
+ config = load_config()
64
+ config.setdefault("hue", {})
65
+ config["hue"]["bridge_ip"] = ip
66
+ config["hue"]["api_key"] = api_key
67
+ save_config(config)
68
+ print(f"✅ Saved to config.yaml:\n HUE_BRIDGE_IP={ip}\n HUE_API_KEY={api_key}")
69
+
70
+ else:
71
+ print("⚠️ Skipped saving to config. You can manually add these later.")
72
+
73
+
74
+ def main():
75
+ bridge_ip = discover_bridge()
76
+ api_key = create_user(bridge_ip)
77
+ save_to_config(bridge_ip, api_key)
78
+
79
+
80
+ if __name__ == "__main__":
81
+ main()
@@ -0,0 +1,146 @@
1
+ """
2
+ pymidi_controller CLI entry point
3
+ """
4
+ import argparse
5
+ import sys
6
+
7
+ from pymidi_controller.actions import hue_discovery
8
+ from pymidi_controller.actions import hue as hue_module
9
+ from pymidi_controller.actions import elgato_discovery, elgato as elgato_module
10
+
11
+ from pymidi_controller.utils.config_manager import init_config
12
+ from pymidi_controller.utils.service_manager import dispatch as service_dispatch, ServiceScope
13
+ from pymidi_controller.utils.midi_utils import listen as midi_listen
14
+
15
+
16
+ def main():
17
+ parser = argparse.ArgumentParser(prog="pymidi", description="MIDI Controller CLI")
18
+ subparsers = parser.add_subparsers(dest="command", required=True)
19
+
20
+ # ----------------------------------------------------------------
21
+ # Initialisation
22
+ # ----------------------------------------------------------------
23
+ subparsers.add_parser("init", help="Bootstrap ~/.config/pymidi-controller/config.yaml")
24
+
25
+ # ----------------------------------------------------------------
26
+ # Run the MIDI listener
27
+ # ----------------------------------------------------------------
28
+ run_p = subparsers.add_parser("run", help="Start the MIDI listener")
29
+ run_p.add_argument("--mode", choices=["interactive","blocking"], default="blocking", help="Listener mode")
30
+
31
+ # ----------------------------------------------------------------
32
+ # Service Commands
33
+ # ----------------------------------------------------------------
34
+ svc = subparsers.add_parser("service", help="Install or manage the systemd service")
35
+ svc_sub = svc.add_subparsers(dest="svc_cmd", required=True)
36
+ # install
37
+ inst = svc_sub.add_parser("install", help="Install and enable the service unit")
38
+ inst_grp = inst.add_mutually_exclusive_group(required=True)
39
+ inst_grp.add_argument("--user", action="store_true", help="Install to user's systemd")
40
+ inst_grp.add_argument("--system", action="store_true", help="Install system-wide (requires sudo)")
41
+ # uninstall
42
+ uninst = svc_sub.add_parser("uninstall", help="Disable and remove the service unit")
43
+ uninst_grp = uninst.add_mutually_exclusive_group(required=True)
44
+ uninst_grp.add_argument("--user", action="store_true", help="Remove from user's systemd")
45
+ uninst_grp.add_argument("--system", action="store_true", help="Remove from system-wide systemd")
46
+ # stop, enable, log
47
+ svc_sub.add_parser("stop", help="Stop the service")
48
+ svc_sub.add_parser("enable", help="Enable the service")
49
+ svc_sub.add_parser("log", help="Show service logs")
50
+
51
+ # ----------------------------------------------------------------
52
+ # Hue Commands
53
+ # ----------------------------------------------------------------
54
+ hue = subparsers.add_parser("hue", help="Hue bridge and lights management")
55
+ hue_sub = hue.add_subparsers(dest="hue_cmd", required=True)
56
+ hue_sub.add_parser("discover", help="Discover Hue Bridge and generate API key")
57
+ hue_sub.add_parser("list-groups", help="List Hue groups and their states")
58
+ hue_sub.add_parser("list-lights", help="List Hue lights and their states")
59
+ hue_sub.add_parser("list-schedules", help="List Hue schedules")
60
+ tg = hue_sub.add_parser("toggle-group", help="Toggle a Hue group on/off")
61
+ tg.add_argument("group", help="Hue group name")
62
+ sc = hue_sub.add_parser("set-color", help="Set a Hue group color")
63
+ sc.add_argument("group", help="Hue group name")
64
+ sc.add_argument("color", help="Named color or hue value")
65
+ sc.add_argument("--sat", type=int, default=254)
66
+ sc.add_argument("--bri", type=int, default=254)
67
+ ts = hue_sub.add_parser("toggle-schedule", help="Toggle a Hue schedule on/off")
68
+ ts.add_argument("schedule", help="Schedule name")
69
+ lp = hue_sub.add_parser("loop", help="Toggle colorloop effect for a group")
70
+ lp.add_argument("group", help="Hue group name")
71
+ lp.add_argument("--effect", choices=["colorloop","none"], default=None)
72
+ cc = hue_sub.add_parser("cycle-color", help="Cycle a group's color through the configured cycle")
73
+ cc.add_argument("group", help="Hue group name")
74
+
75
+ # ----------------------------------------------------------------
76
+ # Elgato Commands
77
+ # ----------------------------------------------------------------
78
+ elg = subparsers.add_parser("elgato", help="Elgato Ring Light controls")
79
+ elg_sub = elg.add_subparsers(dest="elgato_cmd", required=True)
80
+ elg_sub.add_parser("discover", help="Discover Elgato Ring Light via mDNS")
81
+ elg_sub.add_parser("toggle", help="Toggle Elgato Ring Light power")
82
+ elg_sub.add_parser("info", help="Get Elgato Ring Light status")
83
+
84
+ # ----------------------------------------------------------------
85
+ # MIDI Commands
86
+ # ----------------------------------------------------------------
87
+ midi = subparsers.add_parser("midi", help="MIDI utilities")
88
+ midi_sub = midi.add_subparsers(dest="midi_cmd", required=True)
89
+ midi_sub.add_parser("listen", help="Listens for MIDI inputs and prints values")
90
+
91
+ args = parser.parse_args()
92
+
93
+ # ----------------------------------------------------------------
94
+ # Dispatch commands
95
+ # ----------------------------------------------------------------
96
+ if args.command == "init":
97
+ init_config()
98
+ sys.exit(0)
99
+
100
+ if args.command == "run":
101
+ from pymidi_controller.core import run as core_run
102
+ core_run(mode=args.mode)
103
+ sys.exit(0)
104
+
105
+ if args.command == "service":
106
+ scope = ServiceScope.USER if getattr(args, "user", False) else ServiceScope.SYSTEM
107
+ service_dispatch(args.svc_cmd, scope)
108
+ sys.exit(0)
109
+
110
+ if args.command == "hue":
111
+ cmd = args.hue_cmd
112
+ if cmd == "discover":
113
+ hue_discovery.main()
114
+ elif cmd == "list-groups":
115
+ hue_module.list_groups()
116
+ elif cmd == "list-lights":
117
+ hue_module.list_lights()
118
+ elif cmd == "list-schedules":
119
+ hue_module.list_schedules()
120
+ elif cmd == "toggle-group":
121
+ hue_module.toggle_group(args.group)
122
+ elif cmd == "set-color":
123
+ val = int(args.color) if args.color.isdigit() else args.color
124
+ hue_module.set_group_color(args.group, val, args.sat, args.bri)
125
+ elif cmd == "toggle-schedule":
126
+ hue_module.toggle_schedule(args.schedule)
127
+ elif cmd == "loop":
128
+ hue_module.toggle_colorloop(args.group, args.effect)
129
+ elif cmd == "cycle-color":
130
+ hue_module.cycle_group_color(args.group)
131
+ sys.exit(0)
132
+
133
+ if args.command == "elgato":
134
+ cmd = args.elgato_cmd
135
+ if cmd == "discover":
136
+ elgato_discovery.main()
137
+ elif cmd == "toggle":
138
+ elgato_module.toggle_light()
139
+ elif cmd == "info":
140
+ elgato_module.get_ring_info()
141
+ sys.exit(0)
142
+
143
+ if args.command == "midi":
144
+ if args.midi_cmd == "listen":
145
+ midi_listen()
146
+ sys.exit(0)
@@ -0,0 +1,17 @@
1
+ from pymidi_controller.utils.config_manager import load_config
2
+
3
+ _cfg = load_config()
4
+
5
+ # Credentials
6
+ HUE_BRIDGE_IP = _cfg.get("hue", {}).get("bridge_ip")
7
+ HUE_API_KEY = _cfg.get("hue", {}).get("api_key")
8
+ ELGATO_LIGHT_IP = _cfg.get("elgato", {}).get("ip")
9
+
10
+ # MIDI section
11
+ _m = _cfg.get("midi", {})
12
+ MIDI_DEVICES = _m.get("devices", [])
13
+ MIDI_BINDINGS = _m.get("bindings", {})
14
+ COLOR_CYCLES = _m.get("color_cycles", {})
15
+
16
+ # CLI entrypoint
17
+ CLI_COMMAND = "pymidi-controller"
@@ -0,0 +1,83 @@
1
+ import threading
2
+ import sys
3
+ import select
4
+ import time
5
+ import subprocess
6
+ from mido import open_input
7
+ from pymidi_controller.utils.midi_utils import get_known_midi_input
8
+ from pymidi_controller.config import MIDI_BINDINGS, CLI_COMMAND
9
+
10
+ def format_midi_key(msg):
11
+ if msg.type == "control_change":
12
+ return f"{msg.type}:{msg.channel}:{msg.control}:{msg.value}"
13
+ elif msg.type in ("note_on", "note_off"):
14
+ return f"{msg.type}:{msg.channel}:{msg.note}:{msg.velocity}"
15
+ return None
16
+
17
+ def handle_midi_message(msg, bindings):
18
+
19
+ key = format_midi_key(msg)
20
+ if key and key in bindings:
21
+ command = [CLI_COMMAND] + bindings[key]
22
+ print(f"🎯 Matched {key} → Running: {' '.join(command)}")
23
+ try:
24
+ subprocess.Popen(command)
25
+ except Exception as e:
26
+ print(f"❌ Failed to run command: {e}")
27
+ elif key:
28
+ print(f"🎵 Unmapped input: {key}")
29
+
30
+ def run_blocking(device_name, bindings):
31
+ print("💤 Blocking mode: press Ctrl+C to exit.\n")
32
+ with open_input(device_name) as inport:
33
+ for msg in inport:
34
+ handle_midi_message(msg, bindings)
35
+
36
+ def run_interactive(device_name, bindings):
37
+ print("💡 Interactive mode: type 'quit' to exit.\n")
38
+ stop_flag = threading.Event()
39
+
40
+ def input_listener():
41
+ while not stop_flag.is_set():
42
+ if select.select([sys.stdin], [], [], 1)[0]:
43
+ command = sys.stdin.readline().strip().lower()
44
+ if command in ("quit", "exit", "q"):
45
+ stop_flag.set()
46
+
47
+ input_thread = threading.Thread(target=input_listener, daemon=True)
48
+ input_thread.start()
49
+
50
+ with open_input(device_name) as inport:
51
+ while not stop_flag.is_set():
52
+ for msg in inport.iter_pending():
53
+ handle_midi_message(msg, bindings)
54
+ time.sleep(0.01)
55
+
56
+ print("👋 Listener stopped.")
57
+
58
+ def run(mode: str = "blocking"):
59
+ """
60
+ Entry point for the long-running MIDI listener.
61
+ mode: 'interactive' or 'blocking'
62
+ """
63
+ bindings = MIDI_BINDINGS
64
+ if not bindings:
65
+ print("❌ No MIDI bindings defined in config.yaml.")
66
+ return
67
+
68
+ device_name = get_known_midi_input()
69
+ if not device_name:
70
+ print("❌ No MIDI input devices found.")
71
+ return
72
+
73
+ print(f"🎹 Listening on: {device_name}")
74
+ print(f"📖 Loaded {len(bindings)} mappings...")
75
+
76
+ if mode == "blocking":
77
+ run_blocking(device_name, bindings)
78
+ else:
79
+ run_interactive(device_name, bindings)
80
+
81
+
82
+ if __name__ == "__main__":
83
+ run()
@@ -0,0 +1,31 @@
1
+ hue:
2
+ bridge_ip:
3
+ api_key:
4
+
5
+ elgato:
6
+ ip:
7
+
8
+ midi:
9
+ devices:
10
+ # The names of available MIDI devices
11
+ - "Streamer X"
12
+ - "nanoPAD"
13
+ - "APC Key 25"
14
+ - "MIDI Fighter"
15
+
16
+ bindings:
17
+ # The MIDI note
18
+ control_change:0:1:127:
19
+ # The pymidi_controller command
20
+ - COMMAND
21
+ # Your Hue Group Name
22
+ - "HUE GROUP NAME"
23
+
24
+ # Available Colors: red, orange, yellow, green, cyan, blue, purple, pink, white
25
+ color_cycles:
26
+ # Your Hue Group Name
27
+ HUE GROUP NAME:
28
+ - red
29
+ - blue
30
+ - green
31
+ - purple
@@ -0,0 +1,15 @@
1
+ [Unit]
2
+ Description=🎹 MIDI Controller Background Service
3
+ After=network.target
4
+
5
+ [Service]
6
+ Type=simple
7
+ Environment=PATH=%h/.local/bin:/usr/local/bin:/usr/bin:/bin
8
+ ExecStart=/usr/bin/env pymidi-controller run --mode blocking
9
+ Restart=always
10
+ RestartSec=5
11
+ StandardOutput=journal
12
+ StandardError=journal
13
+
14
+ [Install]
15
+ WantedBy=default.target
File without changes
@@ -0,0 +1,13 @@
1
+ from pymidi_controller.config import COLOR_CYCLES
2
+
3
+ # Default fallback cycle if group not defined
4
+ DEFAULT_CYCLE = ["red", "blue"]
5
+
6
+ def get_color_cycle(group_name):
7
+
8
+ if not COLOR_CYCLES:
9
+ print(f"⚠️ color cycles not found at config.yaml. Using default cycle.")
10
+ return DEFAULT_CYCLE
11
+
12
+ return COLOR_CYCLES.get(group_name, DEFAULT_CYCLE)
13
+
@@ -0,0 +1,39 @@
1
+ import yaml
2
+ import os
3
+ import shutil
4
+ from importlib import resources
5
+ from pathlib import Path
6
+
7
+ XDG = Path.home() / ".config" if "XDG_CONFIG_HOME" not in __import__("os").environ else Path(__import__("os").environ["XDG_CONFIG_HOME"])
8
+ CFG_DIR = XDG / "pymidi-controller"
9
+ CFG_FILE = CFG_DIR / "config.yaml"
10
+
11
+ def ensure_config_dir():
12
+ CFG_DIR.mkdir(parents=True, exist_ok=True)
13
+
14
+ def load_config():
15
+ ensure_config_dir()
16
+ if not CFG_FILE.exists():
17
+ return {}
18
+ with CFG_FILE.open() as f:
19
+ return yaml.safe_load(f)
20
+
21
+ def save_config(cfg: dict):
22
+ ensure_config_dir()
23
+ # optional backup
24
+ if CFG_FILE.exists():
25
+ shutil.copy(CFG_FILE, CFG_FILE.with_suffix(".yaml.bak"))
26
+ with CFG_FILE.open("w") as f:
27
+ yaml.safe_dump(cfg, f, sort_keys=False)
28
+
29
+ def init_config():
30
+ ensure_config_dir()
31
+ data = resources.files("pymidi_controller").joinpath("data/default_config.yaml")
32
+
33
+ if not CFG_FILE.exists():
34
+ CFG_FILE.write_text(data.read_text())
35
+ os.chmod(CFG_FILE, 0o600)
36
+ print(f"Created {CFG_FILE}, please discover your API keys & set midi mappings.")
37
+ else:
38
+ print(f"{CFG_FILE} already exists, skipping.")
39
+ return
@@ -0,0 +1,60 @@
1
+ import mido
2
+ import threading
3
+ import sys
4
+ import select
5
+ import time
6
+ from mido import get_input_names
7
+ from pymidi_controller.config import MIDI_DEVICES
8
+
9
+ def get_known_midi_input():
10
+ input_ports = get_input_names()
11
+
12
+ if not input_ports:
13
+ return None
14
+
15
+ for name in MIDI_DEVICES:
16
+ match = next((p for p in input_ports if name.lower() in p.lower()), None)
17
+ if match:
18
+ return match
19
+
20
+ # Fallback
21
+ return input_ports[0]
22
+
23
+
24
+ def listen():
25
+ device_name = get_known_midi_input()
26
+
27
+ if not device_name:
28
+ print("❌ No MIDI input device found.")
29
+ return
30
+
31
+ print(f"🎧 Listening on {device_name}...\nPress buttons on your StreamerX!")
32
+ print("💡 Type 'quit' and press Enter to exit.\n")
33
+
34
+ stop_flag = threading.Event()
35
+
36
+ def input_listener():
37
+ while not stop_flag.is_set():
38
+ # Wait up to 1 second for user input
39
+ if select.select([sys.stdin], [], [], 1)[0]:
40
+ command = sys.stdin.readline().strip().lower()
41
+ if command in ("quit", "exit", "q"):
42
+ stop_flag.set()
43
+
44
+ input_thread = threading.Thread(target=input_listener, daemon=True)
45
+ input_thread.start()
46
+
47
+ try:
48
+ with mido.open_input(device_name) as port:
49
+ while not stop_flag.is_set():
50
+ for msg in port.iter_pending():
51
+ key = f"{msg.type}:{msg.channel}:{getattr(msg, 'control', msg.control)}:{getattr(msg, 'value', msg.value)}"
52
+ print(f"{msg} → {key}")
53
+ time.sleep(0.01)
54
+ except IOError:
55
+ print(f"❌ Could not open MIDI input: {device_name}")
56
+
57
+ print("👋 Listener stopped.")
58
+
59
+ if __name__ == "__main__":
60
+ listen()
@@ -0,0 +1,136 @@
1
+ import shutil
2
+ import subprocess
3
+ from pathlib import Path
4
+ from importlib import resources
5
+ from enum import Enum, auto
6
+
7
+ # -------------------------------------------------------------------
8
+ # Service Installation & Management with Scoped Control
9
+ # -------------------------------------------------------------------
10
+
11
+ class ServiceScope(Enum):
12
+ USER = auto()
13
+ SYSTEM = auto()
14
+
15
+
16
+ def install(scope: ServiceScope):
17
+ """
18
+ Install and enable the systemd service unit.
19
+
20
+ :param scope: ServiceScope.USER or ServiceScope.SYSTEM
21
+ """
22
+ if scope == ServiceScope.USER:
23
+ target_dir = Path.home() / ".config/systemd/user"
24
+ ctl = ["systemctl", "--user"]
25
+ elif scope == ServiceScope.SYSTEM:
26
+ target_dir = Path("/etc/systemd/system")
27
+ ctl = ["systemctl"]
28
+ else:
29
+ print("⚠️ Invalid scope for install.")
30
+ return
31
+
32
+ target_dir.mkdir(parents=True, exist_ok=True)
33
+ src = resources.files("pymidi_controller") / "data/systemd/pymidi-controller.service"
34
+ dst = target_dir / "pymidi-controller.service"
35
+ shutil.copy(src, dst)
36
+ print(f"✔️ Installed service unit to {dst}")
37
+
38
+ subprocess.run(ctl + ["daemon-reload"], check=True)
39
+ subprocess.run(ctl + ["enable", "--now", "pymidi-controller.service"], check=True)
40
+ print("✅ Service enabled and started.")
41
+
42
+
43
+ def uninstall(scope: ServiceScope):
44
+ """
45
+ Disable and remove the systemd service unit.
46
+
47
+ :param scope: ServiceScope.USER or ServiceScope.SYSTEM
48
+ """
49
+ if scope == ServiceScope.USER:
50
+ target_dir = Path.home() / ".config/systemd/user"
51
+ ctl = ["systemctl", "--user"]
52
+ elif scope == ServiceScope.SYSTEM:
53
+ target_dir = Path("/etc/systemd/system")
54
+ ctl = ["systemctl"]
55
+ else:
56
+ print("⚠️ Invalid scope for uninstall.")
57
+ return
58
+
59
+ service_name = "pymidi-controller.service"
60
+ dst = target_dir / service_name
61
+
62
+ subprocess.run(ctl + ["stop", service_name], check=False)
63
+ subprocess.run(ctl + ["disable", service_name], check=False)
64
+
65
+ if dst.exists():
66
+ dst.unlink()
67
+ print(f"🗑️ Removed service unit at {dst}")
68
+ else:
69
+ print(f"⚠️ No service unit found at {dst}")
70
+
71
+ subprocess.run(ctl + ["daemon-reload"], check=True)
72
+ print("✅ Service uninstalled.")
73
+
74
+
75
+ def stop(scope: ServiceScope = ServiceScope.USER):
76
+ """
77
+ Stop the systemd service.
78
+
79
+ :param scope: ServiceScope.USER or ServiceScope.SYSTEM
80
+ """
81
+ cmd = ["systemctl"]
82
+ if scope == ServiceScope.USER:
83
+ cmd.insert(1, "--user")
84
+ cmd.append("stop")
85
+ cmd.append("pymidi-controller.service")
86
+ subprocess.run(cmd, check=True)
87
+ print("✅ Service stopped.")
88
+
89
+
90
+ def enable(scope: ServiceScope = ServiceScope.USER):
91
+ """
92
+ Enable the systemd service.
93
+
94
+ :param scope: ServiceScope.USER or ServiceScope.SYSTEM
95
+ """
96
+ cmd = ["systemctl"]
97
+ if scope == ServiceScope.USER:
98
+ cmd.insert(1, "--user")
99
+ cmd.extend(["enable", "pymidi-controller.service"])
100
+ subprocess.run(cmd, check=True)
101
+ print("✅ Service enabled.")
102
+
103
+
104
+ def log(scope: ServiceScope = ServiceScope.USER):
105
+ """
106
+ Show the systemd service logs.
107
+
108
+ :param scope: ServiceScope.USER or ServiceScope.SYSTEM
109
+ """
110
+ cmd = ["journalctl"]
111
+ if scope == ServiceScope.USER:
112
+ cmd.extend(["--user"])
113
+ cmd.extend(["-u", "pymidi-controller.service", "--no-pager"])
114
+ subprocess.run(cmd, check=True)
115
+ print("✅ Service logs displayed.")
116
+
117
+
118
+ def dispatch(action: str, scope: ServiceScope = ServiceScope.USER):
119
+ """
120
+ Dispatcher for service subcommands.
121
+
122
+ :param action: one of 'install', 'uninstall', 'stop', 'enable', 'log'
123
+ :param scope: ServiceScope.USER or ServiceScope.SYSTEM
124
+ """
125
+ if action == "install":
126
+ install(scope)
127
+ elif action == "uninstall":
128
+ uninstall(scope)
129
+ elif action == "stop":
130
+ stop(scope)
131
+ elif action == "enable":
132
+ enable(scope)
133
+ elif action == "log":
134
+ log(scope)
135
+ else:
136
+ print(f"⚠️ Unknown service action: {action}")
@@ -0,0 +1,50 @@
1
+ import sqlite3
2
+ from pymidi_controller.utils.config_manager import CFG_DIR, ensure_config_dir
3
+
4
+ # Ensure config dir exists
5
+ ensure_config_dir()
6
+
7
+ # Path to our SQLite database
8
+ DB_FILE = CFG_DIR / "state.db"
9
+
10
+ # Initialize the database and create tables if they don't exist
11
+ def _get_connection():
12
+ conn = sqlite3.connect(DB_FILE)
13
+ conn.execute(
14
+ '''
15
+ CREATE TABLE IF NOT EXISTS group_colors (
16
+ group_name TEXT PRIMARY KEY,
17
+ last_color TEXT
18
+ )
19
+ '''
20
+ )
21
+ conn.commit()
22
+ return conn
23
+
24
+
25
+ def get_last_color(group_name: str) -> str | None:
26
+ """
27
+ Retrieve the last color for a given group from the state DB.
28
+ Returns None if not found.
29
+ """
30
+ conn = _get_connection()
31
+ cursor = conn.execute(
32
+ "SELECT last_color FROM group_colors WHERE group_name = ?",
33
+ (group_name,)
34
+ )
35
+ row = cursor.fetchone()
36
+ conn.close()
37
+ return row[0] if row else None
38
+
39
+
40
+ def set_last_color(group_name: str, color: str) -> None:
41
+ """
42
+ Insert or update the last color for a given group in the state DB.
43
+ """
44
+ conn = _get_connection()
45
+ conn.execute(
46
+ "INSERT INTO group_colors (group_name, last_color) VALUES (?, ?) ON CONFLICT(group_name) DO UPDATE SET last_color=excluded.last_color",
47
+ (group_name, color)
48
+ )
49
+ conn.commit()
50
+ conn.close()
@@ -0,0 +1,240 @@
1
+ Metadata-Version: 2.4
2
+ Name: pymidi-controller
3
+ Version: 0.1.0
4
+ Summary: Daemon that maps MIDI events to system actions (Elgato, Hue, etc.)
5
+ Author-email: Alex Sandilands <sandilands.alex@gmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/AlexSandilands/pymidi-controller
8
+ Project-URL: Bug Tracker, https://github.com/AlexSandilands/pymidi-controller/issues
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Operating System :: POSIX :: Linux
11
+ Classifier: Topic :: Multimedia :: Sound/Audio :: MIDI
12
+ Classifier: Topic :: Home Automation
13
+ Classifier: Topic :: System :: Hardware :: Hardware Drivers
14
+ Classifier: Topic :: Utilities
15
+ Requires-Python: >=3.7
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: mido>=1.2.10
19
+ Requires-Dist: python-rtmidi>=1.4.10
20
+ Requires-Dist: requests>=2.0
21
+ Requires-Dist: zeroconf>=0.40
22
+ Requires-Dist: PyYAML>=6.0
23
+ Dynamic: license-file
24
+
25
+ # 🎹 PyMIDI Controller
26
+
27
+ [![Python](https://img.shields.io/badge/python-3.7%2B-blue)](https://www.python.org/downloads/)
28
+ [![License](https://img.shields.io/github/license/AlexSandilands/pymidi-controller)](https://github.com/AlexSandilands/pymidi-controller/blob/main/LICENSE)
29
+ [![Last Commit](https://img.shields.io/github/last-commit/AlexSandilands/pymidi-controller)](https://github.com/AlexSandilands/pymidi-controller/commits/main)
30
+
31
+ A lightweight Python CLI and background MIDI listener for controlling Philips Hue and Elgato Ring Lights via a MIDI device.
32
+
33
+ ---
34
+
35
+ ## 📚 Table of Contents
36
+
37
+ - [🚀 Installation](#-installation)
38
+ - [⚡ Quickstart](#-quickstart)
39
+ - [⚙️ Configuration](#️-configuration)
40
+ - [🎛️ Commands](#️-commands)
41
+ - [Global](#global)
42
+ - [Service](#service)
43
+ - [Hue Commands](#hue-commands)
44
+ - [Elgato Commands](#elgato-commands)
45
+ - [MIDI Commands](#midi-commands)
46
+ - [🎹 MIDI Binding Guide](#-midi-binding-guide)
47
+ - [⚙️ Service (Optional)](#️-service-optional)
48
+
49
+ ## 🚀 Installation
50
+
51
+ **Requirements:**
52
+
53
+ - Python 3.7 or higher
54
+ - A modern Linux distro (systemd)
55
+
56
+ ### Via pip
57
+
58
+ ```bash
59
+ pip install pymidi-controller
60
+ ```
61
+
62
+ ### Via pipx (isolated install)
63
+
64
+ ```bash
65
+ pipx install pymidi-controller
66
+ ```
67
+
68
+ > If you use `pipx`, make sure `~/.local/bin` is on your `PATH` (`pipx ensurepath`).
69
+
70
+ ---
71
+
72
+ ## ⚡ Quickstart
73
+
74
+ 1. **Initialize your config** (creates `~/.config/pymidi-controller/config.yaml`):
75
+ ```bash
76
+ pymidi init
77
+ ```
78
+ 2. **Discover your Hue Bridge** (press the link button when prompted):
79
+ ```bash
80
+ pymidi hue discover
81
+ ```
82
+ 3. **Discover your Elgato Ring Light**:
83
+ ```bash
84
+ pymidi elgato discover
85
+ ```
86
+ 4. **Map MIDI inputs** (listen to your controller to grab event keys):
87
+ ```bash
88
+ pymidi midi listen
89
+ ```
90
+ Press buttons/knobs to print strings like `control_change:0:12:127` for use in your config.
91
+ 5. **Edit your config** (see [Configuration](#️-configuration)) to add your device IPs, API keys, MIDI bindings, and color cycles.
92
+ 6. **Start the listener to test configuration**:
93
+ ```bash
94
+ pymidi run --mode blocking
95
+ ```
96
+ 7. **(Optional) Background Service**:
97
+ You can also install as a background service: see [Service](#️-service-optional).
98
+
99
+ ---
100
+
101
+ ## ⚙️ Configuration
102
+
103
+ All settings live in a single YAML file:
104
+
105
+ ```
106
+ ~/.config/pymidi-controller/config.yaml
107
+ ```
108
+
109
+ This file will contain potentially sensitive data like your Hue API key or your IP address,
110
+ so it will be flagged as senstive and set so only your user can read it.
111
+
112
+ ### Example `config.yaml`
113
+
114
+ ```yaml
115
+ hue:
116
+ bridge_ip: 192.168.1.42 # your Hue Bridge address
117
+ api_key: YOUR_HUE_API_KEY # obtained via `pymidi hue discover`
118
+
119
+ elgato:
120
+ host: 192.168.1.43 # your Elgato Ring Light address
121
+
122
+ midi:
123
+ devices:
124
+ - "Streamer X"
125
+ - "nanoPAD"
126
+
127
+ # Map MIDI event keys → pymidi commands
128
+ bindings:
129
+ control_change:0:12:127:
130
+ - hue
131
+ - toggle-group
132
+ - "Living Room"
133
+ control_change:0:14:127:
134
+ - elgato
135
+ - toggle
136
+
137
+ # Optional: define color cycles per group
138
+ color_cycles:
139
+ Living Room:
140
+ - red
141
+ - blue
142
+ - green
143
+ ```
144
+ ---
145
+
146
+ ## 🎛️ Commands
147
+
148
+ Use `pymidi <group> --help` for details on each context.
149
+
150
+ ### Global
151
+
152
+ | Command | Description |
153
+ | ------------- | ------------------------------------------- |
154
+ | `pymidi init` | Create default config file |
155
+ | `pymidi run` | Start the MIDI listener (`--mode blocking`) |
156
+
157
+ ### Service
158
+
159
+ | Command | Description |
160
+ | ----------------------------------- | ----------------------------------- |
161
+ | `pymidi service install --user` | Install & start as a user service |
162
+ | `pymidi service install --system` | Install & start system-wide service |
163
+ | `pymidi service uninstall --user` | Stop & remove user service |
164
+ | `pymidi service uninstall --system` | Stop & remove system service |
165
+ | `pymidi service stop` | Stop the running service |
166
+ | `pymidi service enable` | Enable service (user scope) |
167
+ | `pymidi service log` | Tail service logs |
168
+
169
+ ### Hue Commands
170
+
171
+ | Command | Description |
172
+ | ---------------------------------------------------------- | ---------------------------------------- |
173
+ | `pymidi hue discover` | Find bridge & generate API key |
174
+ | `pymidi hue list-groups` | List all groups and on/off states |
175
+ | `pymidi hue list-lights` | List all lights and their state/effect |
176
+ | `pymidi hue list-schedules` | List all schedules |
177
+ | `pymidi hue toggle-group <group>` | Toggle a group on/off |
178
+ | `pymidi hue set-color <group> <color> [--sat N] [--bri N]` | Set group color |
179
+ | `pymidi hue toggle-schedule <name>` | Enable/disable a schedule |
180
+ | `pymidi hue loop [--effect colorloop \| none]` | Toggle colorloop effect |
181
+ | `pymidi hue cycle-color <group>` | Cycle group color through `color_cycles` |
182
+
183
+ ### Elgato Commands
184
+
185
+ | Command | Description |
186
+ | ------------------------ | ------------------------------ |
187
+ | `pymidi elgato discover` | Discover Ring Light via mDNS |
188
+ | `pymidi elgato toggle` | Toggle Ring Light on/off |
189
+ | `pymidi elgato info` | Show current Ring Light status |
190
+
191
+ ### MIDI Commands
192
+
193
+ | Command | Description |
194
+ | -------------------- | ------------------------------------------ |
195
+ | `pymidi midi listen` | Print incoming MIDI event keys for mapping |
196
+
197
+ ---
198
+
199
+ ## 🎹 MIDI Binding Guide
200
+
201
+ 1. Run:
202
+ ```bash
203
+ pymidi midi listen
204
+ ```
205
+ 2. Press a control (button/knob) to see its event key, e.g. `control_change:0:12:127`.
206
+ 3. Open `~/.config/pymidi-controller/config.yaml` and under `midi.bindings`, add:
207
+ ```yaml
208
+ bindings:
209
+ control_change:0:12:127:
210
+ - hue
211
+ - toggle-group
212
+ - "Living Room"
213
+ ```
214
+ Each value under the event key should be one part in order of the [Commands](#️-commands)
215
+ 4. Save and test:
216
+ ```bash
217
+ pymidi run --mode interactive
218
+ ```
219
+
220
+ ---
221
+
222
+ ## ⚙️ Service (Optional)
223
+
224
+ To run automatically at login:
225
+
226
+ ```bash
227
+ pymidi service install --user
228
+ ```
229
+
230
+ Logs:
231
+
232
+ ```bash
233
+ pymidi service log
234
+ ```
235
+
236
+ ---
237
+
238
+ ## 📜 License
239
+
240
+ MIT © Alex Sandilands
@@ -0,0 +1,23 @@
1
+ pymidi_controller/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
2
+ pymidi_controller/cli.py,sha256=mvim4LRasfeZxdWrzr5Intqe-VBUrkYFPgWuLVP4XLE,6867
3
+ pymidi_controller/config.py,sha256=gHhT_iJJ-scqPg4irkPXcOcsXFriI_ui5f6L6xATI6c,479
4
+ pymidi_controller/core.py,sha256=NxkpWmLajdPPtOLbXkoLi9SdNh5Vl5rA2_QHByf-DFY,2554
5
+ pymidi_controller/actions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
6
+ pymidi_controller/actions/elgato.py,sha256=AGUoOaXq-oigMG1Sw1oAY4U_NuetPf_xItx02AxQsSg,1730
7
+ pymidi_controller/actions/elgato_discovery.py,sha256=2UNreRaJsGr-O5fDmKBiWk82anqVZIoeZtmqLpClMKE,1789
8
+ pymidi_controller/actions/hue.py,sha256=g4IycA5DdX3-AKnUwxh3kgJbCkGYrhrKmnbOhSUv0IM,8497
9
+ pymidi_controller/actions/hue_discovery.py,sha256=DmgiGsvW1RQbV6PmqXurAk5IjYF3ZimDKJkIAHjVYSs,2649
10
+ pymidi_controller/data/default_config.yaml,sha256=cVs1500lsQroIVhQN7vZWFLrScCpGDgfIkeQgY2bcpw,550
11
+ pymidi_controller/data/systemd/pymidi-controller.service,sha256=Lb_AdNvFFpFg_EaxL1BjiQvQ-dPR21YbL52ZESb1Fic,331
12
+ pymidi_controller/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
+ pymidi_controller/utils/color_cycle.py,sha256=vWvVF4qLyPu9_fg8nMkhJhCJxpZLKBC2Y9YSxQkqM3E,365
14
+ pymidi_controller/utils/config_manager.py,sha256=ljNpBJFVnQtZQsA80l0-5bMXy8aSeYcXa9S_94AH6oE,1186
15
+ pymidi_controller/utils/midi_utils.py,sha256=z-7bh2NKsbu9ndjyB-uU0qYbL0aGoNVESgkurjSeuJc,1722
16
+ pymidi_controller/utils/service_manager.py,sha256=h-mQzOntimvoZrJoU6HqRqYUBylBJnBYZE_U_jxNBUg,4033
17
+ pymidi_controller/utils/state_manager.py,sha256=XVVxAqtCC_QKvSSjpDyivFeHvbuyKVz-3OdAYdGYuzs,1341
18
+ pymidi_controller-0.1.0.dist-info/licenses/LICENSE,sha256=oYHfWdRjsPZ03A3uWKC-J7KJnHqjdHFpWqoglQhvhqs,1164
19
+ pymidi_controller-0.1.0.dist-info/METADATA,sha256=2MFIDEf5tolSFDVcwerJwYwxQt3dLevsBo3Cc717dMs,7583
20
+ pymidi_controller-0.1.0.dist-info/WHEEL,sha256=wXxTzcEDnjrTwFYjLPcsW_7_XihufBwmpiBeiXNBGEA,91
21
+ pymidi_controller-0.1.0.dist-info/entry_points.txt,sha256=-LVVgYsbJkjGcq_WYz11cftdxiEub9cuqfLIipFslW0,101
22
+ pymidi_controller-0.1.0.dist-info/top_level.txt,sha256=TenwuHQdcL0bNx3v_epjVV7Tyo4lQ47lwKl1pYgrD3A,18
23
+ pymidi_controller-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.1.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ pymidi = pymidi_controller.cli:main
3
+ pymidi-controller = pymidi_controller.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alex Sandilands
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1 @@
1
+ pymidi_controller