-
-
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
[intesis] Improve session handling #16476
Conversation
I have changed the login process so that the binding now only logs in at the beginning and logs out at the end. If a request fails due to a missing login or an invalid session ID, a new login attempt is made. This ensures that - Several requests can be sent in direct succession (if I switch the air conditioning from cooling to heating, I also want to change the slats at the same time) - Less traffic is generated as there is not a constant logout and login again - Ideally, the login credentials should only be visible once at startup I am unsure whether I have used the correct levels for the logging. The updated binding has been running without any problems for a few weeks now in my environment. First under 4.1.0, and since a few days now under 4.1.1. Signed-off-by: Christoph <fd0cwp@gmx.de>
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.
Left some comments, the build error has to be fixed (spotless), please also check if there are compile warnings.
Edit: Documentation about logging is here: https://www.openhab.org/docs/developer/guidelines.html#f-logging
...g.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisHomeHandler.java
Outdated
Show resolved
Hide resolved
...g.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisHomeHandler.java
Outdated
Show resolved
Hide resolved
…binding/intesis/internal/handler/IntesisHomeHandler.java I think this is no code I changed, but I also prefer your suggestion. Co-authored-by: lsiepel <leosiepel@gmail.com> Signed-off-by: Christoph <36006493+fd0cwp@users.noreply.github.com>
I have changed the login process so that the binding now only logs in at the beginning and logs out at the end. If a request fails due to a missing login or an invalid session ID, a new login attempt is made. This ensures that - Several requests can be sent in direct succession (if I switch the air conditioning from cooling to heating, I also want to change the slats at the same time) - Less traffic is generated as there is not a constant logout and login again - Ideally, the login credentials should only be visible once at startup I am unsure whether I have used the correct levels for the logging. The updated binding has been running without any problems for a few weeks now in my environment. First under 4.1.0, and since a few days now under 4.1.1. Signed-off-by: Christoph <fd0cwp@gmx.de>
...g.intesis/src/main/java/org/openhab/binding/intesis/internal/handler/IntesisHomeHandler.java
Outdated
Show resolved
Hide resolved
I have changed the login process so that the binding now only logs in at the beginning and logs out at the end. If a request fails due to a missing login or an invalid session ID, a new login attempt is made. This ensures that - Several requests can be sent in direct succession (if I switch the air conditioning from cooling to heating, I also want to change the slats at the same time) - Less traffic is generated as there is not a constant logout and login again - Ideally, the login credentials should only be visible once at startup I am unsure whether I have used the correct levels for the logging. The updated binding has been running without any problems for a few weeks now in my environment. First under 4.1.0, and since a few days now under 4.1.1. Signed-off-by: Christoph <fd0cwp@gmx.de>
@@ -109,6 +112,9 @@ public void initialize() { | |||
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Password not set"); | |||
return; | |||
} else { | |||
logger.trace("trying to log in - current session ID: {}", sessionId); | |||
login(); |
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.
initialize()
should return fast and not do any blocking network calls. This is the reason for background initialization below.
@@ -129,6 +135,8 @@ public void dispose() { | |||
refreshJob.cancel(true); | |||
this.refreshJob = null; | |||
} | |||
|
|||
logout(sessionId); |
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.
Same here.
@fd0cwp can you come up with a folow up PR as i missed these comment jlaur mentioned. |
I am not sure if this is reasonable. What is the purpose of the initialize function? I would say that the binding shall be set up so that it is functional. In my view, this also includes the login. I could remove the login from the initialize. This would result in the first call failing, then the login is made and the call is tried again. |
I already stated what I think. 🙂 Please have a look at https://www.openhab.org/docs/developer/bindings/#startup:
So this means you need to move the |
Hi @jlaur, in https://www.openhab.org/docs/developer/bindings/#lifecycle this is noted: However, I found several threads telling what you stated. |
* [intesis] SESSION ID HANDLING IMPROVED Signed-off-by: Christoph <fd0cwp@gmx.de> Signed-off-by: Jørgen Austvik <jaustvik@acm.org>
* [intesis] SESSION ID HANDLING IMPROVED Signed-off-by: Christoph <fd0cwp@gmx.de>
I have changed the login process so that the binding now only logs in at the beginning and logs out at the end. If a request fails due to a missing login or an invalid session ID, a new login attempt is made.
This ensures that
I am unsure whether I have used the correct levels for the logging.
The updated binding has been running without any problems for a few weeks now in my environment. First under 4.1.0, and since a few days now under 4.1.1.
Signed-off-by: Christoph fd0cwp@gmx.de