Domi04151309 / HomeApp

HomeApp is a small and easy to use smart home app with a simple framework.
https://f-droid.org/packages/io.github.domi04151309.home/
GNU General Public License v3.0
106 stars 24 forks source link

Add mDNS discovery for SimpleHome devices #42

Closed cweiske closed 2 years ago

cweiske commented 2 years ago

(Continuation of #39 which was closed in error)

With that in place, devices can use avahi-daemon to get their SimpleHome API services automatically discovered by HomeApp.

Example avahi daemon service file:

<?xml version="1.0"?>
<service-group>
  <name>Lamps for HomeApp</name>
  <service protocol="ipv4">
    <type>_simplehome._tcp</type>
    <port>80</port>
    <txt-record>url=http://simpleapi-homeapp.example.org/</txt-record>
  </service>
</service-group>

The TXT record with "url" property is optional. If not specified, the IP address of the server will be used by HomeApp.

Specifying the url lets you announce multiple services on the same host.

Domi04151309 commented 2 years ago

I think it would be a better idea to use _http._tcp for simple home devices too so that no additional discovery has to be started.

cweiske commented 2 years ago

Shelly v2 devices support discovery via _shelly._tcp, only v1 devices don't. Using an own service type means we're not restricted on what names we may use.

Also on the network level, a single mDNS discovery request may contain multiple service type requests at once. Unfortunately the Android API doesn't support this yet :)

cweiske commented 2 years ago

In short: I'd like to do the right thing, and not optimize for "least number of discovery processes".

Domi04151309 commented 2 years ago

Is it possible to use only one instance of DnsDiscoveryListener?

cweiske commented 2 years ago

Unfortunately not. I'll get an exception that the listener is already in use.