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

AttributeError: 'ServiceInfo' object has no attribute 'address' #253

Open
tomk235 opened this issue Feb 16, 2021 · 4 comments
Open

AttributeError: 'ServiceInfo' object has no attribute 'address' #253

tomk235 opened this issue Feb 16, 2021 · 4 comments

Comments

@tomk235
Copy link

tomk235 commented Feb 16, 2021

  • pySonoffLAN version: version 1.1.4
  • Python version: Python 3.9.1
  • Operating System: ubuntu

Description

pysonofflanr3 --host [my_sonoff_ip] -l DEBUG --api_key [mytotallysecretkey] --device_id [and_its_device_id] state
or
pysonofflanr3 discover

bring up the error:

root@[machine]:/usr/src/app# pysonofflanr3 discover
2021-02-16 19:30:17,651 - info: Attempting to discover Sonoff LAN Mode devices on the local network, please wait...
Exception in thread zeroconf-ServiceBrowser__ewelink._tcp.local._82:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1755, in run
self._service_state_changed.fire(
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1513, in fire
h(**kwargs)
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1611, in on_change
listener.add_service(*args)
File "/usr/local/lib/python3.9/site-packages/pysonofflanr3/discover.py", line 40, in add_service
ip = utils.parseAddress(info.address) + ":" + str(info.port)
AttributeError: 'ServiceInfo' object has no attribute 'address'


or the error:

root@[machine]:/usr/src/app# pysonofflanr3 --host [my_sonoff_ip] -l DEBUG --api_key [the_secret_key] --device_id [the_id] state
2021-02-16 19:27:02,510 - info: Initialising SonoffSwitch with host 172.23.8.158
2021-02-16 19:27:02,510 - debug: Initializing SonoffLANModeClient class in SonoffDevice
2021-02-16 19:27:02,511 - debug: enter send_availability_loop()
2021-02-16 19:27:02,512 - debug: waiting for connection
2021-02-16 19:27:02,512 - debug: send_updated_params_loop is active on the event loop
2021-02-16 19:27:02,512 - debug: Starting loop waiting for device params to change
2021-02-16 19:27:02,512 - debug: send_updated_params_loop now awaiting event
2021-02-16 19:27:02,632 - info: Service type _ewelink.tcp.local. of name eWeLink[some_id]._ewelink._tcp.local. added
Exception in thread zeroconf-ServiceBrowser__ewelink._tcp.local._31:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1755, in run
self._service_state_changed.fire(
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1513, in fire
h(**kwargs)
File "/usr/local/lib/python3.9/site-packages/zeroconf/init.py", line 1611, in on_change
listener.add_service(*args)
File "/usr/local/lib/python3.9/site-packages/pysonofflanr3/client.py", line 154, in add_service
self.update_service(zeroconf, type, name)
File "/usr/local/lib/python3.9/site-packages/pysonofflanr3/client.py", line 166, in update_service
found_ip = utils.parseAddress(info.address)
AttributeError: 'ServiceInfo' object has no attribute 'address'


What I Did

pysonofflanr3 discover
pysonofflanr3 --host [my_sonoff_ip] -l DEBUG --api_key [the_secret_key] --device_id [the_id] state

Solution

change "found_ip = utils.parseAddress(info.address)" to
found_ip = utils.parseAddress(info.addresses[0])
in those files:
joe /usr/local/lib/python3.9/site-packages/pysonofflanr3/discover.py line 40
joe /usr/local/lib/python3.9/site-packages/pysonofflanr3/client.py line 119 & line 166

as zeroconf has changed its api from deprecated address to addresses

@gulp79
Copy link

gulp79 commented Feb 19, 2021

Thank you, i've had the same problem, resolved with yours changes.

@camelcamro
Copy link

pls can someone tell this to master of "pysonofflanr3"

as there are other users which can'T see that in the WIKI ...
and that is a showstopper when someone is using the newest sources ...

thx

@Teiby
Copy link

Teiby commented Oct 14, 2023

Thanks for the solution. Guess this will never ever be fixed.

@dauheeIRL
Copy link

I have used the library to build https://github.com/dauheeIRL/SonoffSimpleLAN which currently works

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

No branches or pull requests

5 participants