Baldhor / Homey-ESPhome-Enhanced

This is an Homey app which adds support for ESPHome devices. ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems. More information on their homepage: https://www.esphome.io/
GNU General Public License v3.0
4 stars 3 forks source link

Ability to use mDNS name and mDNS discovery #38

Open RoadXY opened 9 months ago

RoadXY commented 9 months ago

Describe the solution you'd like Be able to use the mDNS name instead of the IP address of the device. This has the added benefit that Homey is able to connect to the device when the IP address changes.

Baldhor commented 9 months ago

If I understand how it works, mDNS name can be used if in the first place we use mDNS discovery. However, it must be possible for the user to switch back to a static IP address, just in case his network change.

RoadXY commented 9 months ago

No, not quite. 😉 Let me give you 3 possible ways to add a ESPhome device to Homey.

Using mDNS Service Discovery

  1. User starts ESPHome pairing wizard
  2. Homey starts discovering devices on the local network using mDNS service discovery and Homey should automatically exclude devices which are already added to Homey so only new devices are shown
  3. Homey connects to the device and the device is added

Using mDNS

  1. User starts ESPHome pairing wizard
  2. Homey starts discovering devices on the local network using mDNS service discovery
  3. Since either mDNS SD is blocked by the user (i.e. when using VLAN's) or mDNS SD is disable on their ESPHome devices: no new devices are found
  4. User enters manually the mDNS name (more info on mDNS here: https://en.wikipedia.org/wiki/Multicast_DNS), i.e. slimmelezer.local
  5. Homey connects to the device and the device is added

Using IP address

  1. User starts ESPHome pairing wizard
  2. Homey starts discovering devices on the local network using mDNS service discovery
  3. Since either mDNS SD AND mDNS is blocked by the user (i.e. when using VLAN's) or mDNS SD is disable on their ESPHome devices: no new devices are found
  4. User enters manually the IP address, i.e. 192.168.0.26
  5. Homey connects to the device and the device is added
Baldhor commented 9 months ago

Ok I see, even if mDNS discovery is blocked, mDNS name should still work. IP address would be a last chance solution

Baldhor commented 9 months ago

I was thinking to handle mDNS at the same time as BLE ... but I do not have BLE devices, need money :)

RoadXY commented 9 months ago

Ok I see, even if mDNS discovery is blocked, mDNS name should still work. IP address would be a last chance solution

I think mDNS SD and mDNS are tight together and most of the time both will either work or wont. But theoretically it could be possible that mDNS SD isn't working while mDNS is.

RoadXY commented 9 months ago

I was thinking to handle mDNS at the same time as BLE ... but I do not have BLE devices, need money :)

I understand. This is an feature request so no rush.

By BLE you mean https://esphome.io/components/bluetooth_proxy.html ?

Baldhor commented 8 months ago

So thinking about it, you listed the initial use case in a previous post, but need to consider the hackward use cases :) I have a device connected through IP address/port, I want to switch it to mDNS ... things like that.

My Driver is a Wizard, ... Wizards should be capable of everything ...

Baldhor commented 8 months ago

Ok so I think:

  1. New physical device page will start in discovery mode

    It will offer a "discover" button And list the discored devices if any If a device is selected in the list, it switch to mDNS mode

  2. Edit physical device page will start throught the mDNS or IP/port mode

    It depends of the current state of the physical device

  3. The user can choose at any moment to switch to any mode:

    • discovery
    • mDNS
    • IP/port

      The related fields of each mode will appear as needed

  4. The discovery mode doesn't allow to "apply"

    Only the mDNS and IP/port modes allows it (if all fields are valid as usual)


That's about it ...

I have no idea how encryptionKey or password apply to discovery, need to dig that point a little

Baldhor commented 8 months ago

I have no idea how encryptionKey or password apply to discovery, need to dig that point a little

mDNS is jsut about providing a "stable name" that match an "unstable ipAddress/port".

In the end the connection to the physical device is still based on the ipAddress/port and so encryptionKey and password apply.

In Homey, I understand that the mDNS discovery service will run in the background constantly (from the application start). Physical devices for which the mDNS name will be used will be dependant of the discovery to find the ipAddress / port. Only after that, we will be able to connect to the physical device using the low level API.

It also means that if the result from the discovery change, ie. a physical device restart and change IP (and/or port), then we need to force reconnect the physical device.

https://apps.developer.homey.app/wireless/wi-fi/discovery https://apps-sdk-v3.developer.homey.app/DiscoveryResultMDNSSD.html

Baldhor commented 8 months ago

First estimation: about 15h of dev, probably 5h of test and same for debug. => 25h ...