Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServiceInfo has no attribute 'address' in miio/discovery #891

Closed
gudvinr opened this issue Dec 18, 2020 · 11 comments · Fixed by #898
Closed

ServiceInfo has no attribute 'address' in miio/discovery #891

gudvinr opened this issue Dec 18, 2020 · 11 comments · Fixed by #898
Labels

Comments

@gudvinr
Copy link

gudvinr commented Dec 18, 2020

Describe the bug

When I run mirobo discover it fails with an error.

Version information (please complete the following information):

  • OS: Linux
  • python-miio: 0.5.4 (latest from PIP atm)

To Reproduce
Steps to reproduce the behavior:

  1. run mirobo discover

Expected behavior
Getting a list of discovered devices

Console output

INFO:miio.discovery:Discovering devices with mDNS, press any key to quit...
Exception in thread zeroconf-ServiceBrowser__miio._udp.local._229705:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/home/user/.local/lib/python3.9/site-packages/zeroconf/__init__.py", line 1750, in run
    self._service_state_changed.fire(
  File "/home/user/.local/lib/python3.9/site-packages/zeroconf/__init__.py", line 1508, in fire
    h(**kwargs)
  File "/home/user/.local/lib/python3.9/site-packages/zeroconf/__init__.py", line 1606, in on_change
    listener.add_service(*args)
  File "/home/user/.local/lib/python3.9/site-packages/miio/discovery.py", line 256, in add_service
    addr = str(ipaddress.ip_address(info.address))
AttributeError: 'ServiceInfo' object has no attribute 'address'
@gudvinr gudvinr added the bug label Dec 18, 2020
@elpaso666
Copy link

I have same issue.

@ulope
Copy link

ulope commented Dec 28, 2020

Same issue.

It seems the info object doesn't have an address member but rather addresses which is a list of addresses.

@LukaszLapaj
Copy link

Same issue.

@rytilahti
Copy link
Owner

Looks like the used mdns library changed their API at some point, the simple solution would be making a check if addresses exist, and fallback to using address to keep backwards compatibility. If someone wants to work on that, feel free to create a PR to do that! :-)

@gudvinr
Copy link
Author

gudvinr commented Dec 29, 2020

@rytilahti can't you just pin mdns library version or stick to new addresses field? It was done in this PR and probably was a part of 0.27.0 release.

@rytilahti
Copy link
Owner

@gudvinr fair enough, I suppose porting to use the new API is the way to fix this. I don't usually like breaking something for users who may have previous versions, but as this only affects the discovery I think it's fine.

@ulope
Copy link

ulope commented Dec 30, 2020

A tool like this should always be installed into its own virtualenv anyway.
A good helper for that is pipx

@rytilahti
Copy link
Owner

The problem is, this project is not only for the tool but also for the underlying, fairly widely used (homeassistant, maybe others?) python library. Homeassistant has its own hard dependency pinnings (currently 0.28.7), but this won't be a problem for them, so I'll just merge the linked PR.

@gcamaraomarques
Copy link

Hi @rytilahti,

Any plans to release this fix? I just installed the tool and I am getting the same error.

@rytilahti
Copy link
Owner

Hi @gcamaraomarques, sorry for the delay! I'll do a new release this week, you can follow #969 which will get closed when new release gets made.

@gcamaraomarques
Copy link

No problem at all. It is free and open-source. I just asked because it is already on master.

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants