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.
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…)
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.