thegroove / esphome-zeroconf

ESPHome component to advertise Zeroconf services over mDNS
4 stars 6 forks source link

[REQUEST] Send unique device identifier + project info via Zeroconf for mDNS discovery #2

Open Hedda opened 3 years ago

Hedda commented 3 years ago

Request ESPHome to send out unique device ID on its Zeroconf broadcast like example project name + the MAC address of device.

Copy of old request https://github.com/esphome/feature-requests/issues/575

thegroove commented 3 years ago

As Frenck mentioned in the linked feature request, ESPHome now adds the mac address in its zeroconf announcement:

= enp7s0 IPv4 tube_zb_gw_cc2652p2                           _esphomelib._tcp     local
   hostname = [tube_zb_gw_cc2652p2.local]
   address = [172.16.0.98]
   port = [6053]
   txt = ["version=1.17.0" "address=tube_zb_gw_cc2652p2.local" "mac=aaaa1234nnnn999"]

This is new functionality, starting from 1.17.0, I think. However, this applies to the esphomelib service announcement (which is separate and not configurable by my component). It is just a txt attribute, though, so adding some sort of ID field is already possible through configuration. What is not possible right now, however, is templating the value of a txt attribute. The mac address can be obtained programmatically in esphome, with a lambda snippet, but I need to figure out how to add templatability to those in my component, so it can be used to dynamically fill a txt attribute value -- work in progress. In the meantime one can manually enter the mac, but of course that's boring.

Hedda commented 3 years ago

FYI, HA devs announced latest ESPHome added the new standard for project identifier, version + more via the mDNS discovery info:

https://www.home-assistant.io/blog/2021/06/16/power-up-your-esp-projects/#esphome-embracing-projects

ESPHome: embracing projects

We want to make it easy for creators to sell ESPHome powered products that offer a great user experience. ESPHome projects embrace local control and integrate nicely with Home Assistant, and so each extra ESPHome product that our users can buy is a win.

To make it easier to keep creators and users connected once a product is installed, projects can now add a project identifier and version to their firmware (docs). With today’s release this information will be available in the device information, logging output and the mDNS discovery info.

The goal is to integrate the projects tighter into the ESPHome dashboard by showing the project’s logo, link to the documentation and issue pages and allow installing updates.

https://www.esphome.io/components/esphome.html#project-information

Project information

"_This allows creators to add the project name and version to the compiled code. It is currently only exposed via the logger, mDNS and the device_info response via the native API. The format of the name should be author_name.project_name._"

# Example configuration
esphome:
  ...
  project:
    name: "tube0013.tube_zb_gw_cc2652p2"
    version: "1.0.0"

PS: This was part of a larger article about making ESP firmware and project more user-friendly and easier to get started with:

https://www.home-assistant.io/blog/2021/06/16/power-up-your-esp-projects/