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

[mqtt] allow disabling discovery #8077

Merged
merged 3 commits into from Jul 23, 2020
Merged

[mqtt] allow disabling discovery #8077

merged 3 commits into from Jul 23, 2020

Conversation

J-N-K
Copy link
Member

@J-N-K J-N-K commented Jul 4, 2020

Fixes #8056

This adds a parameter to the broker to disable discovery. By default this is set to false (so discovery is enabled), which is the same behaviour like before.

Signed-off-by: Jan N. Klug jan.n.klug@rub.de

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
@J-N-K J-N-K added the enhancement An enhancement or new feature for an existing add-on label Jul 4, 2020
@J-N-K J-N-K requested a review from davidgraeff as a code owner July 4, 2020 18:44
@TravisBuddy
Copy link

Travis tests were successful

Hey @J-N-K,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

@kaikreuzer
Copy link
Member

This all sounds fishy to me, so please let me try to understand the real issue first.

In general:

  • Every discovery service can be deactivated using the discovery.<id> pid.
  • Discovery services should just silently operate and if there is nothing relevant for them to be seen, they must not cause any errors or side effects.

If those two statements are taken into account, I would assume there would not be any problem with #8056, is this correct?
If so, I would claim that we rather need a bug fix instead of introducing a feature as a workaround.

@J-N-K
Copy link
Member Author

J-N-K commented Jul 12, 2020

The problem seems to be that the discovery service „silently“ listens to what is sent by the broker. This requires a subscription to a topic or a group of topics. Some brokers close the connection if they receive subscriptions for topics they don’t support (IMO broken, but out of our range to fix). So the only solution is to prevent subscription to „unwanted“ topics on these brokers and that requires disabling discovery. But only for that broker, not in general (there might be a second broker used for homie devices).

@kaikreuzer
Copy link
Member

Ok, thanks for the explanation.
It feels a bit weird to have double-negation here: Enabling this flag disables a feature - it would imho be cleaner to have a flag "discovery", which can be enabled (true) and disabled (false), where the default setting would be true. I don't insist on it, but wanted to raise it. Wdyt?

@J-N-K
Copy link
Member Author

J-N-K commented Jul 22, 2020

Agreed. I‘ll change to „discoveryEnabled“ with a default „true“, so nothing changes for users.

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
@TravisBuddy
Copy link

Travis tests were successful

Hey @J-N-K,
we found no major flaws with your code. Still you might want to look at this logfile, as we usually suggest some optional improvements.

By default discovery services (like homie or homeassistant) are enabled on a broker.
This behaviour can be controlled with a configuration parameter.

* __enableDiscovery__:If set to true, enables discovery on this broker, if set to false, disables discovery services om this broker.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* __enableDiscovery__:If set to true, enables discovery on this broker, if set to false, disables discovery services om this broker.
* __enableDiscovery__:If set to true, enables discovery on this broker, if set to false, disables discovery services on this broker.

@@ -50,6 +50,7 @@
protected final MqttService service;

protected String brokerID = "";
protected boolean discoveryDisabled = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still saying "disabled" here

@@ -181,6 +187,12 @@
<label>Broker ID</label>
<description>Each system wide configured MQTT broker has a unique broker ID.</description>
</parameter>
<parameter name="disableDiscovery" type="boolean">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still saying "disable" here

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
@kaikreuzer kaikreuzer added this to the 2.5.8 milestone Jul 23, 2020
@kaikreuzer kaikreuzer merged commit ba915f4 into openhab:2.5.x Jul 23, 2020
CSchlipp pushed a commit to CSchlipp/openhab-addons that referenced this pull request Jul 26, 2020
* allow disabling discovery

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: CSchlipp <christian@schlipp.de>
@J-N-K J-N-K deleted the mqtt-onoff branch August 1, 2020 15:17
MPH80 pushed a commit to MPH80/openhab-addons that referenced this pull request Aug 3, 2020
* allow disabling discovery

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: MPH80 <michael@hazelden.me>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
* allow disabling discovery

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
* allow disabling discovery

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
* allow disabling discovery

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
andrewfg pushed a commit to andrewfg/openhab-addons that referenced this pull request Aug 31, 2020
* allow disabling discovery

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
DaanMeijer pushed a commit to DaanMeijer/openhab-addons that referenced this pull request Sep 1, 2020
* allow disabling discovery

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
Signed-off-by: Daan Meijer <daan@studioseptember.nl>
markus7017 pushed a commit to markus7017/openhab-addons that referenced this pull request Sep 19, 2020
* allow disabling discovery

Signed-off-by: Jan N. Klug <jan.n.klug@rub.de>
@openhab-bot
Copy link
Collaborator

This pull request has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/integrate-dyson-pure-cool-link/40416/92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[mqtt] Cannot connect to TheThingsNetwork because of HomeAssistant discovery
4 participants