[RELEASE] Sleep Number Controller - control your Sleep Number bed and use it for presence

Log Event: app:382020-08-27 05:33:02.908 pm errorError groovyx.net.http.HttpResponseException: Not Found in request: [uri:https://prod-api.sleepiq.sleepnumber.com, path:/rest/bed/-999999999999999/foundation/status, requestContentType:application/json, contentType:application/json, headers:[Host:prod-api.sleepiq.sleepnumber.com, User-Agent:SleepIQ/1593766370 CFNetwork/1185.2 Darwin/20.0.0, Cookie:AWSALB=oYLw+LargeSTRING=Another Large String;, DNT:1, Accept-Version:4.3, X-App-Version:4.3.2], query:[_k:null]]

Screen shot of the device. Not sure what you were looking for there. Set the slider to 60, bed is still at 65

(By the way, this is not critical. I am using this to try and learn a little before I start mass migration of my devices)


Okay, it appears to be working now. I deleted the devices, deleted my instance of the app, rebooted, and then reinstalled it and recreated the devices. Seems to be working now.

Any idea why the question marks on the dimmer?
**** Edit**** Still getting the groovy error

that error is why you aren't seeing updates. I think, based your original post, you have a bed but no foundation which doesn't match what I can test for. So I think what I need to do is avoid getting the foundation status in such a scenario but I need to be able to detect that case.

What do you see on the diagnostics page in the app? (note: the bed number isn't PII so while you can change it, it's not sensitive in any way I can determine).

The info there should help me update the app so it skips attempting to determine foundation info when one is not actually available.

Bed: -9223372027438222333

Size: KING
Dual Sleep: true
Components:
    Type: Bed (double)
    Status: INSTALLED
    Model: P5
    Type: Pump
    Status: INSTALLED
    Model: P5

Perfect, thanks. Looks like the presence of "Type: Base" determines if a foundation is present or not (which, in hindsight, makes sense). I should be able to make a few changes to fix this and will bump the version once I've got it changed.

Awesome
On HE for a day and already broke something
:rofl:

Silly question..

I thought using the switch would set it to favorite. Is that available/ possible?

Would be cool to set it to 100 after getting up(or even as an alarm) then auto back to favorite at some point before bed.

If the switch toggled, I could automate in RM

The switch functionality, as I wrote it at least, pertains to the foundation not the pressure (SleepNumber). So on/off equals a favorite foundation position (e.g, head raised, whatever). I don't tend to change my SleepNumber so it didn't occur to me to set that up as an option and doing so would be a pretty big change (to add as an option vs. the current behavior).

However, you can still do this in RM by using time of day as your trigger and setting the dimmer value as your action or you could use a custom command (select type dimmer, your side of bed as device and then use setSleepNumber command). You would have to hardcode the favorite as I don't surface that value anywhere or you could remember the last value before changing it.

For your current problem, can you try changing line 433 in the app to:
if (!foundationStatus.get(bed.bedId) && state.bedInfo[bed.bedId].components.contains("Base")) {

I think that'll fix it but want to make sure nothing else is hiding to break after that.

Sent two change commands which immediately executed with no errors

app:672020-08-27 08:09:29.363 pm debugSending payload to /rest/bed/-9223372027438222333/sleepNumber: {"bedId":"-9223372027438222333","sleepNumber":65,"side":"L"}

app:672020-08-27 08:09:11.604 pm debugSending payload to /rest/bed/-9223372027438222333/sleepNumber: {"bedId":"-9223372027438222333","sleepNumber":70,"side":"L"}

It appears that unless I change the value from within the HE app, it will not reflect on the dimmer. Is that expected behavior? Not a major deal, just asking. I would not normally look at the app anyhow - I will probably set up the RM as you said. I use Talking alarm clock on ST. I can set a virtual switch to switch on when the alarm goes off to trigger the dimmer to set to 100%. And then I will probably use a timed event to set it back to each of our favorites.

Thanks, looks like that one line is enough to make the rest work. I'll get a change in soon'ish; maybe the weekend but maybe sooner :slight_smile: I'll update the release notes at the top of this post once I fix it.

That's not what I'd expect but the app polls so maybe you just didn't wait the poll duration (set in the app; default is 1 minute).

It had actuality been about 20 minutes since I had adjusted. No biggie

The time function in RM works like a charm as does the virtual switch

interesting, I just confirmed mine does work. If you turn on debug logs for the device itself and then click poll you should (soon) see something like:

2020-08-27 08:13:03.828 pm [debug] setStatus([sleepNumber:50, privacyMode:off, headPosition:0, footPosition:0, positionPreset:Flat, positionPresetTimer:Zero G, positionTimer:0, footWarmingTemp:0, footWarmingTimer:0])

if you don't see that or the value for sleepNumber isn't the new one then let me know. If you do see that then it should be working and you should see the sleepNumber attribute change.

I've updated the app to fix your problem so if you use package manager to update you should be set.

So, in the logging, it is correct. However, it is not updating the tile. Set the value in the sleep IQ app instead of hubitat. Waited five minutes so that several polls executed. As you can see, all of the debug polls have the correct value. However, the slider tile never refreshed. Only issue is if someone uses the remote or the app. I even closed the dashboard and reopened in case that would help it to refresh. (This may be why I thought it wasn't working before as that was a test case I was using and I thought the dimmer was not connected somehow.) Top pic is using the Sleep app.

Bottom pic is after using the Dimmer in the dashboard.

The automated adjustments (or any adjustments made in Hubitat) cause the slider to read correctly.

Ah, I think I see the problem; sorry I don't use the dashboard like that and so never noticed the issue. I should be able to fix this.

I doubt that I will use the dashboard a lot. I am just testing everything out and playing. Most likely, I will use the automations. But, in learning, I am just trying all of them out. I plan on a few tablets around the house running a few dashboards for those times where I have to adjust things and do not want to wake the house up with Google responses.... LOL

No worries, you identified a real bug; I missed a case updating the underlying dimmer state based on sleepnumber for the basic device type :slight_smile:

This is now fixed in v1.7

1 Like

Just updated and verified. Solved

1 Like

@rvrolyk Moving to HE from ST where I was using Tims code to reset the bed to 100 every morning. Presence never worked on that so I was excited to see that you have merged the two ST apps into one. I installed it last night and it is working great. Being able to trigger automations on bed presence is so freaking cool. Thank you for the work and supporting it. I think Tim gave up supporting the ST one after being bombarded with support requests. I donated to him and I will definitely be donating to you. Thanks again for the great HE integration of SleepIQ.

2 Likes

Great to hear it's working well for you @sraschke. Welcome to the Hubitat community! And thanks in advance for any donations, definitely not required but much appreciated :slight_smile:

3 Likes

I thought I was the only one who did that.

1 Like

When the installers came to set the bed up they told me it was recommended to set it back to 100 every day. This was to avoid creating a depression in the middle where you always sleep. Made sense to me but I knew that manual routine would not last long. So I looked out of curiosity on ST to see if there was any integrations. And to my surprise there was. It has worked great since. It is even better now with working bed presence to run those automations.

1 Like