Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

device.presets() errors with unassigned buttons #15

Open
TimoGo opened this issue Aug 6, 2017 · 1 comment
Open

device.presets() errors with unassigned buttons #15

TimoGo opened this issue Aug 6, 2017 · 1 comment

Comments

@TimoGo
Copy link

TimoGo commented Aug 6, 2017

Hi,

when I try to read the presets of a not yet assigned button with:

presets = device.presets()
print(presets[4].name)

I get this error:

root@e422731c2b9f:~# ./get_buttons.py 
Traceback (most recent call last):
  File "./get_buttons.py", line 18, in <module>
    print(presets[4].name)
IndexError: list index out of range
root@e422731c2b9f:~#

Iam a python beginner, so please ignore this if there is a simple solution for that in python.

@CharlesBlonde
Copy link
Owner

It's the normal behavior because you don't have 5 presets configured on your device (indices start at 0).

you can iterate over preset and get the preset_id (1-6):

for preset in presets:
  print(preset.preset_id)
  print(preset.name)

But I have to implement string representation methods (str) in order to help users to understand what are in the objects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants