Skip to content

Commit

Permalink
Fix miio-extract-tokens for devices without tokens (#469)
Browse files Browse the repository at this point in the history
The `miio.extra_tokens.BackupDatabaseReader.decrypt_ztoken` method will
raise a `TypeError` when a device in the SQLite database file has no
token defined. This occurs for local (bluetooth) devices, such as the
Mi Action Cam.

This change will fix the `miio-extra-tokens` utility, so that it will
work again, even if there are devices without tokens.

See also issue #467 for more informations.
  • Loading branch information
domibarton authored and rytilahti committed Jan 24, 2019
1 parent e500982 commit 9692296
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions miio/extract_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def dump_raw(dev):
@staticmethod
def decrypt_ztoken(ztoken):
"""Decrypt the given ztoken, used by apple."""
if len(ztoken) <= 32:
return ztoken
if ztoken is None or len(ztoken) <= 32:
return str(ztoken)

keystring = '00000000000000000000000000000000'
key = bytes.fromhex(keystring)
Expand Down

0 comments on commit 9692296

Please sign in to comment.