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

Ability to use mDNS name and mDNS discovery #38

Open
RoadXY opened this issue Sep 8, 2023 · 10 comments
Open

Ability to use mDNS name and mDNS discovery #38

RoadXY opened this issue Sep 8, 2023 · 10 comments
Assignees
Labels
expensive enhancement expensive enhancement

Comments

@RoadXY
Copy link
Collaborator

RoadXY commented Sep 8, 2023

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.

@RoadXY RoadXY added the enhancement New feature or request label Sep 8, 2023
@Baldhor
Copy link
Owner

Baldhor commented Sep 8, 2023

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
Copy link
Collaborator Author

RoadXY commented Sep 8, 2023

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
Copy link
Owner

Baldhor commented Sep 8, 2023

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

@Baldhor
Copy link
Owner

Baldhor commented Sep 8, 2023

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

@Baldhor Baldhor changed the title Ability to use mDNS name Ability to use mDNS name and mDNS discovery Sep 8, 2023
@RoadXY
Copy link
Collaborator Author

RoadXY commented Sep 8, 2023

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
Copy link
Collaborator Author

RoadXY commented Sep 8, 2023

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
Copy link
Owner

Baldhor commented Oct 11, 2023

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
Copy link
Owner

Baldhor commented Oct 12, 2023

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

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

It depends of the current state of the physical device

  1. 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

  1. 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
Copy link
Owner

Baldhor commented Oct 12, 2023

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
Copy link
Owner

Baldhor commented Oct 12, 2023

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

@Baldhor Baldhor self-assigned this Oct 12, 2023
@Baldhor Baldhor added expensive enhancement expensive enhancement and removed enhancement New feature or request labels Oct 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
expensive enhancement expensive enhancement
Projects
None yet
Development

No branches or pull requests

2 participants