BoschSmartHome / bosch-shc-api-docs

Bosch Smart Home Controller Local REST API
Other
208 stars 44 forks source link

Provide unique id of SHC in public information #39

Closed tschamm closed 3 years ago

tschamm commented 3 years ago

It would be great if it would be possible to provide a unique id (e.g. mac address or serial number) of the SHC via an API call, e.g. using "smarthome/public/information". This would allow other applications to identify the SHC, even if the IP has changed.

hxmelab commented 3 years ago

Via a multicast DNS (mDNS) you get the ip and mac address and in case the ip changes you could repeat mDNS, search for the mac address and you will find your SHC in your local network. Check this line of code for the mDNS message, all SHCs are responding to: https://github.com/hxmelab/node-red-contrib-bosch-shc/blob/13fd565f083dc597c8e2f2e8b63d8324d6b1d402/nodes/shc-config.js#L165

tschamm commented 3 years ago

Thanks hxmelab for pointing out using mDNS discovery. I will use this for my implementation, but gathering unique information via the API would still be more straight forward. Maybe this is not such a big deal to support in the future.

tschamm commented 3 years ago

Using mDNS discovery fails in some network. I have implemented a fallback to retrieve the mac_address via the given ip, but that may be still error prone depending on the network configuration. Considering robustness, providing unique information (e.g. mac_address or serial_number) via the API is still missing.

sebastianharder commented 3 years ago

@tschamm when the IP of the SHC has changed, how would you call the API? Do you have another mechanism than mDNS to discover the new IP address?

tschamm commented 3 years ago

Of course that's correct. Either mDNS works in your network, or you already know the IP of the SHC to call the API. But if the IP changes over time, how can I know that it is the same SHC I'm talking to. This is why a unique ID via API makes sense. If mDNS is working, the mac address is available. But if mDNS is not working, I'm lost without additional information.

sebastianharder commented 3 years ago

@tschamm do you use multiple SHCs in the same network? If you have paired with one SHC, you will notice that it's a different one when the TLS handshake fails.

Nonetheless, we are considering this enhancement at the moment.

tschamm commented 3 years ago

@sebastianharder Thanks for considering this as enhancement. I do not use multiple SHCs in one network, and I guess that is currently not intended by the way the Smart Home App is designed. Just out of curiousity: Would a TLS handshake really fails, if I would have registered the same keypair on both SHCs?

sebastianharder commented 3 years ago

@tschamm good news! Version 10.0 of the Smart Home Controller firmware will include a field macAddress in the /smarthome/public/information REST resource. It is supposed to be rolled out in May.

tschamm commented 3 years ago

@sebastianharder That's very good news, thanks a lot!