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

Yep, that is why I do it too.

1 Like

What a phenomenal app, mega props! One question/idea for you: wonder if you could, without a lot of effort, add a dashboard tile that would allow presentation of the sleep score and sleep quality results?

Again, thank you!

I don't think it's possible to create custom tiles but it would be feasible to expose the last sleep score and quality per side as attributes and you could then use a tile to show those attributes. If that would work for you let me know and I'll see if I can find some time to connect that data; probably a few weeks out (work and baby keeping me busy lately). It's a separate API call so I'd probably make it optional on the device itself...

@mluck - can you clarify the data you're looking for? Sleep Score seems obvious to me and is the big number the app shows (strangely their API refers to it as sleepQuotient) but what do you mean by sleep quality results? Are you looking for the sleep time, your heart rate, heart rate variability, breath rate, something else?

Love your idea.

Fwiw I'm not sure you're correct about custom tiles. I've seen a bunch of other apps around these parts that create custom tiles by way of the attribute template in dashboards.

But hey, it's your app. And, as a non-dev, beggars like me can't be choosers. I love whatever I can get!

Interesting, I’ve not seen that but also not a huge dashboard user. If you have pointers to the ones you’ve seen I’m happy to take a look and give it a shot.

Ah, I think what is being done is exposing an attribute with some html and then you add an attribute tile for that. I’ll see if I can get something working in the next few weeks.

1 Like

I had a bit of time to start looking into this. They return a lot of data so I probably won’t try to extract all of it. Here’s what I was thinking may be useful:

  log.trace "Message ${data.sleepData.message}"
  log.trace "Score ${data.sleepIQAvg}"
  log.trace "restful sleep time ${convertSecondsToTimeString(data.restfulAvg)}"
  log.trace "restless sleep time ${convertSecondsToTimeString(data.restlessAvg)}" 
  log.trace "heart rate avg ${data.heartRateAvg}"
  log.trace "breath rate ${data.respirationRateAvg}"
  log.trace "out of bed ${convertSecondsToTimeString(data.outOfBedTotal)}"
  log.trace "in bed ${convertSecondsToTimeString(data.inBedTotal)}"
  log.trace "session start ${data.sleepData.sessions[0].startDate}"
  log.trace "session end ${data.sleepData.sessions[data.sleepData.sessions.size() - 1].endDate}"

Are you looking for other data?

What would you (or anyone else) want to see combined on a single tile?

That's super cool. If you can expose the data itself, that creates all sorts of amazing possibilities to encourage good sleep hygiene (e.g., lights, noise, TV) based on prior performance.

As far as a tile is concerned, I was really just imagining the same kind of information that you can get on the "Sleep" page of the Sleep Number app. Hadn't really thought about it more than that.

ok, I was thinking along those lines too. That would involve 5 numbers on the tile representing the last session:

  • sleep score
  • time to fall asleep
  • restful time
  • restless time
  • bed exit time

I can see I'm missing the second so I'll try to see where they stash that. My thought is to simply refresh this data each time presence goes to not present (rather than set a schedule that may or may not work for everyone anyway). And have a device preference that enables the collection (so not everyone makes the API calls if they don't want it).

Sounds great. Triggering the tile update off presence departure is a super idea!

No donate link in Hubitat Package Manager...

image

Thanks for flagging, I wasn't aware that was a thing :slight_smile: I've updated the package manifest to include this community thread, the documentation I have on github and a paypal link. Right now I'm only seeing the donate link show up but hopefully that's just a cache issue and the others will show soon as well.

Some beer money on the way in a bit then.

Must be a caching thing. Still not showing up for me.

I ran a repair on the app and it showed up everything.

Thanks for the donation @lewis.heidrick!

I did some digging and found the metadata is cached until a new package is published (or I guess a repair is run).

@mluck, I think I have some tiles set up now along with basic underpinnings for them, still a bit of cleanup to do (and actually plumbing it so they update) but here's what I'm thinking, let me know what you think.

or I can shrink the font and make it a single tile width:
Screen Shot 2020-09-08 at 5.12.26 PM

( or I guess provide both options)

And all the attributes look like:

Screen Shot 2020-09-08 at 5.08.43 PM

That is frickin awesome. You are my hero. How do you triple-click that heart thing?

This is now released in v1.8. The feature hasn't been thoroughly exercised but I figure I'd release it now as you're likely to use it more than I will so please let me know if it looks like something is misbehaving.

I changed the attribute names a bit to give me some flexibility (in naming) if I want to store two nights of data in the future and I modified the tile a bit so that it fit in one tile (data is always 4x4 on the tile). [edit: just watched this update this morning and it seems to work well. @mluck let me know how it ends up working for you]

If you're using HPM, you should be able to update that way and then go to your device(s) to enable collection.

Quick tile update: I found the fixed font size was odd if I was viewing between mobile and desktop so I've removed the "2x wide" option and instead converged on using viewport size. It should now adjust based on the browser. I tried on Android, iOS and Chrome desktop (as well as various simulated sizes using developer tools) and it seems to behave well but please let me know if you see problems.

1 Like

This morning I HE seemed to be sluggish and automations not running all the way or delayed reaction. So I went to look at the logs and there were a bunch of what appeared to be the same repeating errors regarding this app. I rebooted hub and then I noticed there was an update so I updated through HPM and haven’t noticed any more since. Any idea what this was. Everything seemed to work even though it had login errors.