-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[hue] Fix NUPnP discovery #14871
[hue] Fix NUPnP discovery #14871
Conversation
Please consider this for being backported to 3.4.x. |
54afadb
to
12a9d5c
Compare
Fixes openhab#14852 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
12a9d5c
to
49cbb14
Compare
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@jlaur / @lolodomo as with all ongoing PRs for this binding, your #14871 is merged into my #13570 .. however I have a question for you both concerning that.. Background: when mDNS discovery is used, then the discovery service checks if the respective bridge supports API v2 (it makes an API v2 GET call which return 200 OK if API v2 is supported). And if it is supported it puts an API v2 thing in the inbox (and NOT a legacy API v1 thing). Reason is that for newly discovered things it is better for the user to start with the new technology and not the legacy. Now that you have re-enabled NUPnP discovery via this PR, the (legacy) mechanism once more puts a legacy thing in the inbox. So now if the bridge supports API v2, the mDNS discovery puts a v2 thing in the inbox, and the legacy NUPnP discovery puts a second (legacy) thing in the inbox. The risk of this is that the user might click on the legacy bridge thing, and start creating a whole system based mistakenly on legacy stuff. There are two possible solutions..
I suppose 1. is the right answer, but perhaps you can confirm? Note in case of 1. if the bridge really does not support API v2 then a legacy thing will anyway be placed in the inbox (via either mDNS or NUPnP or both). |
In fact, I am not sure what is and what was the interest of the NUPnP cloud discovery ? |
By the way, we need to include again the UPnP discovery class (removed in OH3) as there is no more discovery of old bridge with the current code. I hope the old bridge will still expose itself through UPnP. |
It was not disabled, it was broken - and by that of course indirectly disabled.
See #14852 (comment) - asking the same question. I don't understand why we have an implementation of cloud discovery when the binding works locally and we have local discovery options. So I would opt for completely removing the NUPnP discovery, unless someone steps up and explains why there would be a need for this. |
In the meantime I made this commit but we can revert it later if you wish..
Good point. The following is not directly related to discovery, but may nevertheless be relevant.. Currently there are two ways to authenticate OH on the bridge -- namely locally (press button on hub) to get an application key, and via cloud V1 OAuth2 authentication. Philips / Signify implies that a local application key is not very secure, and they imply that better security can be had from using OAuth2 cloud authentication. Notwithstanding this, Philips / Signify have just announced that V1 OAuth2 will be discontinued on July 1st 2023 and say 'in the future there will be another way to authorize on the V2 API'. So, I interpret all of this to mean that Philips / Signify is planning to introduce some API v2 OAuth2 cloud based work flow with a username and password whereby the application key would probably become time limited in some way. This all just for info.. https://developers.meethue.com/v1-oauth2-to-be-disabled-on-july-1-2023/ EDIT: 4yi I have not implemented API v2 OAuthV2 in my PR because, I don't really understand how OAuth2 works :( |
Afair the history, the reason for the introduction was that it there were quite some users where local UPnP discovery didn't work as expected - be it due to different local subnets, blocked UPnP services IPv6 or whatsoever. So the as the cloud discovery was offered by Philips (and the hue app was using it as a fallback as well), this was also implemented in openHAB as a secondary discovery option. |
Thanks for sharing this, @kaikreuzer. So we should keep this. |
I will run Device Spy on mine, and let you know what I get. |
Ok so UPnP is still available for recent bridges. In that case, I have to apply a filter. |
I submitted a PR. Of course it is tested and working with a bridge V1. And it is expected to not discover bridge V2. I can see that the model id retrieved from API is BSB001 in my case (the modelId property is updated when the binding starts) while "Model number" in UPnP discovery is a different value. |
There might be problems if they would release a new bridge with a model number not starting with B. So perhaps do a Regex search for a year in model name, and only search if it is below 2015? |
Done, I believe it is a better option. |
Getting back to NUPnP as "secondary" discovery option, I noticed that the label for the discovery result changed back and forth when scanning (XXXXXX is last 6 characters of the serial number):
I added some more logging:
So it seems that the two discovery results are fighting. It shouldn't be a real issue except the flickering caused by the label switching. It should be possible to make the labels consistent, I'll have a look at that. FYI @kaikreuzer, @lolodomo, @andrewfg |
Good point. Obviously the most important thing is the representationProperty which must be identical otherwise othwerwise one gets two things 'flickering' rather than one thing with its label 'flickering.. |
But I believe the configuration parameters should also be the same ? |
Hmm. I don't think so -> https://www.openhab.org/docs/developer/bindings/thing-xml.html#representation-property-and-discovery EDIT: oops -- I see this "and both the properties and the configuration parameters of existing Things" |
@jlaur there is unfortunately still a bug here. As you know I synchronized your PR into my own API v2 PR, and two of the people who are running that version reported that the nupnp discovery crashes with the stack trace shown below. The issue is that the One of the two users also cross checked it by opening the
|
This pull request has been mentioned on openHAB Community. There might be relevant details there: https://community.openhab.org/t/hue-binding-with-added-support-for-api-v2/146648/10 |
Thanks, fixed in #14989. |
* Fix NUPnP discovery Fixes openhab#14852 * Declare hybrid connection due to cloud discovery --------- Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Matt Myers <mmyers75@icloud.com>
Fixes #14852
Regression of #11842