[RELEASE] Sleep Number SleepIQ SmartThings Integration

After being unable to find a way to control my SleepIQ enabled Sleep Number bed, I took the time to create an app that works! This is my first app on Smart Things, so if there’s something I can do to improve it let me know.

I’ve been using this for a couple of weeks now and it’s been great!

Features

  • Create separate devices for each side of the bed
  • Raise bed to favorite position on either side
  • Lower bed to flat on either side
  • Set Sleep Number on either side
  • Presence Sensor based on if you’re in the bed (Doesn’t update unless you use one of the other controls, I wouldn’t rely on it but it was possible so I enabled it, wasn’t worth a Post Update since I don’t really plan on using it)

I have a joined king with an adjustable base, this is the only configuration I was able to physically test the manager on so if you run into any issues with any other configuration let me know so I can sort it out for everyone.

You must have a SleepIQ account and enabled bed for this to work. It doesn’t work over Bluetooth.

If you HAVE an adjustable base use these:
Adjustable Base Smart App
Adjustable Base Device Handler
If you DON’T have an adjustable base use these:
No Adjustable Base Smart App
No Adjustable Base Device Handler

The only difference between the two is the one without the adjustable base removes the functionality of turning the bed “on” or “off” to raise/lower the bed. It also will display the sleep number on the “My Home” tab rather than whether the bed is raised or flat.

To set it up, just enable the smart app and log in with your SleepIQ account. Then you’ll be able to create a device for each side of your bed. It should support if you have more than one bed on the account as well.

If you’ve never enabled a custom app before user JDRoberts made an amazing tutorial/overview!

Once you have it set up you can name the device/s whatever you like, I named my side “Tim’s Bed” to make controlling through Alexa easy

The bed kind of works like a Dimmable light bulb.

  • On = Raised to Favorite position
  • Off = Flat
  • “Dim” Level = Sleep Number 0-100

This way you can say “Set X Bed to 50” via Alexa and she’ll change the Sleep Number
I also set up a routine for when I say “Raise the bed” it turns the bed “On” and if I say “Lower the bed” it turns it “Off”. This works very well!

I also have a routine that turns the bed “On” in the morning when it’s time to wake up!

If you have a joined bed like me, you only need to turn one side of the bed “On” and the other one will automatically update. If they’re separate you can control them individually

If there are any other features you’d like to see let me know and I’ll see if I can implement them.

Also, it’s totally unnecessary but if you found this useful and want to support feel free to Donate :slight_smile:

6 Likes

I have the Sleep Number bed and I install your app and device driver and when and try to create two side of the bed and name them but they didn’t get created? I also deleted the app from the phone and started over and still couldn’t create the two side? Is there anything something that I’m missing? Thanks for create this I was using another one that just had presence on it. Also to let you know that I first save my id and password and then when in and try to create the bed’s side and it show my bed ID at the top and right side and left side and I click on left or right and assign a name and then hit create and I get an error that something is wrong?

I do not have the adjustable base but would like to be able to adjust the setting with Alexa. Can I use it without the Adjustable base? If so I will give it a try

@Scott_Purkey if you get it working please let me know maybe I’m doing something wrong?

@llcanada Sorry about that. I changed the naming before I uploaded it to github so it couldn’t find the device! Reinstall the app and device handler and it will work now!

@Scott_Purkey Yes it should work fine for you. Turning the bed “On” or “Off” will simply do nothing for you so you can just ignore those settings, but can still set the “Dimmer” to whatever you want the sleep number to be for that side of the bed.

Tim I use the presence to do other things when I go to bed example turn off living lights, etc. also my bed has a light on the bed is there any chance that you can get that to work. Sleep Number calls it a night light and it has a low, med, and high settings. I have other setting also but If I have a wish it would be the night light working thanks, if not it ok cause it not working from the app now. I just try your fix and it’s working and the bed’s show up. Thanks

1 Like

I just want to thank you for taking this on. Here is the link to the one that I’m using for Sleep Number Presence in case you want to see how @Natec was using it for a presence sensor. I have to say that it is working very well for the presence sensor and I wanted to expand it but I not a programmer. If I can do anything to help let me know thanks.

Do you think it would be possible to program privacy mode with the “On” or “Off” button from your code? I also wanted to ask if you have any plans to integrate with Google Home?

I’m not sure what you mean by privacy mode. Is this something that’s part of SmartThings or Amazon Echo?

As for the Google Home, I don’t have one to test, but it should be able to control the switch via SmartThings just like Alexa can! I haven’t used it to know how their routines work, but turning the bed on or off like any old switch should work fine!

In my SleepIQ app there is an option called privacy mode which Turns SleepIQ off when watching TV or reading in bed. I was inquiring if it would be possible to use the On/Off function in your code to disable and re-enable SleepIQ.

Thanks,

Hi, I was very excited to see that someone had taking this on - thank you!

I am having an issue I hope you can assist with - I got everything setup last night and it seemed to be working and then this morning I could no longer make any adjustments via ST. I looked at the logs and see the following messages:

[SleepNumberManager] Error updating family status - Error (groovyx.net.http.HttpResponseException:)
10:30:41 AM: error [SleepNumberManager] Error updating family status - Error (groovyx.net.http.HttpResponseException: Unauthorized)

