Browsed by
Category: IoT

The First Rest API! (For the Hatch Baby Rest)

The First Rest API! (For the Hatch Baby Rest)

Ha ha, get it? The first Rest API? Programmer humor, right? Anyway, someone who knows that I love Smart Lights sent me a Hatch Baby Rest as a gift, and I was excited to unbox it and try it out. The Rest is a small nightlight that pairs with an Android or iOS app to set the color, auto-timer/schedule for turning on and off, and controlling the volume of the built-in speaker which plays soothing sounds.

Hatch Baby Rest Nightlight and App

Now, it’s supergreat that the light has an app, but I’ve got like 20 lights in my house and if each one had its own app I’d have a hard time keeping track of 20 different apps for controlling the lights. Luckily I’m a handy guy and I’ve got a home automation setup that could slot in this light quite nicely.

If only it had an API, that is. I mean, in this day and age, what smart light maker doesn’t have one?

clickity-clickity-click (sound of me writing to Hatch Baby to ask about it…)

Hatch Support’s pooh-pooh response

Hmmmm…. well that sucks…

So — you know where this is going, don’t you… fast forward a few hours and I’m happy to introduce to you a great .NET API for the Hatch Baby Rest. Thanks to Windows 10’s improved support (in the Creators Update 15063) for Bluetooth LE pair-less communication, it was actually pretty quick to do. UPDATE: I later on got a note from Ken (VP of software at Hatch Baby) that they’d be happy to contribute to OSS projects in the future, which is super awesome to hear coming from the company, kudos to them.

Here’s a sample, just a few lines of code. Hope this could be useful to other home automators.

GitHub Link: https://github.com/Marcus-L/m4rcus.HatchBaby.Rest, or install it from nuget:

Oh, p.s. it’s not a REST API, it’s a Rest API. I know, it was super confusing in the code too.

Wake up with the Sunrise

Wake up with the Sunrise

I’ve been trying to get up earlier in the morning, so rather than just going to bed earlier, I decided that I needed a wake up light that gradually illuminates like a sunrise, while playing soothing wake up sounds like birds chirping.

My Wake-Up-System wishlist is:

  • The wake up system should fade the lights in slowly like a sunrise
  • It should play wake up sounds (birds chirping) softly at first then progressively louder
  • There should be no annoying glowing lights on the device(s) to keep you up
  • The alarm time should be changeable without using stupid tiny digital alarm clock buttons
  • Both bed occupants can change the wake time easily from our phones
  • Both bed occupants can silence the wake sounds easily from phone or a remote control
The Philips HF3550, a very expensive object

I looked on Amazon and something like this exists, but the damn thing is $200! Also it has pretty terrible reviews, isn’t compatible with Android1, and being just one light it’d end up not being bright enough to wake both occupants of the bed without being blinding (or out of view) for the other. What to do? Buy two? That would be expensive, and the device itself didn’t meet a few wishlist bullets.

So once again instead of deciding to just go to bed earlier, I remembered that I had a pair of Hue Bloom light bulbs packed away in a box. What if I could use those to simulate a sunrise? I set them up and installed the Hue app, which had a built-in scheduled sunrise wake up function. However, there didn’t seem to be a way to play sounds with the lights fading in. I could probably find an app for that, but then there’d be two different things to change around or enable/disable when the wake up schedule is changed, which would have a pretty unacceptable WAF.

I came up empty in a search for such a device, so after a day of tinkering around, I am excited to introduce to you: Sunrise!

The alarm is set from the app, from any phone (it’s a web app with “add-to homescreen” features) and runs off a Raspberry Pi in my closet. Best of all I was able to hook it up to the Hue lights I already own, play wake up music on the Chromecast Audio which was already hooked up to speakers in the room, and works with the X10 remotes I was already using for some other lights in the room.

It works surprisingly great for the duct-taped-togetherness of it all. It’s so nice to have the lights gradually turn on and wake up to the sound of waves crashing or birds chirping, rather than being jolted out of bed with the usual smartphone alarm. I highly recommend it. We’ve each got our own remotes on the side of the bed so both can silence the alarm, turn on the lights and reschedule the alarm without getting out of bed! Bliss.

If you’re sufficiently nerdy (or motivated), feel free to replicate my setup using my code as a starting point, it’s up on GitHub. Happy sleeping (and waking)!

 

  1. A total non-starter, although there’s also a non-iPhone version but the reviews on that say that either the buttons were terrible or the clock LEDs weren’t easily dimmable