NickWaterton / Roomba980-Python

Python program and library to control iRobot Roomba 980 Vacuum Cleaner
MIT License
367 stars 103 forks source link

Compatible with i7? #39

Open lolento opened 5 years ago

lolento commented 5 years ago

Is there anyway that I can help with making this compatible with i7?

I just gave this a try and it is not detecting the BLID or password....

NickWaterton commented 5 years ago

You mean i7 as in the processor? That has nothing to do with your issue. You need to check carefully your pre-reqs (python versions, paho mqtt version etc.) Can you show your output?

lolento commented 5 years ago

i7 and i7+ are new models. i7+ is just i7 with a dirt bin base.

Here is the output I'm getting:

[I 2018-10-05 14:13:51,435] [I 2018-10-05 14:13:51,436] Program Started [I 2018-10-05 14:13:51,436] [I 2018-10-05 14:13:51,436] Roomba.py Version: 1.2.3 [I 2018-10-05 14:13:51,436] Python Version: 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 15:51:26) [MSC v.1900 32 bit (Intel)] [I 2018-10-05 14:13:51,436] Paho MQTT Version: 1.4.0 [I 2018-10-05 14:13:51,436] CV Version: 3.4.3 [I 2018-10-05 14:13:51,437] PIL Version: 5.3.0 [I 2018-10-05 14:13:51,437] to Exit [I 2018-10-05 14:13:51,437] Roomba 980 MQTT data Interface [I 2018-10-05 14:13:51,437] reading info from config file ./config.ini [W 2018-10-05 14:13:51,437] No roomba or config file defined, I will attempt to discover Roombas, please put the Roomba on the dock and follow the instructions: [I 2018-10-05 14:13:51,437] Using Password version 1.2.2 waiting on port: 5678 for data [W 2018-10-05 14:13:51,438] supplied address 255.255.255.255 does not match discovered address 192.168.2.116, using discovered address... [W 2018-10-05 14:13:51,517] supplied address 255.255.255.255 does not match discovered address 192.168.2.12, using discovered address... json decode error: the JSON object must be str, not 'bytes' RECEIVED: %s (b'{"ver":"3","hostname":"iRobot-E21988B837404711A2301616CC00009C","robotname":' b'"Roomba","robotid":"E21988B837404711A2301616CC00009C","ip":"192.168.2.12","m' b'ac":"50:14:79:0F:1A:26","sw":"lewis+1.2.7+lewis-day-0-ota+9","sku":"i755020"' b',"nc":0,"proto":"mqtt","cap":{"binFullDetect": 1, "dockComm": 1, "maps": 3, ' b'"edge": 0, "area": 1, "eco": 1, "multiPass": 2, "pose": 1, "pp": 0, "5ghz": ' b'1, "prov": 3, "sched": 1, "svcConf": 1, "ota": 2, "log": 2}}') No Roombas found, try again... [I 2018-10-05 14:14:01,519] reading info from config file ./config.ini [E 2018-10-05 14:14:01,520] No Roombas found! You must specify RoombaIP, blid and roombaPassword to run this program, or have a config file, use -h to show options.

NickWaterton commented 5 years ago

Ah, OK.

Looks like it’s working, there is a python 3 error in the output (Json string vs bytes), that is probably the problem.

What platform/OS are you using? Is there a possibility of using python 2.7 to get the blid/password?

The program is written in 2.7, and it’s patched for the myriad versions of 3.x with all their incompatibilities. String vs byte is one of them.

I’ll take a look at fixing that, but it might take me a while to get to it.

Nick Waterton P.Eng Sent from my iPhone

On Oct 5, 2018, at 5:16 PM, lolento notifications@github.com<mailto:notifications@github.com> wrote:

i7 and i7+ are new models. i7+ is just i7 with a dirt bin base.

Here is the output I'm getting:

[I 2018-10-05 14:13:51,435] [I 2018-10-05 14:13:51,436] Program Started [I 2018-10-05 14:13:51,436] [I 2018-10-05 14:13:51,436] Roomba.py Version: 1.2.3 [I 2018-10-05 14:13:51,436] Python Version: 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 15:51:26) [MSC v.1900 32 bit (Intel)] [I 2018-10-05 14:13:51,436] Paho MQTT Version: 1.4.0 [I 2018-10-05 14:13:51,436] CV Version: 3.4.3 [I 2018-10-05 14:13:51,437] PIL Version: 5.3.0 [I 2018-10-05 14:13:51,437] to Exit [I 2018-10-05 14:13:51,437] Roomba 980 MQTT data Interface [I 2018-10-05 14:13:51,437] reading info from config file ./config.ini [W 2018-10-05 14:13:51,437] No roomba or config file defined, I will attempt to discover Roombas, please put the Roomba on the dock and follow the instructions: [I 2018-10-05 14:13:51,437] Using Password version 1.2.2 waiting on port: 5678 for data [W 2018-10-05 14:13:51,438] supplied address 255.255.255.255 does not match discovered address 192.168.2.116, using discovered address... [W 2018-10-05 14:13:51,517] supplied address 255.255.255.255 does not match discovered address 192.168.2.12, using discovered address... json decode error: the JSON object must be str, not 'bytes' RECEIVED: %s (b'{"ver":"3","hostname":"iRobot-E21988B837404711A2301616CC00009C","robotname":' b'"Roomba","robotid":"E21988B837404711A2301616CC00009C","ip":"192.168.2.12","m' b'ac":"50:14:79:0F:1A:26","sw":"lewis+1.2.7+lewis-day-0-ota+9","sku":"i755020"' b',"nc":0,"proto":"mqtt","cap":{"binFullDetect": 1, "dockComm": 1, "maps": 3, ' b'"edge": 0, "area": 1, "eco": 1, "multiPass": 2, "pose": 1, "pp": 0, "5ghz": ' b'1, "prov": 3, "sched": 1, "svcConf": 1, "ota": 2, "log": 2}}') No Roombas found, try again... [I 2018-10-05 14:14:01,519] reading info from config file ./config.ini [E 2018-10-05 14:14:01,520] No Roombas found! You must specify RoombaIP, blid and roombaPassword to run this program, or have a config file, use -h to show options.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/NickWaterton/Roomba980-Python/issues/39#issuecomment-427501138, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALCUZ0CoOPQNaNWE2gcG0bqSchkP0MFCks5uh8w6gaJpZM4XK054.

Unsubscribe from GE's commercial electronic messages: http://sc.ge.com/*casl-unsubscribe Désabonner des messages électroniques commerciaux de GE: http://sc.ge.com/*lcap-desabonnement

lolento commented 5 years ago

Thx so much.

I'm using this on windows but have a nas box that can run docker which can give this a try on Python 2.7

NickWaterton commented 5 years ago

You can run python 2.7 on a Windows too - that’s what I do. Most platforms have 2.7 and 3.x at the same time, you can choose which to run.

It’s just that to debug 3.x issues I have to spin up a VM to check it out, and that takes a while. The main program should work as its tested with 3.5, but I already have my credentials, so I haven’t tested out the whole discovery process with every version of 3.x.

Nick Waterton P.Eng Sent from my iPhone

On Oct 6, 2018, at 12:39 PM, lolento notifications@github.com<mailto:notifications@github.com> wrote:

Thx so much.

I'm using this on windows but have a nas box that can run docker which can give this a try on Python 2.7

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/NickWaterton/Roomba980-Python/issues/39#issuecomment-427588049, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALCUZ02VNGLwUJmtXiRh7yoCilg8_WSyks5uiNzCgaJpZM4XK054.

Unsubscribe from GE's commercial electronic messages: http://sc.ge.com/*casl-unsubscribe Désabonner des messages électroniques commerciaux de GE: http://sc.ge.com/*lcap-desabonnement

lolento commented 5 years ago

Hello,

I got a bit further with Python 2.7. However, it says BLID = None

c:\Python27>python2 -m roomba -R 192.168.2.109 [I 2018-10-06 15:23:49,653] [I 2018-10-06 15:23:49,653] Program Started [I 2018-10-06 15:23:49,653] [I 2018-10-06 15:23:49,653] Roomba.py Version: 1.2.3 [I 2018-10-06 15:23:49,653] Python Version: 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40) [MSC v.1500 64 bit (AMD64)] [I 2018-10-06 15:23:49,653] Paho MQTT Version: 1.2.3 [I 2018-10-06 15:23:49,653] CV Version: 3.4.3 [I 2018-10-06 15:23:49,653] PIL Version: 5.3.0 [I 2018-10-06 15:23:49,653] to Exit [I 2018-10-06 15:23:49,653] Roomba 980 MQTT data Interface [I 2018-10-06 15:23:49,653] reading info from config file ./config.ini [W 2018-10-06 15:23:49,653] No roomba or config file defined, I will attempt to discover Roombas, please put the Roomba on the dock and follow the instructions: waiting on port: 5678 for data found 1 Roomba(s) Make sure your robot (Roomba) at IP 192.168.2.109 is on the Home Base and powered on (green lights on). Then press and hold the HOME button on your robot until it plays a series of tones (about 2 seconds). Release the button and your robot will flash WIFI light. Press Enter to continue... Received: { "robotname": "Roomba", "sku": "i755020", "nc": 1, "ver": "3", "proto": "mqtt", "ip": "192.168.2.109", "hostname": "iRobot-E21988B837404711A2301616CC00009C", "sw": "lewis+1.2.7+lewis-day-0-ota+9", "robotid": "E21988B837404711A2301616CC00009C", "mac": "50:14:79:0F:1A:26", "cap": { "pp": 0, "sched": 1, "log": 2, "ota": 2, "area": 1, "binFullDetect": 1, "prov": 3, "maps": 3, "pose": 1, "eco": 1, "dockComm": 1, "edge": 0, "svcConf": 1, "multiPass": 2, "5ghz": 1 } } Roomba (Roomba) IP address is: 192.168.2.109 blid is: None Password=> xxx <= Yes, all this string. Use these credentials in roomba.py [I 2018-10-06 15:24:33,819] reading info from config file ./config.ini [I 2018-10-06 15:24:33,821] Success! 1 Roombas Found! [I 2018-10-06 15:24:33,821] Creating Roomba object 192.168.2.109 [I 2018-10-06 15:24:33,822] connecting Roomba 192.168.2.109 [W 2018-10-06 15:24:33,822] CSS file not found, creating ./style.css [W 2018-10-06 15:24:33,828] html file not found, creating ./Roombaroomba_map.html No handlers could be found for logger "roomba.main" Traceback (most recent call last): File "C:\Python27\lib\runpy.py", line 174, in _run_module_as_main "main", fname, loader, pkg_name) File "C:\Python27\lib\runpy.py", line 72, in _run_code exec code in run_globals File "C:\Python27\lib\site-packages\roomba__main.py", line 590, in main() File "C:\Python27\lib\site-packages\roomba\main__.py", line 572, in main myroomba.connect() File "C:\Python27\lib\site-packages\roomba\roomba.py", line 290, in connect if not self._connect(): File "C:\Python27\lib\site-packages\roomba\roomba.py", line 320, in _connect if exc_type == socket.error or exc_type == ConnectionRefusedError: NameError: global name 'ConnectionRefusedError' is not defined

Ghawken commented 5 years ago

@NickWaterton

Few simple changes get the library working with the i7

First: Hostname is now iRobot - previously iRoomba "hostname": "iRobot-E21988B837404711A2301616CC00009C",

Change:

password.py line 117

            if hostname[0] == 'Roomba':
                blid = hostname[1]

to

            if hostname[0] == 'Roomba' or hostname[0]=='iRobot':
                blid = hostname[1]

Second:

Password return now a null string attached to the end which needs to be removed.

password.py line 171 password = str(data[7:].decode())

Change to

password = str(data[7:]).partition(b'\0')[0]