I see this:
Response Data: [beds:[[bedId:-9223372019840XXXXXX, leftSide:[alertDetailedMessage:Data Out of Sync, alertId:4, isInBed:false, lastLink:00:00:12, pressure:523, sleepNumber:65], rightSide:[alertDetailedMessage:Data Out of Sync, alertId:4, isInBed:false, lastLink:00:00:12, pressure:1685, sleepNumber:50], status:1]]]

Then this keeps popping up:
10:31:38 AM: error java.lang.NullPointerException: Cannot get property ‘fsCurrentPositionPresetRight’ on null object @line 165 (processBedData)

10:31:38 AM: error [SleepNumberManager] Error updating foundation status - Error (java.net.SocketTimeoutException: Read timed out)

10:31:28 AM: trace [SleepNumberManager] Updating Foundation Status for: Right

When I try to change the sleep number I get this:
Put Request failed: /rest/bed/-92233720198402XXXXX/sleepNumber?_k=BVJZUEYWXXXXX : {‘bed’: -9223372019840XXXXXX, ‘side’: L, ‘sleepNumber’: 73} : Error (groovyx.net.http.HttpResponseException: Bad Request)

A lot of these errors seem to indicate a problem with authorization. Have you seen this before?

Also, I have tried completely removing the app and device handler and recreating them - the result was the same.

This is an awesome idea. I had bought my Sleep Number bed not even thinking this was going to be possible. I decided to search though here yesterday and found it. Was able to set it up in mine (had to copy the code as it didn’t show for me from Github) but it worked right away.
I have some suggestions though. My bed has both head raise and leg raise for both my wife and mine separately (it’s a split king bed) so it would be great to control the height of the legs if possible.

Also, the app didn’t seem to update for me other than for the raise of the head. So when I changed the sleep number it still showed the original value even though the activity under the Recently tab shows the change was made but then shows an activity that changed it back even though I had not. The presence indicator didn’t update either. If the app can’t update periodically maybe a refresh button can be added to manually request the refresh.

Hi, Thanks for the hard work! I too am having this issue. I can create one “New Device” but I get an error when I attempt to create a second for the left side. Also, the one that does create, will not change the sleep number from the ST apps. I get the same errors as Cyberfreak is/was. Any help would be greatly appreciated.

Update when I create the first Device, I get this error in the logs:
error org.springframework.security.access.AccessDeniedException: Access is denied @line 5577 (doCall)

Before that, I can see in the log that it does connect to my account and see my current and correct sleep number values. However as soon as I click “Create Device” on either the left or right side in the manager app, I get the above error and nothing will work. Thanks in advance.

using this integration and working well. Is there a way to make it so the actual head/feet up and down could be controlled via a dimmer switch like the firmness is

I did find one issue also when I turn on the right side both sides go up to the same favorite spot for the right side, this does not happen when I turn on the left side nore does it happen when I turn off the left or right side?

I got this working by editing the line it refers to in the code of the SmartApp.

Line 165 reads:

        if((device.currentSide == "Right" && foundationStatus.fsCurrentPositionPresetRight != "Flat") || (device.currentSide == "Left" && foundationStatus.fsCurrentPositionPresetLeft != "Flat")){

I fixed it by changing that to:

        if((device.currentSide == "Right") || (device.currentSide == "Left")){

Basically, it just doesn’t look for the status of the bed’s foundation, and I’d imagine breaks that functionality (but I don’t have a foundation, so I’m imagining that’s where the error came in in the first place.

See my recent comment here to fix this.

EDIT: I have now split app and device manager in two depending on whether you have an adjustable base or not. Please use the correct links above and you won’t have any issues!

Thank you for narrowing this down. I was unable to test it without a bed that doesn’t include a flexible base.

What you did will make the button state always be “on” which doesn’t matter if you don’t have a flexible base. I went ahead and changed the line to:

if(foundationStatus.fsCurrentPositionPresetRight != null && ((device.currentSide == "Right" && foundationStatus.fsCurrentPositionPresetRight != "Flat") || (device.currentSide == "Left" && foundationStatus.fsCurrentPositionPresetLeft != "Flat"))){

Which should keep the functionality of adjusting the base, but not give you the error if you don’t have a flex base! (This will default the switch to “off” if you don’t have the base")

So now no one has to make a change whether you have the flexible base or not.

Thanks again!

I don’t have a split bed so I can’t really test this. So let me make sure I know what you mean

If the bed is flat and you turn on the right side BOTH the sides go up (Wrong)
If the bed is flat and you turn on the left side ONLY the left side goes up
if both sides are up and you turn OFF the right side ONLY the right side goes down
If both sides are up and you turn OFF the left side ONLY the left side goes down

I don’t see this happening in the logs for my bed, but again it’s hard to tell since mine isn’t split.

Also I’d love to have it work as a dimmer for the feet/head position. That was my original goal when I started working on this, but the bed doesn’t work that way for the position of it unfortunately. At least by what I have access to via the API I can only set it to a few set positions. (Flat, Favourite, Snore, Zero-G)

Even if I could I’m not sure how it’d work having two sets of dimmer switches for one device. I don’t know if Smart Things could do that so I’d have to split up the Sleep Number, Head Position, and Foot Position into 3 seperate devices.

Yes the problem is exactly as u described