radinsky / broadlink-http-rest

Broadlink RM/RM2/RM Pro/RM3/BlackBean/A1 Web server with REST API (like..)
MIT License
156 stars 47 forks source link

sendCommand not working after migration #29

Closed thunder2k closed 5 years ago

thunder2k commented 5 years ago

Hi, I've installed your code cloning the git repo in a new machine running raspbian buster.

I've copied over my settings.ini file and installed all dependencies.

The server starts fine but, when I try to send a command, I get the following error

Exception happened during processing of request from ('192.168.1.10', 39708) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 293, in _handle_request_noblock self.process_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/lib/python2.7/SocketServer.py", line 655, in init self.handle() File "server.py", line 44, in handle self.handle_one_request() File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request method() File "server.py", line 60, in do_GET self.messageHandler() File "server.py", line 142, in messageHandler result = sendCommand(commandName, deviceName) File "server.py", line 238, in sendCommand deviceKey = device.key AttributeError: rm instance has no attribute 'key'

Can you please suggest what I could check?

Thanks!

radinsky commented 5 years ago

I would validate that broadlink package is installed and the RM is discovered correctly by using in python console:

import broadlink
devices = broadlink.discover()
print devices.__dict__

You should see your discovered RM.

thunder2k commented 5 years ago

This is the output of the code you suggested above:

Traceback (most recent call last): File "broadlink_test.py", line 1, in import broadlink File "/home/pi/broadlink.py", line 3, in devices = broadlink.discover(timeout=5) AttributeError: 'module' object has no attribute 'discover'

This is the output if I try to reinstall broadlink:

pip install broadlink Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Requirement already satisfied: broadlink in /usr/local/lib/python2.7/dist-packages (0.11.1) Requirement already satisfied: cryptography>=2.1.1 in /usr/lib/python2.7/dist-packages (from broadlink) (2.6.1) Requirement already satisfied: PyCRC in /usr/local/lib/python2.7/dist-packages (from broadlink) (1.21)

radinsky commented 5 years ago

I would try using this one: https://github.com/mjg59/python-broadlink

thunder2k commented 5 years ago

As a test? Yours was working previously, so why shouldn't work now? My doubt is, do I need to go through the setup process from scratch or migrating the settings.ini file is enough?

EDIT: I've just tested the same command in my Raspberry Pi with Strech (where everything is working correctly) and from the console I get the exact same error if I type import broadlink.

thunder2k commented 5 years ago

I don't know what is changed, but now the import broadlink command is working.

On Buster the instruction devices = broadlink.discover() never comes back

On Stretch it works correctly

How can this be possible? When you import a module are you pulling directly from the source every time?

Anyway I guess it's a module issue, isn't it?

radinsky commented 5 years ago

When you import a module are you pulling directly from the source every time?

No, the module should be installed only once.

Anyway I guess it's a module issue, isn't it?

Yes indeed.

thunder2k commented 5 years ago

For the benefit of the others, I found out that on my other pi I had version 0.9 of the broadlink module while on the new pi I had 0.11.1. Removing 0.11.1 and installing again 0.9 did the trick!