wemosetup
wemosetup copied to clipboard
encode hex no longer working in python3
Looks like the encode hex command in the encrypt_wifi_password is failing in python3 when trying to add a device. I tried importing codecs and changing it to
codecs.encode(salt, 'hex')
and
codecs.encode(iv,'hex')
but it still seems to fail with it complaining about it being a string and not byte coded `` Discovered 3 networks with SSID "wifissid", using the first available..." Traceback (most recent call last): File "/usr/lib/python3.8/encodings/hex_codec.py", line 15, in hex_encode return (binascii.b2a_hex(input), len(input)) TypeError: a bytes-like object is required, not 'str'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "wemosetup.py", line 258, in
I can poke through python a bit but not extremely versed in it so not sure what to try next.
you'd have to poke yourself, yes :(
you'd need to put in .encode() (or .encode("utf-8"), but i i'm not sure if anything there supports utf8) in right places to convert ascii strings to bytes
poking can be limited to that encrytpt_wifi_password function which is short
Are the salt and iv values required for wemo setup? looks like you can use just '-salt' with openssl and it will generate a random salt.
they are required, yes, you must use specific iv/salt that come the device metadata call
Any example of how we would do this?
I think the course of action should be: go over the code, check for bytes / strings arguments. If needed, find the commit before python2->python3 refactoring to see what it was supposed to be doing.
Sorry I'm not of help, but I don't have access to wemo devices anymore. But with some basic debugging and comparing to the old Python2 version, one should be able to do these fixes.