Light switches on my wrist: a Garmin Connect IQ app

· garmin, connect-iq, monkey-c, home-automation, raspberry-pi

The sockets that the Pi and Alexa look after now have a third way in: my watch, a Garmin Vivoactive 3. Imagine you’re in bed and want to turn the light off, but don’t fancy shouting at Alexa. Now it’s a tap on my wrist.

Garmin watches run little apps written for Connect IQ, Garmin’s app platform, in its own language, Monkey C. It’s a bit like Java crossed with JavaScript, with a monkey for a mascot. Connect IQ apps don’t get the internet to themselves: their web requests go over Bluetooth to the Garmin app on the phone, which passes them on. That’s fine for flicking a light on, since it’s only one small request.

I downloaded the SDK (version 3.0.12) in the middle of July, and on the first evening got as far as building and running Garmin’s template app. That build still has the monkey as its icon.

This weekend it grew some real icons, borrowed from Google’s Material Design set: a sofa for the lamp, and a bed for the bedroom socket.

The app’s two icons: a sofa and a bed.

That’s the whole app: the two icons side by side, one per socket. Tap one to toggle its socket, and the icon goes yellow while that socket is on.

The Pi’s side

The app talks to the little HTTP API on the Pi, the one that already lets me switch a socket with /send/<channel>/<state>. State 2 means “toggle”, which is exactly what a watch button wants. It saves the watch from having to know whether the lamp is currently on, and the reply tells it the new state anyway.

The Pi’s server changed the same evening:

  • a third socket, for the bedroom, alongside the lamp and the stereo;
  • replies labelled as JSON rather than HTML. Connect IQ is fussy about this: ask for JSON, get back something labelled text/html, and you get an error instead of data;
  • an “everything” channel, number 8, to switch all the sockets at once.

Where it stands

The watch app has its icons, the Pi has a bedroom socket and a watch-friendly API, and the lamp can now be switched from my wrist.

Update, late 2019: It works, but it hasn't really caught on. Getting to the app on the watch takes just long enough that it's always easier to reach for the physical remote, or ask Alexa.