pysonofflan icon indicating copy to clipboard operation
pysonofflan copied to clipboard

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

Open tomk235 opened this issue 4 years ago • 4 comments

  • 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

tomk235 avatar Feb 16 '21 19:02 tomk235

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

gulp79 avatar Feb 19 '21 13:02 gulp79

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

camelcamro avatar Feb 28 '21 20:02 camelcamro

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

Teiby avatar Oct 14 '23 16:10 Teiby

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

dauheeIRL avatar Oct 14 '23 16:10 dauheeIRL