Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ZiGate-Ethernet.ino with values for Home Assistant ZHA discovery via mDNS Zeroconf #8

Merged
merged 2 commits into from
Mar 15, 2022

Conversation

Hedda
Copy link
Contributor

@Hedda Hedda commented Oct 19, 2021

@fairecasoimeme as per #7 this blind attempt adds missing DNS TXT records values needed for Zeroconf discovery in ZHA.

https://www.home-assistant.io/integrations/zha/#discovery-via-usb-or-zeroconf

Also note that I changed the service name to contain word "zigate" which will be needed as an identifier for ZiGate gateways.

So this is my attempt at updating ZiGate-Ethernet.ino with values for Home Assistant ZHA discovery via mDNS Zeroconf.

Please understand that I own a ZiGate-Ethernet to test it myself so I can not test this (I am just a fan of ZHA's auto-discovery).

This is a back-port of the mDNS code that @xyzroe and @mercenaruss is working on for ZigStar-Gateway firmware (which in turn is a fork of ZiGate-Ethernet firmware):

xyzroe/ZigStarGW-FW#3

https://github.com/xyzroe/ZigStarGW-FW/blob/fd41317584758333786d26592d24b3d90a0e60d2/src/main.cpp#L648-L652

Other than the service name really need to start with "zigate*" as a unique identifier, these values is needed via TXT records:

  • radio_type=zigate
  • baud_rate=115200
  • data_flow_control=software

@fairecasoimeme I assumed ZiGate Zigbee radio uses software flow control but maybe it use hardware or no flow control? Could be that flow control parameter for serial communication needs to be set to hardware or none instead of software?

Anyway; hostname, service, port, are the minimum TXT records needed for Home Assistant ZHA discovery via mDNS Zeroconf.

If wanted could add additional TXT records for information, like version and location, (some ESPHome based gateways do so).

You should be able to test ZiGate results obtained with avahi-browse -a -r so can see that txt format and info looks correct.

Result from avahi-browse -a -r should be compatible with ZHA integration in Home Assistant if they look something like:

_zigate_zigbee_gateway._tcp      local
  hostname = [zigate_zigbee_gateway.local]
  address = [192.168.0.174]
  port = [9999]
  txt = ["radio_type=zigate" "baud_rate=115200" "data_flow_control=software"]

Once those values are available to Zeroconf via DNS TXT records can submit patch for ZiGate-Ethernet to Home Assistant core:

https://github.com/home-assistant/core/blob/dev/homeassistant/generated/zeroconf.py

https://github.com/home-assistant/core/blob/dev/homeassistant/components/zha/manifest.json

See example for "tube*" as used for "domain": "zha" in those two files which could be copied and replaced with zigate info:

https://github.com/home-assistant/core/blob/dev/homeassistant/generated/zeroconf.py#L79

   "_zigate_zigbee_gateway._tcp.local.": [
       {
           "domain": "zha",
           "name": "zigate*"
       }
   ],

https://github.com/home-assistant/core/blob/dev/homeassistant/components/zha/manifest.json#L26

   {
     "type": "_zigate_zigbee_gateway._tcp.local.",
     "name": "zigate*"
   }

Plus think also need to add zigate to ZHA config flow as that currently look to only support ezsp and znp radio types, or?

https://github.com/home-assistant/core/blob/dev/homeassistant/components/zha/config_flow.py#L190

        self._radio_type = (
            RadioType.ezsp.name if "efr32" in local_name else RadioType.znp.name
        )

@doudz Can you maybe help test Conditions and If statements for adding RadioType.zigate.name with another else? Like:

        self._radio_type = (
            RadioType.ezsp.name if "efr32" in local_name else RadioType.zigate.name if "zigate" in local_name else RadioType.znp.name
        )

…ry via mDNS Zeroconf

Update ZiGate-Ethernet.ino with values for Home Assistant ZHA discovery via mDNS Zeroconf. Please note that the service name really needs to start with the word "zigate" as an non-general unique identifier for ZiGate-Ethernet.
No need to add port as TXT for mDNS
@Hedda
Copy link
Contributor Author

Hedda commented Feb 6, 2022

FYI, Zero-configuration networking (zeroconf) looks to have been changed and improved in the Home Assistant 2022.02 release:

home-assistant/core#62133

https://www.home-assistant.io/integrations/zeroconf/

This change is only a concern for custom integration developers.

Currently zeroconf matching only allows matching the macaddress, model, and manufacturer properties along with the name from the ZeroconfServiceInfo.

Since properties are arbitrarily defined by the zeroconf service, the list of named properties has grown over time.

Matching now allows for any arbitrarily defined property. All property matches must be lowercase, wildcards are supported

The top level keys model, manufacturer, and macaddress are now deprecated from components manifest.json file and should be moved into a properties dict.

For example:

-    {"type":"_airplay._tcp.local.","model":"appletv*"}
+    {"type":"_airplay._tcp.local.","properties":{"model":"appletv*"}}

By the way, Home Assistant founders/leads now explicitly said this year they will prioritize focus on features like these types:

https://www.home-assistant.io/blog/2022/01/19/streamlining-experiences/

Check out this video at around 11 min 55 sec in where talk about that focus point about making it easier to get started, etc.

https://www.youtube.com/watch?v=t_2D_KoFIfU&t=710s

Hopefully, it should be a greater chance of getting more help from other Home Assistant developers with this if ask them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants