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

AttributeError: 'miband' object has no attribute 'artist' #54

Open
janvda opened this issue Nov 16, 2021 · 1 comment
Open

AttributeError: 'miband' object has no attribute 'artist' #54

janvda opened this issue Nov 16, 2021 · 1 comment

Comments

@janvda
Copy link

janvda commented Nov 16, 2021

I successfully connected to my miband 4 using program:

python miband4_console.py -m XXXX -k XXXX

I then navigate on my miband to the music menu
and if I then select the first item Get general info of the device from the curses menu it is reporting below error:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.9/site-packages/cursesmenu/curses_menu.py", line 133, in _wrap_start
    curses.wrapper(self._main_loop)
  File "/usr/local/lib/python3.9/curses/__init__.py", line 94, in wrapper
    return func(stdscr, *args, **kwds)
  File "/usr/local/lib/python3.9/site-packages/cursesmenu/curses_menu.py", line 193, in _main_loop
    self.process_user_input()
  File "/usr/local/lib/python3.9/site-packages/cursesmenu/curses_menu.py", line 289, in process_user_input
    self.select()
  File "/usr/local/lib/python3.9/site-packages/cursesmenu/curses_menu.py", line 329, in select
    self.selected_item.action()
  File "/usr/local/lib/python3.9/site-packages/cursesmenu/items/function_item.py", line 35, in action
    self.return_value = self.function(*self.args, **self.kwargs)
  File "/miband4/miband4_console.py", line 91, in general_info
    print ('Soft revision:',band.get_revision())
  File "/miband4/miband.py", line 380, in get_revision
    svc = self.getServiceByUUID(UUIDS.SERVICE_DEVICE_INFO)
  File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 488, in getServiceByUUID
    rsp = self._getResp('find')
  File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 416, in _getResp
    self.delegate.handleNotification(hnd, data)
  File "/miband4/miband.py", line 111, in handleNotification
    self.device.setMusic()
  File "/miband4/miband.py", line 666, in setMusic
    if self.artist is not None:
AttributeError: 'miband' object has no attribute 'artist'
Exception ignored in: <function Peripheral.__del__ at 0x7679a658>
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 630, in __del__
  File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 454, in disconnect
  File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 407, in _getResp
  File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 375, in _waitResp
bluepy.btle.BTLEInternalError: Unexpected response (find)
root@pi3two:/miband4# 
@janvda
Copy link
Author

janvda commented Nov 16, 2021

Possible solution:

call setTrack(MUSICSTATE.PAUSED) during initialization of the miband this will set all the music attributes so it won't report an AttibuteError anymore.

So I added line 184 (= self.setTrack(MUSICSTATE.PAUSED)) in miband.py which fixed the problem

image

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

1 participant