01 logo

Go Govee! Automate your home

A simple desktop application to control Govee IoT devices

By Lost in WritingPublished 6 months ago 6 min read
Like
Desktop shortcuts and command-line interface sample run

The Internet is all around us and we are also seeing a greater variety of smart devices that make up the so called Internet Of Things (IoT for short). Better yet, many of these devices have affordable prices, so the question is, can you afford not to automate your home or office?

These days you can classify devices and appliances as:

  • Dumb devices/appliances. These just do their work the old-fashioned way.
  • Smart appliances: They can be controlled and give you status information through some manufacturer-specific mobile app, for example smart washing machines and smart air conditioners.
  • Networked smart devices: they can be monitored through a mobile/desktop app but are not necessarily manufacturer-specific. Their apps and system adhere to common standards, as such you are not locked to one manufacturer. Best of all, they operate in your local network and can even communicate between themselves. Sometimes they need a dedicated gateway device, but others have a distributed gateway, meaning a device can act as such for the others.

Of these I prefer the last option (Networked smart devices) because you can create your own ecosystem of smart devices and combine them to perform complex collaborative functionality. And, as mentioned, I can control them in multiple ways without being locked to a single vendor. Imagine finding a smart device that suits your needs but that is incompatible with the other devices in your network, or that it would require installing yet another app just for that device! Even worse, having to discard your entire ecosystem to start anew!

Govee Smart Devices & Lights

I am a technical person with design and development background. I have even developed firmware since the 1990s. As such, my searches are methodical so that the end result satisfies the needs. And that is how I found these wonderful devices made by an american company named Govee.

For a start, I didn't want to invest in a smart appliance right away. I wanted to give new life to my dumb appliances like traditional lights or air purifiers that only had an On/off switch. I went for Govee's Smart Plug which makes it possible to control any of those old/traditional devices up to 10/15A load. You can think of these smart plugs as prosthetic for old-time devices.

I am security conscious; therefore, my smart plug must not only have interoperability, it must be electrically secure as well. In particular, Govee smart plugs have a good current rating (up to 15A) but also comply to american electrical standards and are made of flame-retardant materials.

So, I got my first smart device and I put it to good use to schedule the air purifier, and kitchen LED lights. Good thing is I can control it with:

  • The Govee Home mobile application
  • The Google Home mobile aplication
  • Amazon's Alexa

But during most of the day I am at my computer (currently a Raspberry Pi) running Debian Linux. Getting my smart phone to control the device can be distracting. So, knowing Govee also offers a public API (Application Program Interface) for personal use, I decided to take it a bit further.

Get started with a $5 discount on your first GOVEE purchase! This is an affiliate link, it doesn't cost you anything extra. You get a $5 discount and we get a small comission to help me with my experiments.

A self-developed Govee device Control desktop app

I have learned a lot (too many to count!) of programming languages in my lifetime. Nowadays, I am developing several with #GoLang a language named Go developed by Google. I like it over Python for many reasons, but primarily because it can be compiled and Go is available in other Operating Systems such as Windows and MacOS, so not just Linux.

I wrote this bare-bones desktop application that I use to control my Govee devices from my Raspberry Pi graphical desktop (see top image) using shorcuts which in turn invoke the CLI (Command-Line Interface) application. You can see two of my desktop shortcuts surrounded by a dashed yellow square in my desktop screenshot above. I have made this public Open Source application available on GitHub's lordofscripts's repository. Feel free to browse it!

Additionally, I can list my devices, inquire their status and control them using the command line. An example is in the terminal console shown on the lower left of the screenshot.

Provided you have GO installed in your system, you can install this application with the following command:

go install github.com/lordofscripts/govee

Using my Govee desktop application

To get it to work on your system, you will need to obtain your own personal Govee API Key (see README on GitHub) and make it known to the app. Obvioulsy, you will also need at least one Govee device. The Smart Plug is a good starting point for low-budget experiments. You can specify your Govee API key either in an optional application configuration file or via the GOVEE_API environment variable.

To control your device(s) with the application, you will need both their model number (for example, mine is an H5083) and their device ID which is actually their MAC (hardware) address. The later is a string of 8 hexadecimal bytes separated by colon, like "0F:1E:2D:3C:4B:5A:69:78".

Since it is very unpractical to remember these addresses, my application uses

govee -list

Provided you are connected to your home network (WiFi or Ethernet), this command will broadcast a request and list all Govee devices that are connected. The output of this simple command gives you the model & MAC address you need to control the device.

govee -mac {MAC_ADDRESS} -model {MODEL_NUMBER} -on

With this command you turn on the smart device using the device address and model number you got from the List command. The curly brackets are just placeholders that should NOT be typed, so it would become something like:

govee -mac 0F:1E:2D:3C:4B:5A:69:78 -model H5083 -on

govee -mac {MAC_ADDRESS} -model {MODEL_NUMBER} -off

With this command you turn off the smart device using the device address and model number you got from the List command.

govee -mac {MAC_ADDRESS} -model {MODEL_NUMBER} -state

With this command you will be given the current state of the device as known by the Govee API servers. It will tell you wether the device is connected to the network, as well as whether it is on or off.

Too difficult to remember that!

That's right! we cannot even remember our friend's mobile phone numbers! But once you get those addresses and model number pairs once, I can show you how to make it much easier!

You can use the configuration file to store your Govee API key. This configuration file is called "govee.json" because it uses a standard JSON formatting. You can use the same configuration file to create a catalog of devices in your ecosystem. Each entry in your ecosystem catalogue contains:

  • The device address (MAC address) — required
  • Its model number — required
  • A user-provided unique ID, for example "coffeeMaker" — required
  • A short comment where you can indicate its location, i.e. "Living room" — optional

So now, instead of specifying the model number (-model parameter) and device address (-mac parameter), you can simply give its unique ID which you remember. Now the commands from above become:

govee -id coffeeMaker -on

govee -id coffeeMaker -off

govee -id coffeeMaker -state

Summary

This was a fun experiment in writing a small Go Language application that I could compile and enjoy the advantages of the Internet of Things, in particular home automation. Better yet, I could use this compiled application while working at my compiter without having to bother with my mobile phone.

You don't need a complex setup to download and compile the application other than the Go installation.

Tags: #IoT #Govee #Go #GoLang #Software #SmartDevices

appshow to
Like

About the Creator

Lost in Writing

Engineer by birth with an inquisitive mind, genealogist, driven by logic & feeling. Traveled to 34 countries and worked for high tech companies in USA/Europe. Facebook & WhatsApp dissident. Privacy advocate. Lost in Writing™ D. Grimaldo

Reader insights

Be the first to share your insights about this piece.

How does it work?

Add your insights

Comments

There are no comments for this story

Be the first to respond and start the conversation.

Sign in to comment

    Find us on social media

    Miscellaneous links

    • Explore
    • Contact
    • Privacy Policy
    • Terms of Use
    • Support

    © 2024 Creatd, Inc. All Rights Reserved.