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.homeassistant] Fix binding crash when home assistant discovery topics update with content #13518

Merged

Conversation

ssalonen
Copy link
Contributor

@ssalonen ssalonen commented Oct 8, 2022

Fixes #13517
Possibly resolves #9711 and #12295 as well.

The implementation does not handle updating discovery topics -- when the content is not exactly the same. Example of real life scenario documented in #13517 with OpenMQTTGateway. To be honest, I am not sure if there are other kind of situations when we might hit this error.

This fix ensures that conflicting channels are first removed, and only then we add new channels. This means that more recent discovery data always overrides older... at least when it comes to channels.

Signed-off-by: Sami Salonen ssalonen@gmail.com

Fixes openhab#13517
Possibly resolves openhab#9711 and openhab#12295 as well.

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
@ssalonen ssalonen changed the title [mqtt.homeassistant] Fix for discovery topics that update with content [mqtt.homeassistant] Fix binding crash when home assistant discovery topics update with content Oct 8, 2022
Signed-off-by: Sami Salonen <ssalonen@gmail.com>
@ssalonen
Copy link
Contributor Author

ssalonen commented Oct 8, 2022

I believe I picked this pattern of recreating thing with list of channels from some other binding.

Is it ok? Or are there side effects eg to links?

I have not tested this with full setup, only unit tests

@lolodomo lolodomo added the bug An unexpected problem or unintended behavior of an add-on label Oct 9, 2022
@ssalonen
Copy link
Contributor Author

ssalonen commented Oct 9, 2022

Tested with mqtt.generic 3.4.0-SNAPSHOT https://github.com/ssalonen/openhab2-addons/releases/tag/mqtt-homeassistant-b2e6c55 succesfully, seems to work fine

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
@lolodomo lolodomo added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Oct 10, 2022
@lolodomo
Copy link
Contributor

lolodomo commented Nov 5, 2022

@antroids : would you like to review that change ?

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
@antroids
Copy link
Contributor

antroids commented Nov 5, 2022

@antroids : would you like to review that change ?

Yes, looks interesting, let me check.
I'll do it today or tomorrow.

Copy link
Contributor

@lolodomo lolodomo left a comment

Choose a reason for hiding this comment

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

LGTM

@lolodomo
Copy link
Contributor

lolodomo commented Nov 5, 2022

Waiting for @antroids review before merging.

Copy link
Contributor

@antroids antroids left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good. Just two minor issues found.
It would be better to create two different PRs next time: one with Bug fix and one with refactoring.

Co-Authored-by: @antroids github handle

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
Signed-off-by: Sami Salonen <ssalonen@gmail.com>
@lolodomo lolodomo merged commit a1270c7 into openhab:main Nov 12, 2022
@lolodomo lolodomo added this to the 3.4 milestone Nov 12, 2022
@lolodomo
Copy link
Contributor

Thank you @ssalonen and @antroids

andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Dec 24, 2022
…topics update with content (openhab#13518)

* [mqtt.homeassistant] Fix for discovery topics that update with content

Fixes openhab#13517
Possibly resolves openhab#9711 and openhab#12295 as well.

* [mqtt.homeassistant] Sort channels before changing thing
* [mqtt.homeassistant] logging + removed unnecessary synchronization
* Resolve bunch of warnings in homeassistant bundle
* [mqtt.homeassistant] Handling null warnings and unnecessary null checks
* [mqtt.homeassistant] Removing unnecessary null checks

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
Co-Authored-by: @antroids github handle
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
borazslo pushed a commit to borazslo/openhab-mideaac-addon that referenced this pull request Jan 8, 2023
…topics update with content (openhab#13518)

* [mqtt.homeassistant] Fix for discovery topics that update with content

Fixes openhab#13517
Possibly resolves openhab#9711 and openhab#12295 as well.

* [mqtt.homeassistant] Sort channels before changing thing
* [mqtt.homeassistant] logging + removed unnecessary synchronization
* Resolve bunch of warnings in homeassistant bundle
* [mqtt.homeassistant] Handling null warnings and unnecessary null checks
* [mqtt.homeassistant] Removing unnecessary null checks

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
Co-Authored-by: @antroids github handle
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
…topics update with content (openhab#13518)

* [mqtt.homeassistant] Fix for discovery topics that update with content

Fixes openhab#13517
Possibly resolves openhab#9711 and openhab#12295 as well.

* [mqtt.homeassistant] Sort channels before changing thing
* [mqtt.homeassistant] logging + removed unnecessary synchronization
* Resolve bunch of warnings in homeassistant bundle
* [mqtt.homeassistant] Handling null warnings and unnecessary null checks
* [mqtt.homeassistant] Removing unnecessary null checks

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
Co-Authored-by: @antroids github handle
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Feb 28, 2023
…topics update with content (openhab#13518)

* [mqtt.homeassistant] Fix for discovery topics that update with content

Fixes openhab#13517
Possibly resolves openhab#9711 and openhab#12295 as well.

* [mqtt.homeassistant] Sort channels before changing thing
* [mqtt.homeassistant] logging + removed unnecessary synchronization
* Resolve bunch of warnings in homeassistant bundle
* [mqtt.homeassistant] Handling null warnings and unnecessary null checks
* [mqtt.homeassistant] Removing unnecessary null checks

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
Co-Authored-by: @antroids github handle
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Jan 6, 2024
…topics update with content (openhab#13518)

* [mqtt.homeassistant] Fix for discovery topics that update with content

Fixes openhab#13517
Possibly resolves openhab#9711 and openhab#12295 as well.

* [mqtt.homeassistant] Sort channels before changing thing
* [mqtt.homeassistant] logging + removed unnecessary synchronization
* Resolve bunch of warnings in homeassistant bundle
* [mqtt.homeassistant] Handling null warnings and unnecessary null checks
* [mqtt.homeassistant] Removing unnecessary null checks

Signed-off-by: Sami Salonen <ssalonen@gmail.com>
Co-Authored-by: @antroids github handle
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of an add-on
Projects
None yet
3 participants