shauntarves / wyze-sdk

A modern Python client for controlling Wyze devices.
The Unlicense
308 stars 50 forks source link

PARAM_SIGN_INVALID for locks.create_access_code #174

Closed onigor closed 4 months ago

onigor commented 6 months ago

perm = LockKeyPermission(type=LockKeyPermissionType['ALWAYS'])

result = client.locks.create_access_code(
   device_mac='YD.LO1.xxx',
   access_code='123456',
   name='TEST_CODE',
   permission=perm
   )

the response is

{
    "ReqID": "5610c131aa",
    "ErrNo": "14008",
    "ErrMsg": "PARAM_SIGN_INVALID"
}

Fist thought maybe I was providing the wrong params but doesn't matter what I send, always get the same response.

jose96043 commented 5 months ago

I am getting the same error. I am not able to create an access_code

shauntarves commented 4 months ago

@onigor @jose96043, thanks for reporting the issues you had with this. There's a problem since Wyze stopped supporting the old login method in favor of the developer key/token. In short, we no longer get the user_id value "for free" from the login process, but the lock client needs this user_id when creating new lock codes. I've updated the code and created a new release version, BUT there is still a change you need to make in your own scripts:

# create a client
client = wyze_sdk.Client(token='<...>', refresh_token='<...>')
# query the user info to get the userid
user_info = client.user_get_info() # <-- this is currently an UNSTRUCTURED wyze response

# there are two options:
# 1. set the user_id globally on your client (doesn't require latest code)
client._user_id = user_info['data']['user_center_id']
# 2. update your call to create_access_code to pass the user_id value (notice no underscore in the prop name)
client.locks.create_access_code(device_mac='<...>',  ....., userid='<value from the user_info>')