Coder Social home page Coder Social logo

Comments (6)

argrento avatar argrento commented on May 23, 2024

Hi!

You have too many bt-devices in the table? You mean it is hard to find desired device?

from huami-token.

b100dian avatar b100dian commented on May 23, 2024

No, I only have one device. What I am trying to say is that the script did not work out of the box for me, but only when modifying it to set my real BT address as device_id

from huami-token.

argrento avatar argrento commented on May 23, 2024

That's weird. Can you post the whole output of the script?

from huami-token.

b100dian avatar b100dian commented on May 23, 2024

Oh, interesting, now it works 😲 !
I do have some unrelated errors after my auth key

Downloading AGPS_ALM...
Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 159, in _new_conn
    conn = connection.create_connection(
  File "/usr/lib/python3.8/site-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/lib/python3.8/socket.py", line 918, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -5] No address associated with hostname

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 381, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 978, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 309, in connect
    conn = self._new_conn()
  File "/usr/lib/python3.8/site-packages/urllib3/connection.py", line 171, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7fe414460df0>: Failed to establish a new connection: [Errno -5] No address associated with hostname

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/usr/lib/python3.8/site-packages/urllib3/connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "/usr/lib/python3.8/site-packages/urllib3/util/retry.py", line 439, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='s3.us-west-2.amazonaws.com', port=443): Max retries exceeded with url: /huami-public-us2/AGPS_FILES/2020-10-18/1603032007862cep_alm_pak.zip (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fe414460df0>: Failed to establish a new connection: [Errno -5] No address associated with hostname'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "huami_token.py", line 229, in <module>
    device.get_gps_data()
  File "huami_token.py", line 175, in get_gps_data
    with requests.get(agps_result['fileUrl'], stream=True) as r:
  File "/usr/lib/python3.8/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='s3.us-west-2.amazonaws.com', port=443): Max retries exceeded with url: /huami-public-us2/AGPS_FILES/2020-10-18/1603032007862cep_alm_pak.zip (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fe414460df0>: Failed to establish a new connection: [Errno -5] No address associated with hostname'))

I think you can close this ticket, if somebody observes this situation I was in maybe he or she can make the same modifications as me:

--- a/huami_token.py
+++ b/huami_token.py
@@ -32,10 +32,10 @@ class HuamiAmazfit:
         self.r = str(uuid.uuid4())
 
         # IMEI or something unique
-        self.device_id = "02:00:00:%02x:%02x:%02x" % (random.randint(0, 255),
-                                                      random.randint(0, 255),
-                                                      random.randint(0, 255))
-
+        # self.device_id = "02:00:00:%02x:%02x:%02x" % (random.randint(0, 255),
+        #                                               random.randint(0, 255),
+        #                                               random.randint(0, 255))
+        self.device_id = "TH:ER:EA:AL:BT:ID"
     def get_access_token(self):
         print(f"Getting access token with {self.method} login method...")

from huami-token.

argrento avatar argrento commented on May 23, 2024

To summarize: if device_id is random, no keys are returned, but if you set device_id to your phone mac address, key is returned?

from huami-token.

b100dian avatar b100dian commented on May 23, 2024

yes, but not phone mac, but watch Bluetooth address
And I was not able to reproduce. so it may have been some other glitch..

from huami-token.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.