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

[ecovacs] Initial contribution #12231

Merged
merged 72 commits into from
Mar 21, 2023
Merged

[ecovacs] Initial contribution #12231

merged 72 commits into from
Mar 21, 2023

Conversation

maniac103
Copy link
Contributor

Add initial version of a binding for vacuum cleaners made by Ecovacs. It should work for all devices made in the last 3 years, but
only a limited subset of those have been tested actively (the README spells out the respective devices).

Release for testing in the marketplace: here

@maniac103 maniac103 requested a review from a team as a code owner February 7, 2022 08:15
@lolodomo lolodomo added the new binding If someone has started to work on a binding. For a new binding PR. label Feb 7, 2022
@maniac103
Copy link
Contributor Author

@Flowdalic l would appreciate some help regarding the integration of Smack here. My problem is the following:

  • I only need smack-core for this binding, as I don't need any actual chat features, and Ecovacs' XMPP server doesn't support them anyway
  • The XMPP client binding, on the other side, does need IM features
  • Since smack-core is loaded as OSGi bundle, there's only one instance of both code and static variables for both
  • Smack's initializer code will try to load any relevant classes in the classpath, which will automagically enable any feature in the class path for all connections by a callback system in static variables
  • This means that (at least) when the XMPP binding is loaded, the IM features (e.g. roster) are active for my connections as well
  • Ecovacs' server does not support roster, so each connection attempt yields error messages and stack traces in the log
  • Unfortunately, the XMPP connection to the vacuum seems a bit unstable, so I have to reconnect rather often, which leads to a lot of clutter in the log

