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

[boschindego] Rewrite to avoid external dependencies #12905

Merged
merged 10 commits into from
Jun 14, 2022

Conversation

jlaur
Copy link
Contributor

@jlaur jlaur commented Jun 7, 2022

This is an overhaul of the Bosch Indego binding in order to get rid of the dependency towards bosch-indego-controller-lib, which seems abandoned and is no longer working after Bosch made some service requirement changes. The library has been reimplemented within the binding using Jetty HTTP client for communication and GSON for JSON serialization/deserialization.

Session handling:

  • Session is now persisted in memory to avoid reauthentication every few minutes and for each command.
  • Session is handled by receiving a Set-Cookie HTTP header when authenticating. The context is then set in a Cookie HTTP header in requests belonging to that session. This is automatically handled by Jetty.
  • As a fallback solution, additionally the HTTP header x-im-context-id is used for sending the session context.
  • If the session would expire before anticipated (max age in cookie), the controller will automatically reauthenticate and retry the failed request.
  • Because additional authentication request is eliminated, commands are now executed a tiny bit faster.

Additional changes:

  • Device command handling has been reworked for improved reliability.
  • REFRESH command is now supported.
  • Serial number has been added as a property.
  • New status code supported: Docked from app/API.
  • Configuration validation.
  • README cleaned up.

Besides these changes under the hood, no functional or breaking changes has been made.

IndegoController contains some currently unused methods (with corresponding DTO's). They were part of the library reimplementation and will most likely be used for new features in subsequent pull requests.

Fixes #7438
Fixes #12720

JAR available for testing: org.openhab.binding.boschindego-3.3.0-SNAPSHOT.jar

@jlaur jlaur added the enhancement An enhancement or new feature for an existing add-on label Jun 7, 2022
@jlaur jlaur force-pushed the 12720-boschindego-rewrite branch 6 times, most recently from f691991 to f67dac7 Compare June 8, 2022 14:37
@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/boschindego-bosch-indego-binding-not-working-any-more/135825/7

@jlaur jlaur marked this pull request as ready for review June 8, 2022 17:18
@jlaur jlaur requested a review from jofleck as a code owner June 8, 2022 17:18
@jlaur jlaur requested a review from a team June 8, 2022 17:18
@jlaur jlaur force-pushed the 12720-boschindego-rewrite branch 3 times, most recently from a622be9 to e8ffb29 Compare June 10, 2022 15:02
jlaur added 3 commits June 10, 2022 20:33
Fixes openhab#12720

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Avoid reauthorization for each command/poll

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
@jlaur jlaur force-pushed the 12720-boschindego-rewrite branch from 4a717c2 to 25a11b5 Compare June 10, 2022 18:34
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
@jlaur jlaur force-pushed the 12720-boschindego-rewrite branch from 7393433 to 592cea7 Compare June 10, 2022 21:17
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
@jlaur
Copy link
Contributor Author

jlaur commented Jun 11, 2022

@lolodomo, @fwolter, @Hilbrand - can one of you review this PR?

I would like it to be ready for 3.3 since the binding is currently not working due to a small change in the service being used. This needed to be fixed in a library used, but unfortunately that library seems abandoned. Therefore I have replaced this by a custom implementation in the binding.

Primary classes to be reviewed are BoschIndegoHandler and IndegoController. Currently most of the DTO classes are unused and untested, so they will be fixed and tested when being adopted later. Used DTO's for supporting existing functionality are:

  • AuthenticationRequest (for authentication)
  • AuthenticationResponse (for retrieving session information)
  • DeviceStateResponse (for retrieving state)
  • SetStateRequest (for sending commands)

I have tested getting state and sending commands myself, and currently the binding doesn't provide any other functionality than that.

After this PR I plan to add new channels providing new functionality, so this PR is to be considered a baseline and bringing the binding back to a working state.

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.

Review part 1

@lolodomo
Copy link
Contributor

Note for myself: remains to review README and classes BoschIndegoHandler and IndegoController.

jlaur added 2 commits June 12, 2022 13:01
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
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.

Review part 2

@jlaur jlaur requested a review from lolodomo June 14, 2022 10:43
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
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.

Review last part

jlaur added 2 commits June 14, 2022 22:10
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
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, thank you

@lolodomo lolodomo merged commit 960be6b into openhab:main Jun 14, 2022
@lolodomo lolodomo added this to the 3.3 milestone Jun 14, 2022
@henrydiesner
Copy link

Great! Now it works!
I've installed the JAR file from https://github.com/jlaur in the 3.2.0 release built and for me it works fine. Better as all years before!
Many many thanks!!!

@jlaur
Copy link
Contributor Author

jlaur commented Jun 25, 2022

@henrydiesner - good to hear, thanks. You can also try out https://drive.google.com/file/d/17xy2JwRGDcoxcDlIawjx9IDk2hzz_L8A/view?usp=sharing. It includes #12938 (partially) and #12986.

@henrydiesner
Copy link

@jlaur - now i've used the new jar file. Unfortunately I'm not able to use GET requests with my knowledge ;-(
For me it would be great, to have more channels in the binding - in the future!
Thousand thanks in advance for your effort!!!

@jlaur
Copy link
Contributor Author

jlaur commented Jun 27, 2022

now i've used the new jar file. Unfortunately I'm not able to use GET requests with my knowledge ;-(

I'm sorry, but I don't understand what you mean - you can't use GET requests? What happens when you use the binding - can you send some debug/trace logs? This PR is now included in openHAB 3.3 released today, so if you have problems, please create an issue, and I'll look into it.

leifbladt pushed a commit to leifbladt/openhab-addons that referenced this pull request Oct 15, 2022
* Rewrite to avoid external dependencies

Fixes openhab#12720

* Improve session handling
* Avoid reauthorization for each command/poll
* Further improve session handling
* Refactor SSO cookie handling
* Optimize getting DeviceStatus for unknown status code

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
* Rewrite to avoid external dependencies

Fixes openhab#12720

* Improve session handling
* Avoid reauthorization for each command/poll
* Further improve session handling
* Refactor SSO cookie handling
* Optimize getting DeviceStatus for unknown status code

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
* Rewrite to avoid external dependencies

Fixes openhab#12720

* Improve session handling
* Avoid reauthorization for each command/poll
* Further improve session handling
* Refactor SSO cookie handling
* Optimize getting DeviceStatus for unknown status code

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
* Rewrite to avoid external dependencies

Fixes openhab#12720

* Improve session handling
* Avoid reauthorization for each command/poll
* Further improve session handling
* Refactor SSO cookie handling
* Optimize getting DeviceStatus for unknown status code

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Feb 28, 2023
* Rewrite to avoid external dependencies

Fixes openhab#12720

* Improve session handling
* Avoid reauthorization for each command/poll
* Further improve session handling
* Refactor SSO cookie handling
* Optimize getting DeviceStatus for unknown status code

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
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
4 participants