Jump to content

cannot import name 'Mapping' from 'collections'


brockp

Recommended Posts

Posted

I just added the roomba plugin to my eisy setup running 6.0 and pg3,  it's not finding our roomba s9+

It doesn't start and discover doesn't appear to do anything. 

 

I can control it from the app just fine, looking in the logs there are a bunch of errors that look like python errors:

 

2025-10-06 09:14:18.142 MainThread udi_interface      INFO     __init__:<module>: Loading udi_interface module
2025-10-06 09:14:18.143 MainThread udi_interface      INFO     __init__:<module>: Loading node module
2025-10-06 09:14:18.143 MainThread udi_interface      INFO     __init__:<module>: Loading custom module
2025-10-06 09:14:18.143 MainThread udi_interface      INFO     __init__:<module>: Loading isy module
2025-10-06 09:14:18.143 MainThread udi_interface      INFO     __init__:<module>: Loading OAuth module
2025-10-06 09:14:18.144 MainThread udi_interface      INFO     __init__:<module>: UDI interface initialized
2025-10-06 09:14:18.144 MainThread udi_interface      INFO     __init__:<module>: UDI Python Interface for Polyglot version 3 3.3.18 Starting...
2025-10-06 09:14:18.146 MainThread udi_interface      ERROR    udi_interface:write: Traceback (most recent call last):
2025-10-06 09:14:18.146 MainThread udi_interface      ERROR    udi_interface:write: File "/var/polyglot/pg3/ns/0021b9026aaf_9/roomba-poly.py", line 19, in <module>
2025-10-06 09:14:18.146 MainThread udi_interface      ERROR    udi_interface:write: from roomba import Roomba
2025-10-06 09:14:18.147 MainThread udi_interface      ERROR    udi_interface:write: File "/var/polyglot/pg3/ns/0021b9026aaf_9/roomba.py", line 42, in <module>
2025-10-06 09:14:18.147 MainThread udi_interface      ERROR    udi_interface:write: from collections import Mapping
2025-10-06 09:14:18.147 MainThread udi_interface      ERROR    udi_interface:write: ImportError
2025-10-06 09:14:18.147 MainThread udi_interface      ERROR    udi_interface:write: :
2025-10-06 09:14:18.147 MainThread udi_interface      ERROR    udi_interface:write: cannot import name 'Mapping' from 'collections' (/usr/local/lib/python3.11/collections/__init__.py)

 

Posted (edited)

Hmm. This is not my plugin, but I recognize this error. The Mapping class is in collections.abc, not collections. And it's been that way since Python 3.3. I think Python 3.3-3.9 had an alias that allowed imports from collections, but that was removed in Python 3.10. But that was like 4 years ago. And udx has included Python 3.10 or 3.11 for most of that timeframe. So it doesn't make a lot of sense that it would just now be cropping up now. I guess it's possible that the Roomba plugin (or the roomba library it depends on) hasn't been updated in A LONG TIME.

Edited by Goose66
  • Like 1
Posted

I see the plugin is in a GitHub repo and it's free. The quick fix for you would be to ssh into your eisy or policy, navigate to the /var/polyglot/pg3/ns/0021b9026aaf_9/roomba.py file, and change

 from collections import Mapping

to

 from collections.abc import Mapping

using a text editor, like ee or vi

A better solution would be to fork the repository in GitHub, make the fix and make a pull request to Bob to merge it back in and upload a new version of the plugin. That way, it should work for anyone who needs it.

  • Like 1
Posted

Thanks I opened a bug.  I Did also try editing the python and it got further log says made a node but no node actually appears.  My guess is the plugin is orphaned given the python issue just kinda gives the feeling of nobody is using it.

Posted

Not really orphaned, just low priority and difficult to debug as I'm not the original author of the plug-in and it does depend on the external library for all the interaction with the Roomba.   

Since that external library was developed without any documentation or support from Roomba, it is also possible that Roomba has updated the firmware so that it no longer works.

The external library hasn't been updated in about 4 years except for one minor change and I've added that one change and it didn't make any difference.

I'll spend some more time and see if I can track down the issue.

Posted

I managed to find a couple of things and it seems to be working for me now.

First, it looks like the newer OpenSSL liibs now being used on eisy/Polisy block the security methods Roomba uses and I wasn't able to get a connection to the Roomba.  I found a workaround for that overrides the block and that allows it to connect and I was getting data from the Roomba.

At some point the external library being used switch to an asyncio based library but plug-ins are not asyncio.  This means you have to some modifications in the plug-in to properly call the asyncio based functions in the library.  I had already make most of those changes.  But there was one place I didn't have it right and it was hanging in the initialization code where it waits for the Roomba to send out the updates to get the full state of the Roomba.

Once I fixed that, the node was created and I think it's working.  However, there still could be places where I don't have proper code in there to access the asyncio functions.

Version 2.0.8 should be in the store now. 

Posted

Thanks for the update.  I have tried to update the plugin but it never really updated the roomba plugin.  Finally just deleted the old one and reinstalled.  that worked and now I am running 2.0.8.

However when trying to connect the Roomba device I still see the following error in the log:

 
2025-10-09 22:01:25.678 Thread-5 (handleConfigDone) udi_interface INFO roomba-poly:getPassword: start password discovery
2025-10-09 22:01:25.679 Thread-5 (handleConfigDone) udi_interface INFO roomba-poly:getPassword: Connecting to 10.100.100.142 on port 8883
2025-10-09 22:01:26.150 Thread-5 (handleConfigDone) udi_interface ERROR roomba-poly:getPassword: Failed to connect to robot: [SSL: UNSAFE_LEGACY_RENEGOTIATION_DISABLED] unsafe legacy renegotiation disabled (_ssl.c:1016)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...