mitchellrj / eufy_robovac

Other
105 stars 52 forks source link

Local key should be a 16-character string #17

Closed achaiah closed 4 years ago

achaiah commented 4 years ago

I have a 30C vacuum and am seeing this error when trying to set it up in home assistant:

File "/config/custom_components/eufy_vacuum/tuya.py", line 451, in __init__
    raise InvalidKey("Local key should be a 16-character string")
custom_components.eufy_vacuum.tuya.InvalidKey: Local key should be a 16-character string

My access_token is 22 characters long. I successfully used it on the command line to retrieve information from eufy but it doesn't seem to work with this project. Any pointers would be appreciated.

Thanks

achaiah commented 4 years ago

Huh.. so I commented out the assertion about key length but am now getting a different error:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 178, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/eufy_vacuum/vacuum.py", line 50, in setup_platform
    add_entities([EufyVacuum(device_config)], True)
  File "/config/custom_components/eufy_vacuum/vacuum.py", line 70, in __init__
    device_config['local_key'])
  File "/config/custom_components/eufy_vacuum/tuya.py", line 453, in __init__
    self.cipher = TuyaCipher(local_key, self.version)
  File "/config/custom_components/eufy_vacuum/tuya.py", line 166, in __init__
    self.cipher = Cipher(algorithms.AES(key.encode('ascii')), modes.ECB(),
  File "/usr/local/lib/python3.7/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py", line 35, in __init__
    self.key = _verify_key_size(self, key)
  File "/usr/local/lib/python3.7/site-packages/cryptography/hazmat/primitives/ciphers/algorithms.py", line 21, in _verify_key_size
    len(key) * 8, algorithm.name
ValueError: Invalid key size (176) for AES.
achaiah commented 4 years ago

Nevermind. Looks like the 30C vacuum is special. I had to look up the info per #1 with an old Android app and adb.