Skip to content

Commit

Permalink
Allow empty button config
Browse files Browse the repository at this point in the history
This is an actual usecase in case someone wants to setup a device
and figure out the button ids by looking at the logs
  • Loading branch information
votti committed Jan 2, 2023
1 parent d3aa169 commit ef0b487
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions src/jukebox/components/controls/event_devices/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,30 +95,24 @@ def initialize():
default={},
).items():
logger.debug("activate %s", name)
button_mapping = config.get("mapping", default=None)
if button_mapping:
button_callbacks: dict[int, Callable] = {}
for key, action_request in button_mapping.items():
button_callbacks[key] = jukebox.utils.bind_rpc_command(
action_request,
dereference=False,
logger=logger,
)
device_name = config.get("device_name")
exact = config.get("exact", default=False)
logger.debug(
f'Call activate with: "{device_name}" and exact: {exact}',
)
activate(
device_name,
button_callbacks=button_callbacks,
exact=exact,
)
else:
logger.error(
"No button mapping configured for event device: %s",
name,
button_mapping = config.get("mapping", default={})
button_callbacks: dict[int, Callable] = {}
for key, action_request in button_mapping.items():
button_callbacks[key] = jukebox.utils.bind_rpc_command(
action_request,
dereference=False,
logger=logger,
)
device_name = config.get("device_name")
exact = config.get("exact", default=False)
logger.debug(
f'Call activate with: "{device_name}" and exact: {exact}',
)
activate(
device_name,
button_callbacks=button_callbacks,
exact=exact,
)


@plugin.atexit
Expand Down

0 comments on commit ef0b487

Please sign in to comment.