Skip to content

Commit 4344092

Browse files
authored
Merge pull request #2 from deckerego/multi_send
Multiple Lights per Source
2 parents 7b0b164 + b5e0587 commit 4344092

File tree

3 files changed

+19
-15
lines changed

3 files changed

+19
-15
lines changed

Diff for: README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ An OBS script in both [Python](./scripts/obs_tally_light.py) and
2121
[Lua](./scripts/obs_tally_light.lua) is provided that maps
2222
preview/program/idle status to AV input sources. You can chose the color
2323
and brightness for the status of your input sources, and map each input source
24-
to the IP address or hostname of your tally light web interface.
24+
to the IP addresses or hostnames of your tally light web interface. If you want
25+
to interacet with multiple lights, a comma-separated list of addresses
26+
can be provided.
2527

2628
![OBS Plugin Settings](./docs/images/obs_settings.png)
2729

Diff for: docs/images/obs_settings.png

5.27 KB
Loading

Diff for: scripts/obs_tally_light.py

+16-14
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def script_properties():
6969

7070
video_source_names = list_video_source_names()
7171
for source_name in video_source_names:
72-
obs.obs_properties_add_text(props, source_name, source_name + " light addr:", obs.OBS_TEXT_DEFAULT)
72+
obs.obs_properties_add_text(props, source_name, source_name + " light(s):", obs.OBS_TEXT_DEFAULT)
7373

7474
return props
7575

@@ -91,26 +91,28 @@ def call_tally_light(source, color, brightness):
9191

9292
def fetch_command():
9393
command = commandQueue.get()
94-
addr = light_mapping[command['source']]
95-
if not addr:
96-
obs.script_log(obs.LOG_INFO, 'No tally light set for: %s' % (source))
94+
addressList = light_mapping[command['source']]
95+
if not addressList:
96+
obs.script_log(obs.LOG_INFO, 'No tally light set for: %s' % (command['source']))
9797
return
9898

9999
hexColor = hex(command['color'])
100100
hexBlue = hexColor[4:6]
101101
hexGreen = hexColor[6:8]
102102
hexRed = hexColor[8:10]
103103
pctBright = command['brightness'] / 10
104-
url = 'http://%s:7413/set?color=%s%s%s&brightness=%f' % (addr, hexRed, hexGreen, hexBlue, pctBright)
105-
106-
try:
107-
with urllib.request.urlopen(url, None, http_timeout_seconds) as response:
108-
data = response.read()
109-
text = data.decode('utf-8')
110-
obs.script_log(obs.LOG_INFO, 'Set %s tally light: %s' % (source, text))
111-
112-
except urllib.error.URLError as err:
113-
obs.script_log(obs.LOG_WARNING, 'Error connecting to tally light URL %s: %s' % (url, err.reason))
104+
addresses = addressList.split(',')
105+
106+
for address in addresses:
107+
url = 'http://%s:7413/set?color=%s%s%s&brightness=%f' % (address.strip(), hexRed, hexGreen, hexBlue, pctBright)
108+
try:
109+
with urllib.request.urlopen(url, None, http_timeout_seconds) as response:
110+
data = response.read()
111+
text = data.decode('utf-8')
112+
obs.script_log(obs.LOG_INFO, 'Set %s tally light: %s' % (command['source'], text))
113+
114+
except urllib.error.URLError as err:
115+
obs.script_log(obs.LOG_WARNING, 'Error connecting to tally light URL %s: %s' % (url, err.reason))
114116

115117
def list_video_source_names():
116118
sources = obs.obs_enum_sources()

0 commit comments

Comments
 (0)