Discovery not working in 0.33.1

All,

I’ve used the discovery: feature in my HA install running on RPi without issue, but I’ve had it disabled for a while. I enabled it today, and I get the following error in the logs:

Exception in thread Thread-9:
Traceback (most recent call last):
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/home/homeassistant/.homeassistant/deps/netdisco/service.py", line 59, i
  File "/home/homeassistant/.homeassistant/deps/netdisco/service.py", line 59, in run
    self._scan()
  File "/home/homeassistant/.homeassistant/deps/netdisco/service.py", line 73, i
  File "/home/homeassistant/.homeassistant/deps/netdisco/service.py", line 73, in _scan
    self.discovery.scan()
  File "/home/homeassistant/.homeassistant/deps/netdisco/discovery.py", line 62,
  File "/home/homeassistant/.homeassistant/deps/netdisco/discovery.py", line 62, in scan
    self.samsungac.scan()
  File "/home/homeassistant/.homeassistant/deps/netdisco/samsungac.py", line 35,
  File "/home/homeassistant/.homeassistant/deps/netdisco/samsungac.py", line 35, in scan
    self.update()
  File "/home/homeassistant/.homeassistant/deps/netdisco/samsungac.py", line 74,
  File "/home/homeassistant/.homeassistant/deps/netdisco/samsungac.py", line 74, in update
    sock.bind(('', DISCOVERY_PORT))
OSError: [Errno 98] Address already in use

There’s nothing else running on the RPi, so I’m not sure what else would be using the address (or which port it’s trying to bind to so I can verify).

Thanks!
Roddie

Getting the same on my docker setup

This doesn’t help me, but Docker has a caveat on the discovery page that might help you:

Home Assistant must be on the same network as the devices for uPnP discovery to work. If running Home Assistant in a Docker container use switch --net=host to put it on the host’s network.

I ran into this issue and did some debugging to figure out what was going on.

For my case, it was the fact that the Hue Emulator and the Samsung AC discovery were both trying to open the same port.

The Hue Emulator was well behaved, but the Samsung AC wasn’t opening the port in a way that they could share. I actually submitted a patch to netdisco, but I think they plan to just disable the Samsung AC discovery until someone can make it bulletproof.

Here’s a link to my patch, if you’re curious: https://github.com/home-assistant/netdisco/pull/66

Ah, that makes sense, since I have probably turned on Hue Emulation since the last time I tried a discovery.

Is there a quick/easy way to implement the patch or should I just wait for the netdisco update?

Thanks!

The change has already been merged in, so you just have to wait for the next release 0.33.3.

The other option would be to edit /home/homeassistant/.homeassistant/deps/netdisco/samsungac.py directly, adding the middle line here at line 72:

    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) # add this line
    sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)

If someone other than roddie wants to do this way, you’ll have to find your samsungac.py location in your logs where the exception is thrown. (e.g. docker is located at “/usr/local/lib/python3.5/site-packages/netdisco/samsungac.py”)

Seems 0.33.3 is out now, so probably upgrading is your best bet!

Worked like a charm - Thanks for the help!