itead / Sonoff_Devices_DIY_Tools

BSD 3-Clause "New" or "Revised" License
548 stars 168 forks source link

Make device uniquely identifiable via the API #58

Closed frenck closed 4 years ago

frenck commented 4 years ago

Currently, the deviceid is only published via mDNS, there is no way to get it via the API. Hence, without mDNS, there is no way to uniquely identify the device.

This causes problems for platforms, like Home Assistant, to manage multiple devices on a single network. A device has to be uniquely identifiable on the network, even without mDNS.

Suggestion: Add deviceid to the zeroconf/info response.

Daniel-zhan-itead commented 4 years ago

A device has to be uniquely identifiable on the network, you have some ways to get it

  1. the hostname
  2. the id in txtrecord
  3. IP address

As sonoff device uses the mDNS protocol to discover the device, without the mDNS, how do you find the device in the network?

frenck commented 4 years ago

hostname & IP addresses are not properties of the device and therefore not a unique identifier of the device. For example, I can log in to my router, and change the IP address & hostname via the DHCP configuration. In conclusion, it is not a device identification, but a network identification of the device, which is not what I requested.

The ID is the TXT record is only available via mDNS, which is not a reliable source for home automation in general, for several reasons:

In conclusion of the above, hostname & IP are not device identifiers but network properties. The device ID is currently only available via mDNS, which is not guaranteed to be available.

Hence, I'm looking for a reliable fallback method to obtain a unique device ID and thus request it to add a method to obtain it via the HTTP API.

As sonoff device uses the mDNS protocol to discover the device, without the mDNS, how do you find the device in the network?

Asking the user for it? We are talking about a DIY mode here, not about an app on a phone. A home automation platform can try to discover things on the network, but should also be able to accept manually configured devices by a user in case auto-discovery failed.

Daniel-zhan-itead commented 4 years ago

Hi Frenck,

the New DIY Mode has been released, the deviceid has been added in zeroconf/info.

Daniel

frenck commented 4 years ago

Great, that close this issue 👍