Image generated by DreamStudio

Top Three Home Automation Libraries for Go

Make Go-based Home Automation Easier

Mike Riley
3 min readDec 4, 2023

--

https://pragprog.com/newsletter/

My latest book with co-author and Go programmer extraordinaire Ricardo Gerardi hit the number one spot on Pragmatic Bookshelf’s best seller list a week after the book hit beta, and for that Ricardo and I are extremely thankful to the readers who offered us such a warm reception!

That success shows the growing interest in programming home automation in Go. In this post, we’ll look at some of the Go libraries that have made my own Go-based home automation applications much easier to develop. Some we use in our book, Automate Your Home Using Go, while others are useful in unique scenarios for one-off apps that either need sensor data or actuator interaction. Here are my top three libraries for home automation in Go in no particular order.

go-rpio

Managed by Go developer Stian Eikeland, this helpful and stable library allows Go programs to access and control the general purpose input output (GPIO) pin status of Raspberry Pi boards. go-rpio is an essential library for controlling actuators or reading sensor values, many of which can be attached either directly to the GPIO pins or via specially designed adapters called hardware attached on top, or HATS for short. These special add-on boards remove the need to solder your own circuits and make it much easier to collect specific data or interact with the world via a simple set of commands.

gohue

This is a fairly straightforward, easy to use package that gives you the ability to poll and control Philips Hue lighting systems. You need a Philips Hue base station and at least one Hue light to leverage this library. While a bit older than other Hue libraries, I prefer gohue’s simple function calls and lightweight approach. However, if you want to control every aspect of what Hue has in their API, then check out the more expansive and recently maintained HueGo library maintained by Go developer Amir Mofasser.

gigbee2mqtt

If you have Zigbee devices in your network (especially popular in electric smart meters and older home automation appliances), you can communicate with them via the gigbee2mqtt library. While you need to expend some effort identifying the ZigBee devices on your network, once identified, sending and receiving messages to them is fairly straightforward. If you would rather not mess with the messaging layer and need something easy to interact with, check out the Zigbee2MQTT bridge instead.

Going Further

Last I checked, there were forty repositories on GitHub specifically keyworded for “Golang” and “home automation,” and I’m sure that number will continue to rise through 2024 and beyond. You can visit the listing of those repositories here.

🔊 Do you have a favorite Go library for home automation? Add to the conversation in the comments.

--

--