frawau / aiozeroconf

An asyncio/pure python implementation of multicast DNS service discovery
GNU Lesser General Public License v2.1
24 stars 6 forks source link

Efficiency with ServiceBrowser and many service types #15

Closed Kane610 closed 5 years ago

Kane610 commented 5 years ago

Hi!

I'm in the middle of using this library as a part of a new zeroconf discovery component for Home assistant (https://github.com/home-assistant/home-assistant/pull/23919). With this new way of configuring zeroconf discovery there is a possibility of a lot more service types being used for discovery than in the previous implementation.

I would like to get your view point of whether it is more efficient to craft some catch all service type method or using a new service browser for each new service type.

/R

frawau commented 5 years ago

Hi, Glad to know you are using this library.

I am not familiar with home-assistant ( I never had time to try it) but as you may have seen, I wrote my own HA system. My system is essentially a message bus with various component publishing and reacting to messages on the bus. In that system I have a "scanning" agent that will use aiozeroconf to locate services. It works like this:

So in this case, I used a new service browser for each service and I only look for needed services.

In my case the user decides which agent to run, and we look for those specific services.

If you want to start agents when a specific service is detected, I would detect all available services, then run a new service browser for each one, not sure if it is more efficient, but it "feel" cleaner to me.

Again, I am not familiar with the inner workings of Home assistant, but it seems to me that using a "catch all" would make configuration/extension harder.

Hope this helps.

François
Kane610 commented 5 years ago

Thanks for clarifying. I missed the functionality of ZeroconfServiceTypes, that is the other way to do it 👍