openhab-addons icon indicating copy to clipboard operation
openhab-addons copied to clipboard

[sleepiq] Communication with SleepIQ cloud very unreliable

Open mhilbush opened this issue 3 years ago • 8 comments

After fixing the ClassNotFoundException through PR #11700, the binding now runs again (albeit, not well).

However, after the first hour or so of runtime, the binding's communication with the SleepIQ cloud service becomes very unstable. Many transactions fail, and many NPEs are logged. For all intents and purposes, the binding is effectively unusable.

I spent the better part of two days trying to figure it out with little success. I was beginning to think the SleepIQ cloud service was just that unreliable. Rather than continue to invest time into it, I decided to see what would happen if I replaced the JAX-RS implementation with Jetty HttpClient.

Since having done that several days ago, the binding has been rock solid stable for me and one other OH user. I dunno what it was about the JAX-RS implementation (I don't know that package very well), but there was something that was not working with the SleepIQ cloud service. I suspect it had something to do with session management and the AWS load balancer used by the SleepIQ cloud. But I tried multiple changes to the binding, and nothing solved the core issue.

So, my intention is to submit a PR with a highly modified version of the binding that uses the Jetty client instead of JAX-RS. At a minimum, the PR will:

  • replace the JAX-RS implementation with HttpClient
  • use null annotations
  • eliminate the NPEs
  • Implement a new function to set the sleep number from openHAB
  • conform to latest OH coding guidelines and remove as many compiler warnings as practical

Given the closeness to the upcoming release, I will target the next release cycle.

mhilbush avatar Dec 12 '21 15:12 mhilbush

@mhilbush I'm seeing the same. Any chance you have a patch of the changes that you can share?

brianwarner avatar Oct 09 '22 03:10 brianwarner

Yes, try this version of the binding.

https://github.com/mhilbush/openhab-binding-releases/blob/master/sleepiq/org.openhab.binding.sleepiq-3.4.0-SNAPSHOT.jar?raw=true

Please let me know how it works for you. I'm pretty close to submitting the PR, so your feedback would be valuable.

mhilbush avatar Oct 09 '22 10:10 mhilbush

Wow. You really did a lot of work on this, there are a ton of new channels. This looks great! Thank you so much for putting in this work. I'll run it for a bit and keep an eye on my logs, and confirm that I'm seeing the same improvement in stability.

Out of curiosity, did you find a documented API somewhere?

brianwarner avatar Oct 09 '22 14:10 brianwarner

Out of curiosity, did you find a documented API somewhere?

No. I just looked at a couple other implementations that were using some additional APIs.

mhilbush avatar Oct 09 '22 22:10 mhilbush

It's unfortunate they don't publish it.

I think I found a python implementation with the adjustable base endpoints. Is the source for your update branch public yet? I'd be happy to try to implement them.

brianwarner avatar Oct 09 '22 23:10 brianwarner

Just confirming the bridge seems to be rock solid for me as well.

brianwarner avatar Oct 11 '22 20:10 brianwarner

Glad to hear it's working well for you.

Can you post the link to the adjustable base endpoints?

mhilbush avatar Oct 13 '22 13:10 mhilbush

Certainly. Here's a python app: https://github.com/technicalpickles/sleepyq/blob/master/sleepyq/init.py

and it looks like someone wrote a Groovy app for Hubitat as well: https://github.com/rvrolyk/SleepNumberController

Anything I can do to help?

The updated binding is already really popular in the house because one of us is a light sleeper who gets really annoyed with the responsive air setting turning the pump on in the middle of the night, and the other likes the bed to keep air correctly. I have a rule that boosts the sleep number by 5, waits 30 seconds, then drops it back down again, once per day. This at least ensures the bed does a regular pressure adjustment. It wasn't possible before with the read-only endpoints, so multiple wins here. Thanks again for doing this!

brianwarner avatar Oct 13 '22 13:10 brianwarner

This is amazing, thank you so much!

brianwarner avatar Feb 18 '23 16:02 brianwarner