mjg59 / python-broadlink

Python module for controlling Broadlink RM2/3 (Pro) remote controls, A1 sensor platforms and SP2/3 smartplugs
MIT License
1.38k stars 479 forks source link

Device has no auth attribute? #674

Closed Jibun-no-Kage closed 2 years ago

Jibun-no-Kage commented 2 years ago

Installed via # pip3 install python-broadlink # python3

import broadlink broadlink.discover() [broadlink.remote.rm4mini(('1.1.1.1', 80), mac=b'\ffC\xb01\xff>', devtype=25741, timeout=10, name='智能遥控', model='RM4 mini', manufacturer='Broadlink', is_locked=True)] theDevice=broadlink.discover() theDevice.auth() Traceback (most recent call last): File "", line 1, in AttributeError: 'list' object has no attribute 'auth'

What is the issue? Should have an class object not a list, right?

Jibun-no-Kage commented 2 years ago

And... the included example fails as well...

# python3 broadlink_discovery Discovering... Traceback (most recent call last): File "/root/python-broadlink/cli/broadlink_discovery", line 17, in if device.auth(): File "/usr/local/lib/python3.9/dist-packages/broadlink/device.py", line 185, in auth e.check_error(response[0x22:0x24]) File "/usr/local/lib/python3.9/dist-packages/broadlink/exceptions.py", line 152, in check_error raise exception(error_code) broadlink.exceptions.AuthenticationError: [Errno -1] Authentication failed

felipediel commented 2 years ago

Hi, discover() returns a list, you need to use the index eg. theDevices[0]. The second problem is that the device is locked, you need to open the official app and unlock it in order to authenticate.