Using python partition to split on the null return and take all the string before. (in my usage I don't use decode - which may impact this) Works with both i7 and 980.

Glenn

NickWaterton commented 5 years ago

Thanks for that, Is there still a python 3.5 issue?

NickWaterton commented 5 years ago

I've pushed a fixed version - can you try the password discovery out in python 3.5 again? (I think I fixed the 3.5 issue as well). Just rename your .ini file and try again.

lolento commented 5 years ago

Will do after I get home today.

lolento commented 5 years ago

Hi Nick,

I tried to do an upgrade to Roomba980-python via:

pip3 install git+https://github.com/NickWaterton/Roomba980-Python.git

the console is saying there is no upgrade....

Tried using: pip3 install Roomba980-Python==1.1.2

But console says the current version is 1.2.1 which is what I already have...

NickWaterton commented 5 years ago

Yes, this is because I don't maintain the PyPi version of this (was packaged by someone else).

I have updated the pip version to 1.2.2, see if that upgrades now.

lolento commented 5 years ago

Ok, it got further in Python 3.5, but not as far as Python 2.7, here is what I'm getting:

[I 2018-10-09 20:15:52,909] [I 2018-10-09 20:15:52,909] Program Started [I 2018-10-09 20:15:52,910] [I 2018-10-09 20:15:52,910] Roomba.py Version: 1.2.3 [I 2018-10-09 20:15:52,910] Python Version: 3.5.3 (v3.5.3:1880cb95a742, Jan 16 2017, 15:51:26) [MSC v.1900 32 bit (Intel)] [I 2018-10-09 20:15:52,910] Paho MQTT Version: 1.4.0 [I 2018-10-09 20:15:52,910] CV Version: 3.4.3 [I 2018-10-09 20:15:52,910] PIL Version: 5.3.0 [I 2018-10-09 20:15:52,910] to Exit [I 2018-10-09 20:15:52,911] Roomba 980 MQTT data Interface [I 2018-10-09 20:15:52,911] reading info from config file ./config.ini [W 2018-10-09 20:15:52,911] No roomba or config file defined, I will attempt to discover Roombas, please put the Roomba on the dock and follow the instructions: waiting on port: 5678 for data supplied address 255.255.255.255 does not match discovered address 192.168.2.116, using discovered address... supplied address 255.255.255.255 does not match discovered address 192.168.2.109, using discovered address... found 1 Roomba(s) Make sure your robot (Roomba) at IP 192.168.2.109 is on the Home Base and powered on (green lights on). Then press and hold the HOME button on your robot until it plays a series of tones (about 2 seconds). Release the button and your robot will flash WIFI light. Press Enter to continue... Received: { "sku": "i755020", "robotid": "E21988B837404711A2301616CC00009C", "ip": "192.168.2.109", "cap": { "maps": 3, "prov": 3, "edge": 0, "ota": 2, "5ghz": 1, "sched": 1, "svcConf": 1, "binFullDetect": 1, "log": 2, "multiPass": 2, "pp": 0, "area": 1, "dockComm": 1, "eco": 1, "pose": 1 }, "sw": "lewis+1.2.7+lewis-day-0-ota+9", "ver": "3", "nc": 0, "robotname": "Roomba", "mac": "50:14:79:0F:1A:26", "hostname": "iRobot-E21988B837404711A2301616CC00009C", "proto": "mqtt" } Roomba (Roomba) IP address is: 192.168.2.109 Traceback (most recent call last): File "C:\Users\Hilman\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "C:\Users\Hilman\AppData\Local\Programs\Python\Python35-32\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\Hilman\AppData\Local\Programs\Python\Python35-32\lib\site-packages\roomba__main.py", line 590, in main() File "C:\Users\Hilman\AppData\Local\Programs\Python\Python35-32\lib\site-packages\roomba\main.py", line 485, in main Password(file=arg.configfile) File "C:\Users\Hilman\AppData\Local\Programs\Python\Python35-32\lib\site-packages\roomba\password.py", line 39, in init__ self.get_password() File "C:\Users\Hilman\AppData\Local\Programs\Python\Python35-32\lib\site-packages\roomba\password.py", line 173, in get_password password = str(data[7:]).partition(b'\0')[0].decode() #for i7 - has null termination TypeError: Can't convert 'bytes' object to str implicitly

NickWaterton commented 5 years ago

Bloody bytes vs string I'm sure the python 3 people had a good reason for it but...

Anyway, pushed another fix, see how far it gets this time.

lolento commented 5 years ago

Thx, I tried to do a upgrade using pip but I guess the version wasn't updated...?

EDIT: I did a downgrade and then upgrade, so this is working with python 3.5 which is great.

gemixsan commented 4 years ago

this is what I get with the I7: Connection Error EOF occurred in violation of protocol (_ssl.c:590) Traceback (most recent call last): File "./getpassword.py", line 39, in main() File "./getpassword.py", line 34, in main Password(file=arg.configfile) File "/Users/gemasantamaria/Documents/Roomba980-Python-master/roomba/password.py", line 39, in init self.get_password() File "/Users/gemasantamaria/Documents/Roomba980-Python-master/roomba/password.py", line 136, in get_password wrappedSocket.send(packet) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 687, in send v = self._sslobj.write(data) ssl.SSLError: [SSL: SSL_HANDSHAKE_FAILURE] ssl handshake failure (_ssl.c:1647)

NickWaterton commented 4 years ago

I would need to know a lot more. What OS is this? what is the full output? Your libraries are probably out of date, especially if you are using python 2.7, many libraries (eg ssl) have not been updated in a long time.

It's possible that Roomba has implemented some new SSL security, but this would be the first time if they have.

Of course, the other possibility is that you already have a device connected to the Roomba (the app for instance). This is what causes 99% of the failures with Roomb.py connections.

This is a function of the Roomba itself, it only allows one connection at a time, so if the app is connected, nothing else can connect, and you get errors like this.

The app can still be connected even if it's closed.

gemixsan commented 4 years ago

I have Macos Mojave 10.14.6, I am using python 3.7 the last one. I have already tried again, turning off my mobile phone to be sure the app it is not runing, but I got the same error, please sorry for mi ignorance I do not know nothing about python I saw a youtube video to do this with terminal. This is the message I get

Make sure your robot (Roomba) at IP 192.168.1.67 is on the Home Base and powered on (green lights on). Then press and hold the HOME button on your robot until it plays a series of tones (about 2 seconds). Release the button and your robot will flash WIFI light. Press Enter to continue... Received: { "robotname": "Roomba", "sku": "i755840", "nc": 0, "ver": "3", "proto": "mqtt", "ip": "192.168.1.67", "hostname": "xxxxxxxx", "sw": "lewis+1.6.6+lewis-day-0-ota+29", "robotid": "xxxxxxxxx", "mac": "50:14:79:06:49:06", "cap": { "pp": 0, "svcConf": 1, "sched": 1, "log": 2, "ota": 2, "area": 1, "binFullDetect": 1, "prov": 3, "maps": 3, "pose": 1, "eco": 1, "dockComm": 1, "edge": 0, "team": 1, "multiPass": 2, "5ghz": 1 } } Roomba (Roomba) IP address is: 192.168.1.67 Connection Error EOF occurred in violation of protocol (_ssl.c:590) Traceback (most recent call last): File "./getpassword.py", line 39, in main() File "./getpassword.py", line 34, in main Password(file=arg.configfile) File "/Users/gemasantamaria/Documents/Roomba980-Python-master/roomba/password.py", line 39, in init self.get_password() File "/Users/gemasantamaria/Documents/Roomba980-Python-master/roomba/password.py", line 136, in get_password wrappedSocket.send(packet) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 687, in send v = self._sslobj.write(data) ssl.SSLError: [SSL: SSL_HANDSHAKE_FAILURE] ssl handshake failure (_ssl.c:1647)

Thanks for your help

tidalf commented 4 years ago

https://github.com/zhouF96/Roomba980-Python/commit/ede7e95e5b10c7e1d52154815f96098859287365 fixed the SSL handshake for me