This .NET API allows programmatic control over the basic functions of the Hatch Baby Rest Smart Night Light, Sound Machine and OK-to-Wake, including control of Power, Color, Volume and Audio Track.
- .NET Framework v4.6.1+
- Windows 10 Creators Update (OS Version 15063 or later) - to support non-pairing Bluetooth LE communication
- Windows 10 Compatible Bluetooth LE hardware (tested on Intel Dual Band Wireless-AC 7260 with integrated Bluetooth)
Install-Package m4rcus.HatchBaby.Rest
Examples in C#:
using m4rcus.HatchBaby.Rest;
foreach (var rest in RestDevice.Discover().Result)
{
using (rest) // dispose of the device when done with "using" or .Dispose()
{
// save rest.Name and rest.BluetoothAddress
// for later use
await rest.SetPower(true);
await rest.SetVolume(60);
await rest.SetAudioTrack(AudioTrack.TRACK_STREAM);
}
}
// connect directly without discovery if address is known, ex "CBBABE52631F"
var bluetoothAddress = ulong.Parse("CBBABE52631F", System.Globalization.NumberStyles.HexNumber);
using (var rest = new RestDevice("MyHatchRest", bluetoothAddress))
{
Console.WriteLine(rest.Data.Color);
await rest.SetColor(Colors.Red);
await Task.Delay(5000);
await rest.SetPower(false);
}
static void Main(string[] args)
{
// output debugging info to console
Trace.Listeners.Add(new ConsoleTraceListener());
}
See the sample console app for more examples.
This library currently supports Power, Color, Volume and Audio Track. For other functionality (events, time), PRs are welcome!