esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
413 stars 26 forks source link

Zeroconf custom component for ESPHome with support to use DNS TXT records for passing setting parameters to integration config flows #1227

Open Hedda opened 3 years ago

Hedda commented 3 years ago

Describe the problem you have/What new integration you would like

Firstly suggest separate Zeroconf and mDNS service to make a Zeroconf custom component for ESPHome as thegroove started work on that here -> https://github.com/thegroove/esphome-zeroconf

Secondly suggest implementing use of DNS TXT records for passing setting parameters to Home Assistant integration config flows.

More information about idea of using DNS TXT records for passing along setting parameters in -> https://github.com/thegroove/esphome-zbbridge/issues/1

Please describe your use case for this integration and alternatives you've tried:

Zeroconf can already be used for basic discovery of a ESPHome based serial gateway/bridge, see https://github.com/home-assistant/core/pull/48420 which is used to discover Tube's Zigbee coordinators in Home Assistant's ZHA integration -> https://github.com/tube0013/tube_gateways

Note that even though discovery work it does not yet pass along parameters via txt records to config flow as requested in https://github.com/thegroove/esphome-zbbridge/issues/1

DNS TXT records could be used to pass along recommended settings parameters config flow to Home Assistant's ZHA integration:

Zeroconf DNS TXT records could also be used to discover hostnames, service version, location, MAC address, and more, etc..

Additional context

FYI, thegroove plans on using this his ESPHome builds for Sonoff ZBBrige -> https://github.com/thegroove/esphome-zbbridge

For reference regarding ESPHome as a serial gateway with Zeroconf see https://github.com/tube0013/tube_gateways and https://github.com/esphome/feature-requests/issues/688

Hedda commented 3 years ago

DNS-SD (Rendezvous) TXT record format -> http://www.zeroconf.org/Rendezvous/txtrecords.html

Example TXT record containing three name/value pairs


| 0x0A | name=value | 0x08 | paper=A4 | 0x12 | Rendezvous Is Cool |

Zeroconf DNS-SD (DNS Service Discovery) should be able to pass additional attributes such as config parameters via "TXT records".

https://en.wikipedia.org/wiki/Zero-configuration_networking#DNS-based_service_discovery

"Each service instance is described using a DNS SRV and DNS TXT record. A client discovers the list of available instances for a given service type by querying the DNS PTR record of that service type's name; the server returns zero or more names of the form ., each corresponding to a SRV/TXT record pair. The SRV record resolves to the domain name providing the instance, while the TXT can contain service-specific configuration parameters."

https://en.wikipedia.org/wiki/Zero-configuration_networking#DNS-SD_with_multicast

"DNS Service Discovery (DNS-SD) requests can also be sent using mDNS to yield zero-configuration DNS-SD. This uses DNS PTR, SRV, TXT records to advertise instances of service types, domain names for those instances, and optional configuration parameters for connecting to those instances. But SRV records can now resolve to .local domain names, which mDNS can resolve to local IP addresses."

https://en.wikipedia.org/wiki/TXT_record

"TXT record (short for text record) is a type of resource record in the Domain name system (DNS) used to provide the ability to associate arbitrary text with a host or other name, such as human readable information about a server, network, data center, or other accounting information. It is also often used in a more structured fashion to record small amounts of machine-readable data into the DNS."