I now need some suggestions how to proceed from here. Could I somehow disable the extended features just for a single connection (I tried, but didn't find a way)? Can the error message on roster reload failure be toned down in case the server doesn't support it? (I would have submitted a PR for that, but I seemingly can't build Smack on my machine; probably due to wrong Gradle version?) Is there another way to split the use cases of the XMPP and Ecovacs bindings?
I'd appreciate any pointers. Thanks!

@maniac103 maniac103 changed the title [ecovacs] Initial contribution [ecovacs] [WIP] Initial contribution Feb 7, 2022
@maniac103
Copy link
Contributor Author

The WIP tag is only for the XMPP issue described above, everything else in the binding should be ready for review.

@Flowdalic
Copy link

  • This means that (at least) when the XMPP binding is loaded, the IM features (e.g. roster) are active for my connections as well

Have you tried Roster.setLoadedOnLogin(false)?

Can the error message on roster reload failure be toned down in case the server doesn't support it?

IIRC the XMPP roster is a non discoverable feature. But the IQ request that yield an IQ error response that indicates that the service does not support the roster, which we may could use to change the logging behavior.

I would have submitted a PR for that, but I seemingly can't build Smack on my machine; probably due to wrong Gradle version?

Smack currently needs Gradle 6.8.3 to build.

Is there another way to split the use cases of the XMPP and Ecovacs bindings?

Ideally, and if I understood your issue(s) correctly, we wouldn't need that.

Copy link

@Flowdalic Flowdalic left a comment

Choose a reason for hiding this comment

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

I had a quick look at your implementation and left some comments on things that looked strange to me. I hope you do not mind, especially since I may not fully understood what's done here.

@maniac103
Copy link
Contributor Author

maniac103 commented Feb 7, 2022

Have you tried Roster.setLoadedOnLogin(false)?

I can not find that method in Smack's sources?

But the IQ request that yield an IQ error response that indicates that the service does not support the roster, which we may could use to change the logging behavior.

It does:

2022-02-03 07:43:50.151 [TRACE] [.internal.api.impl.EcovacsXmppDevice] - XXX: SENT (0): <iq id='GWpLy-10' type='get'><query xmlns='jabber:iq:roster'></query></iq>
2022-02-03 07:43:50.161 [TRACE] [.internal.api.impl.EcovacsXmppDevice] - XXX: RECV (0): <iq type="error" to="[email protected]/e7a4f07a" from="ecouser.net" id="GWpLy-10"><error type="cancel" code="501"><feature-not-implemented xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq>
2022-02-03 07:43:50.180 [ERROR] [org.jivesoftware.smack.roster.Roster] - Exception reloading roster
org.jivesoftware.smack.XMPPException$XMPPErrorException: XMPP error reply received from ecouser.net: XMPPError: feature-not-implemented - cancel
	at org.jivesoftware.smack.XMPPException$XMPPErrorException.ifHasErrorThenThrow(XMPPException.java:185) ~[?:?]
	at org.jivesoftware.smack.XMPPException$XMPPErrorException.ifHasErrorThenThrow(XMPPException.java:179) ~[?:?]
	at org.jivesoftware.smack.AbstractXMPPConnection$7.processStanza(AbstractXMPPConnection.java:1542) ~[?:?]
	at org.jivesoftware.smack.AbstractXMPPConnection$5.run(AbstractXMPPConnection.java:1223) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at java.lang.Thread.run(Thread.java:829) [?:?]

... and that was my idea for the logging change: reduce the logging level if the error indicates the feature is not supported.

Smack currently needs Gradle 6.8.3 to build.

That one works, thank you. I'll submit a PR for the logging change. (Edit: PR done)

And thank you for the prompt and detailed responses 👍

@Flowdalic
Copy link

Have you tried Roster.setLoadedOnLogin(false)?

I can not find that method in Smack's sources?

Sorry it is Roster.setRosterLoadedAtLogin().

@maniac103
Copy link
Contributor Author

Sorry it is Roster.setRosterLoadedAtLogin().

That one works and fixes the log spam, thanks!

@maniac103 maniac103 changed the title [ecovacs] [WIP] Initial contribution [ecovacs] Initial contribution Feb 8, 2022
@maniac103 maniac103 force-pushed the ecovacs-rebase branch 2 times, most recently from 7e645d0 to a8c5377 Compare February 13, 2022 13:13
@maniac103 maniac103 force-pushed the ecovacs-rebase branch 3 times, most recently from 1201f66 to 8172c44 Compare February 26, 2022 13:37
@maniac103
Copy link
Contributor Author

@openhab/add-ons-maintainers May I ask for a review and/or help with the OSGi question, please? Thanks.

@fwolter fwolter added help wanted work in progress A PR that is not yet ready to be merged labels May 7, 2022
@maniac103 maniac103 force-pushed the ecovacs-rebase branch 2 times, most recently from 75a5e5a to 775ab52 Compare May 13, 2022 08:46
@maniac103 maniac103 force-pushed the ecovacs-rebase branch 2 times, most recently from b3f48be to 0e438d0 Compare May 25, 2022 07:37
Device name is not necessarily unique.

Signed-off-by: Danny Baumann <[email protected]>
Signed-off-by: Danny Baumann <[email protected]>
Signed-off-by: Danny Baumann <[email protected]>
@jlaur
Copy link
Contributor

jlaur commented Mar 20, 2023

Draft status will effectively prevent the merge button from being accessible, while a lot of text conversations can be harder to interpret and ultimately could lead to a wrong decision being made.

I lost track. I still see the "help wanted" label. Besides the comments from my side, is this PR still blocked because of dependency issues?

@maniac103
Copy link
Contributor Author

I still see the "help wanted" label. Besides the comments from my side, is this PR still blocked because of dependency issues?

No, it should be fine with @J-N-K's comment.

@jlaur jlaur removed the help wanted label Mar 20, 2023
@maniac103
Copy link
Contributor Author

AFAICT only open question that's remaining should be the channel naming discussion now.

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

Another serialNumber round. 🙂

Signed-off-by: Danny Baumann <[email protected]>
@jlaur
Copy link
Contributor

jlaur commented Mar 20, 2023

@maniac103 - there are some checkstyle warnings left. You could take a look at target/code-analysis/report.html.

@maniac103
Copy link
Contributor Author

there are some checkstyle warnings left. You could take a look at target/code-analysis/report.html.

Fixed, thanks for the heads-up.

Copy link
Contributor

@jlaur jlaur left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

Now, you could add your binding's logo to the openHAB website. See https://www.openhab.org/docs/developer/bindings/#add-your-binding-s-logo-to-the-openhab-website

@jlaur jlaur merged commit b47a205 into openhab:main Mar 21, 2023
@jlaur jlaur added this to the 4.0 milestone Mar 21, 2023
@maniac103
Copy link
Contributor Author

Now, you could add your binding's logo to the openHAB website.

Done: openhab/openhab-docs#2035
Thanks for the review and merging!

@JohannesPtaszyk
Copy link

Happy to see how much you invested into this after the initial poc we built together 😍
Well done! Keep the great work and thank you so much for this contribution!

renescherer pushed a commit to renescherer/openhab-addons that referenced this pull request Mar 23, 2023
* [ecovacs] Initial contribution

Add initial version of a binding for vacuum cleaners made by Ecovacs.

Signed-off-by: Danny Baumann <[email protected]>
FordPrfkt pushed a commit to FordPrfkt/openhab-addons that referenced this pull request Apr 20, 2023
* [ecovacs] Initial contribution

Add initial version of a binding for vacuum cleaners made by Ecovacs.

Signed-off-by: Danny Baumann <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new binding If someone has started to work on a binding. For a new binding PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.