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

[velux] Stability checks and improvements in slip io #10119

Merged
merged 4 commits into from
Mar 26, 2021

Conversation

andrewfg
Copy link
Contributor

@andrewfg andrewfg commented Feb 10, 2021

Background

The Velux KLF200 hub is notoriously unpredictable in its communications.

On the OH community forum, various users have recently reported communication issues. But unfortunately the exact cause of the issues if often hard to nail down; and often not repeatable on my own test system; so hard to debug.

Solution

This PR is a step to try to improve the situation by the following means..

  • Some 'hardening' of the Slip IO communications to handle possible (but unexpected) communication edge cases.
  • Extra logging of potential Slip IO errors that should not happen, so we can detect if they do ever actually occur.

Signed-off-by: Andrew Fiddian-Green [email protected]

@andrewfg andrewfg added the enhancement An enhancement or new feature for an existing add-on label Feb 10, 2021
@andrewfg
Copy link
Contributor Author

@gs4711 feedback appreciated

@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/velux-new-openhab2-binding-feedback-welcome/32926/1223

Copy link
Contributor

@gs4711 gs4711 left a comment

Choose a reason for hiding this comment

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

Look fine.... unfortuntelly this addition of debugging code seems to be reasonable.

@andrewfg
Copy link
Contributor Author

unfortuntelly this addition of debugging code seems to be reasonable

:)

Indeed Guenther. Just so you know it, during my tests I discovered the following..

The Slip Encoding is described in the Velux API specification as below. And my idea was to check the correct full syntax of all elements in the Slip telegrams (including LL and KK). But I found that even so called 'good' telegrams are non compliant because, for example, the LL value is wrong (e.g. 0x10 instead of 0x12). So finally I decided to forego the full syntax check (because it definitely does not comply), and instead just check for valid MM and PP markers..

MM PP LL CC CC DD .. DD KK MM

where..
MM = Slip marker (at both start and end of telegram)
PP = Protocol ID
LL = Length of telegram
CC = Command
DD = Data (if any)
KK = Check sum

@andrewfg andrewfg requested a review from a team February 10, 2021 19:34
Signed-off-by: Andrew Fiddian-Green <[email protected]>
@andrewfg andrewfg requested a review from fwolter February 23, 2021 15:39
Signed-off-by: Andrew Fiddian-Green <[email protected]>
@andrewfg andrewfg added the bug An unexpected problem or unintended behavior of an add-on label Feb 28, 2021
@andrewfg
Copy link
Contributor Author

andrewfg commented Feb 28, 2021

Still not happy with the stability?

Unfortunately not. Aargh!

I installed OH3.1.x Milestone 2 just now, and one of my two KLF bridges was left in a zombie state after the restart; which required a manual power cycle to resolve. The two KLF bridges are identical (except that they control different windows and shutters) so there is no clear reason why one bridge would restart cleanly and the other not.

The commit just now is to ensure that the input buffer has been fully emptied before issuing the socket close command; although I can't really see why it would make much difference.

@andrewfg andrewfg requested review from a team and removed request for a team March 5, 2021 18:22
@andrewfg
Copy link
Contributor Author

andrewfg commented Mar 9, 2021

Ping!

@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/velux-new-openhab2-binding-feedback-welcome/32926/1246

@andrewfg
Copy link
Contributor Author

@openhab/add-ons-maintainers could I kindly request someone to review this PR please?

@@ -75,34 +88,47 @@ public void interrupt() {
*/
@Override
public Boolean call() throws Exception {
logger.trace("Poller.call(): started");
Copy link
Member

Choose a reason for hiding this comment

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

I'm a bit in doubt about these log statements in the light of https://www.openhab.org/docs/developer/guidelines.html#f-logging

If there are no other complaints, I would say we should merge it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @martinvw I do understand that the developer guideline says one should not use the logger to replace the debugger. But our problem is that the Velux bridge has an undocumented weakness whereby it sometimes (very infrequently) falls into a "zombie state" that requires the bridge to be physically power cycled. Users of the binding have been trying to track down the exact circumstances when such zombie states occur, but it is very infrequent, so I can't expect normal users to be trying to run the binding in a debugger. That is the reason why I added these logger.trace() commands instead. So I do hope you that can allow this please.

@martinvw
Copy link
Member

@andrewfg could you fix the merge conflict? If no-one else steps it with comments I could merge if after that. Feel free to pine me once you fixed the merge conflict.

@martinvw
Copy link
Member

When people are willing to run the binding in trace mode you could of course also provide a separate version for that.

Given no one else stood up against it, I propose to merge it.

@andrewfg
Copy link
Contributor Author

Given no one else stood up against it, I propose to merge it.

Thank you :)

I have also resolved the merge conflict.

@martinvw martinvw merged commit 361a672 into openhab:main Mar 26, 2021
@andrewfg andrewfg deleted the velux-slip-io branch March 30, 2021 13:08
@kaikreuzer kaikreuzer removed the enhancement An enhancement or new feature for an existing add-on label Apr 2, 2021
@kaikreuzer kaikreuzer added this to the 3.1 milestone Apr 2, 2021
themillhousegroup pushed a commit to themillhousegroup/openhab2-addons that referenced this pull request May 10, 2021
computergeek1507 pushed a commit to computergeek1507/openhab-addons that referenced this pull request Jul 13, 2021
thinkingstone pushed a commit to thinkingstone/openhab-addons that referenced this pull request Nov 7, 2021
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
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
Development

Successfully merging this pull request may close these issues.

5 participants